Skip to content

Commit

Permalink
Add custom classifier option
Browse files Browse the repository at this point in the history
  • Loading branch information
rdz-oss committed May 22, 2024
1 parent a2ad5a1 commit 59eac94
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
6 changes: 6 additions & 0 deletions analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,15 @@ def analyzeFile(item):
# Sort by score
p_sorted = sorted(p_labels, key=operator.itemgetter(1), reverse=True)
p_sorted_ = list(p_sorted)
# human_cutoff = max(10, int(len(p_sorted) * priv_thresh / 100.0))
# for i in range(min(10, len(p_sorted))):
# if p_sorted[i][0] == 'Human_Human':
for i in range(len(p_sorted_)):
p_sorted_[i] = list(p_sorted_[i])
p_sorted_[i][1] = str(p_sorted_[i][1])
# check for privacy pot.here: if a human is present in top %, then
# set first entry to human_voclization. Filter that out with the
# excluded species list in the Pi system
# for i in len(p_sorted):
# p_sorted[i][1] = str(p_sorted[i][1])
# print(p_sorted[i][1])
Expand Down
Binary file added checkpoints/bats/v1.0/CUSTOM-BAT-256kHz.tflite
Binary file not shown.
31 changes: 31 additions & 0 deletions checkpoints/bats/v1.0/CUSTOM-BAT-256kHz_Labels.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Barbastella barbastellus_Western barbastelle
Eptesicus nilssonii_Northern bat
Eptesicus serotinus_Serotine bat
Hypsugo savii_Savis pipistrelle
Myotis bechsteinii_Bechsteins bat
Myotis dasycneme_Pond bat
Myotis daubentonii_Daubentons or Whiskered bat
Myotis emarginatus_Geoffroys bat
Myotis myotis_Greater mouse-eared bat
Myotis mystacinus_Whiskered or Daubentons bat
Myotis nattereri_Natterers bat
Nyctalus leisleri_Lesser noctule
Nyctalus noctula_Common noctule
Pipistrellus kuhlii_Kuhls or Nathusius pipistrelle
Pipistrellus nathusii_Nathusius or Kuhls pipistrelle
Pipistrellus pipistrellus_Common pipistrelle
Pipistrellus pygmaeus_Soprano pipistrelle
Plecotus auritus_Brown or Grey long eared bat
Rhinolophus ferrumequinum_Greater horseshoe bat
Rhinolophus hipposideros_Lesser horseshoe bat
Vespertilio murinus_Parti-coloured bat
audiomoth
background
bird
collected
electrical
insect
mechanical
other
pro
rain
Binary file added checkpoints/bats/v1.0/CUSTOM-BIRD-48kHz.tflite
Binary file not shown.
31 changes: 31 additions & 0 deletions checkpoints/bats/v1.0/CUSTOM-BIRD-48kHz_Labels.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Barbastella barbastellus_Western barbastelle
Eptesicus nilssonii_Northern bat
Eptesicus serotinus_Serotine bat
Hypsugo savii_Savis pipistrelle
Myotis bechsteinii_Bechsteins bat
Myotis dasycneme_Pond bat
Myotis daubentonii_Daubentons or Whiskered bat
Myotis emarginatus_Geoffroys bat
Myotis myotis_Greater mouse-eared bat
Myotis mystacinus_Whiskered or Daubentons bat
Myotis nattereri_Natterers bat
Nyctalus leisleri_Lesser noctule
Nyctalus noctula_Common noctule
Pipistrellus kuhlii_Kuhls or Nathusius pipistrelle
Pipistrellus nathusii_Nathusius or Kuhls pipistrelle
Pipistrellus pipistrellus_Common pipistrelle
Pipistrellus pygmaeus_Soprano pipistrelle
Plecotus auritus_Brown or Grey long eared bat
Rhinolophus ferrumequinum_Greater horseshoe bat
Rhinolophus hipposideros_Lesser horseshoe bat
Vespertilio murinus_Parti-coloured bat
audiomoth
background
bird
collected
electrical
insect
mechanical
other
pro
rain
14 changes: 13 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def handleRequest():
os.unlink(file_path_tmp.name)
def set_analysis_location():

if args.area not in ["Bavaria", "South-Wales", "UK", "USA","USA-EAST","USA-WEST","BIRDS"]:
if args.area not in ["Bavaria", "South-Wales", "UK", "USA","USA-EAST","USA-WEST","BIRDS","CUSTOM_BIRD","CUSTOM_BAT"]:
exit(code="Unknown location option.")
else:
args.lat = -1
Expand Down Expand Up @@ -249,6 +249,18 @@ def set_analysis_location():
cfg.SIG_OVERLAP = cfg.SIG_LENGTH / 4.0
cfg.SIG_MINLEN = cfg.SIG_LENGTH / 3.0

elif args.area == "CUSTOM_BIRD":
cfg.CUSTOM_CLASSIFIER = cfg.BAT_CLASSIFIER_LOCATION + "/CUSTOM-BIRD-48kHz.tflite"
cfg.LABELS_FILE = cfg.BAT_CLASSIFIER_LOCATION + "/CUSTOM-BIRD-48kHz_Labels.txt"
cfg.SAMPLE_RATE = 48000
cfg.SIG_LENGTH = 3
cfg.SIG_OVERLAP = cfg.SIG_LENGTH / 4.0
cfg.SIG_MINLEN = cfg.SIG_LENGTH / 3.0

elif args.area == "CUSTOM_BAT":
cfg.CUSTOM_CLASSIFIER = cfg.BAT_CLASSIFIER_LOCATION + "/CUSTOM-BAT-256kHz.tflite"
cfg.LABELS_FILE = cfg.BAT_CLASSIFIER_LOCATION + "/CUSTOM-BAT-256kHz_Labels.txt"
cfg.LABELS = utils.readLines(cfg.LABELS_FILE)

else:
cfg.CUSTOM_CLASSIFIER = None
Expand Down

0 comments on commit 59eac94

Please sign in to comment.