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

Small fixes #321

Merged
merged 2 commits into from
Apr 29, 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Local testing
playground*
foo*

# Apple :/
.DS_Store

Expand Down
2 changes: 1 addition & 1 deletion analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import argparse
import datetime
import json
import multiprocessing
import operator
import os
import sys
import multiprocessing
from multiprocessing import Pool, freeze_support

import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion model.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,11 @@ def saveLinearClassifier(classifier, model_path: str, labels: list[str], mode="r


def save_raven_model(classifier, model_path, labels: list[str], mode="replace"):
import tensorflow as tf
import csv
import json

import tensorflow as tf

global PBMODEL

tf.get_logger().setLevel("ERROR")
Expand Down
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
librosa==0.9.2
resampy
tensorflow==2.15.0
gradio
webview
tqdm
bottle
requests
2 changes: 1 addition & 1 deletion segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Can be used to save the segments of the audio files for each detection.
"""
import argparse
import os
import multiprocessing
import os
from multiprocessing import Pool

import numpy as np
Expand Down
12 changes: 7 additions & 5 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
Can be used to train a custom classifier with new training data.
"""
import argparse
import os
import tqdm
import multiprocessing
import os
from functools import partial
from multiprocessing.pool import Pool

import numpy as np
import tqdm

import audio
import config as cfg
import model
import utils


def _loadAudioFile(f, label_vector, config):
"""Load an audio file and extract features.
Args:
Expand All @@ -40,7 +41,7 @@ def _loadAudioFile(f, label_vector, config):
except Exception as e:
# Print Error
print(f"\t Error when loading file {f}", flush=True)
pass
return np.array([]), np.array([])

# Crop training samples
if cfg.SAMPLE_CROP_MODE == "center":
Expand Down Expand Up @@ -208,10 +209,11 @@ def trainModel(on_epoch_end=None, on_trial_result=None, on_data_load_end=None):
print(f"...Done. Loaded {x_train.shape[0]} training samples and {y_train.shape[1]} labels.", flush=True)

if cfg.AUTOTUNE:
import keras_tuner
import keras
import gc

import keras
import keras_tuner

# Call callback to initialize progress bar
if on_trial_result:
on_trial_result(0)
Expand Down
3 changes: 2 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"""
import os
import traceback
import numpy as np
from pathlib import Path

import numpy as np

import config as cfg


Expand Down