Skip to content

Commit

Permalink
Don't regenerate files if they exist
Browse files Browse the repository at this point in the history
  • Loading branch information
csaudiodesign committed Dec 10, 2023
1 parent 570567f commit 69839fc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion batdetect2_gui/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ def compute_image_data(audio_raw, sampling_rate, spec_params, reference):
segment_width = spec.shape[1] // n_segments
dims = (spec.shape[0], spec.shape[1])

os.makedirs("data", exist_ok=True)
if os.path.exists(f'data/{os.path.basename(reference)}_15.jpg'):
print("Spectrogram already generated.")
return [f'data/{os.path.basename(reference)}_{i}.jpg' for i in range(n_segments)], dims

# split spec into multiple parts along the x axis
os.makedirs("data", exist_ok=True)
im_paths = []
for i in range(n_segments):
start = i * segment_width
Expand Down

0 comments on commit 69839fc

Please sign in to comment.