Skip to content

Commit

Permalink
Small fixes (#321)
Browse files Browse the repository at this point in the history
* some small fixes

* updated requirements

---------

Co-authored-by: Josef Haupt <josef.haupt@phil.tu-chemnitz.de>
  • Loading branch information
Josef-Haupt and Josef Haupt authored Apr 29, 2024
1 parent 1e55caf commit 0327cc1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
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 @@ -3,9 +3,10 @@

import os
import traceback
import numpy as np
from pathlib import Path

import numpy as np

import config as cfg


Expand Down

0 comments on commit 0327cc1

Please sign in to comment.