Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions batbot/spectrogram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import pyastar2d
import scipy.signal # Ensure this is at the top with other imports
import tqdm
from line_profiler import LineProfiler
from scipy import ndimage

# from PIL import Image
Expand All @@ -29,7 +28,12 @@

from batbot import log

lp = LineProfiler()
PROFILE = os.environ.get('BATBOT_PROFILE', '').lower() in ('1', 'true', 'yes')

if PROFILE:
from line_profiler import LineProfiler

lp = LineProfiler()


FREQ_MIN = 5e3
Expand All @@ -38,7 +42,8 @@

def compute(*args, **kwargs):
retval = compute_wrapper(*args, **kwargs)
lp.print_stats()
if PROFILE:
lp.print_stats()
return retval


Expand Down Expand Up @@ -1298,7 +1303,7 @@ def calculate_harmonic_and_echo_flags(
return harmonic_flag, harmonic_peak, echo_flag, echo_peak


@lp
@lp if PROFILE else lambda f: f
def compute_wrapper(
wav_filepath, annotations=None, output_folder='.', bitdepth=16, debug=False, **kwargs
):
Expand Down
1 change: 1 addition & 0 deletions requirements/optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ flake8
# gradio
ipython
isort
line_profiler
# onnx
# onnxruntime
pre-commit
Expand Down
1 change: 0 additions & 1 deletion requirements/runtime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ click
cryptography
cython
librosa
line_profiler
matplotlib
numpy
opencv-python-headless
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ install_requires =
cryptography
cython
librosa
line_profiler
matplotlib
numpy
opencv-python-headless
Expand Down
Loading