Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maximum value for crop length in training data #373

Merged
merged 1 commit into from
Jul 2, 2024
Merged
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
6 changes: 5 additions & 1 deletion audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ def splitSignal(sig, rate, seconds, overlap, minlen):
rate = cfg.SAMPLE_RATE
if seconds is None or seconds <= 0:
seconds = cfg.SIG_LENGTH
if overlap is None or overlap < 0 or overlap >= seconds:
if overlap is None or overlap < 0:
overlap = cfg.SIG_OVERLAP
if minlen is None or minlen <= 0 or minlen > seconds:
minlen = cfg.SIG_MINLEN

# Make sure overlap is smaller then signal duration
if overlap >= seconds:
overlap = seconds - 0.01

# Number of frames per chunk, per step and per minimum signal
chunksize = int(rate * seconds)
Expand Down
13 changes: 8 additions & 5 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def runAnalysis(
cfg.SIGMOID_SENSITIVITY = max(0.5, min(1.0 - (float(sensitivity) - 1.0), 1.5))

# Set overlap
cfg.SIG_OVERLAP = overlap
cfg.SIG_OVERLAP = max(0.0, min(2.9, float(overlap)))

# Set frequency range
cfg.BANDPASS_FMIN = max(0, min(cfg.SIG_FMAX, int(fmin)))
Expand Down Expand Up @@ -596,7 +596,7 @@ def start_training(

cfg.TRAIN_DATA_PATH = data_dir
cfg.SAMPLE_CROP_MODE = crop_mode
cfg.SIG_OVERLAP = crop_overlap
cfg.SIG_OVERLAP = max(0.0, min(2.9, float(crop_overlap)))
cfg.CUSTOM_CLASSIFIER = str(Path(output_dir) / classifier_name)
cfg.TRAIN_EPOCHS = int(epochs)
cfg.TRAIN_BATCH_SIZE = int(batch_size)
Expand Down Expand Up @@ -1342,9 +1342,12 @@ def on_autotune_change(value):
label=loc.localize("training-tab-crop-mode-radio-label"),
info=loc.localize("training-tab-crop-mode-radio-info"),
)
crop_overlap = gr.Number(
0.0,
minimum=0.0,

crop_overlap = gr.Slider(
minimum=0,
maximum=2.99,
value=0,
step=0.01,
label=loc.localize("training-tab-crop-overlap-number-label"),
info=loc.localize("training-tab-crop-overlap-number-info"),
visible=False,
Expand Down
2 changes: 1 addition & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def run_trial(self, trial, *args, **kwargs):
# Config
cfg.TRAIN_DATA_PATH = args.i
cfg.SAMPLE_CROP_MODE = args.crop_mode
cfg.SIG_OVERLAP = args.crop_overlap
cfg.SIG_OVERLAP = max(0.0, min(2.9, float(args.crop_overlap)))
cfg.CUSTOM_CLASSIFIER = args.o
cfg.TRAIN_EPOCHS = args.epochs
cfg.TRAIN_BATCH_SIZE = args.batch_size
Expand Down