Skip to content

Commit

Permalink
incorporation of #465
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Haupt committed Oct 18, 2024
1 parent 3452cc1 commit ca3f962
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion birdnet_analyzer/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def analyzeFile(item):
pred = p[i]

# Assign scores to labels
p_labels = zip(cfg.LABELS, pred)
p_labels = zip(cfg.LABELS, pred, strict=True)

# Sort by score
p_sorted = sorted(p_labels, key=operator.itemgetter(1), reverse=True)
Expand Down
3 changes: 3 additions & 0 deletions birdnet_analyzer/gui/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import gradio as gr

import birdnet_analyzer.analyze as analyze
import birdnet_analyzer.model as model
import birdnet_analyzer.config as cfg
import birdnet_analyzer.localization as loc
import birdnet_analyzer.utils as utils
Expand Down Expand Up @@ -100,6 +101,8 @@ def runAnalysis(
if custom_classifier_file is None:
raise gr.Error(loc.localize("validation-no-custom-classifier-selected"))

model.resetCustomClassifier()

# Set custom classifier?
cfg.CUSTOM_CLASSIFIER = (
custom_classifier_file # we treat this as absolute path, so no need to join with dirname
Expand Down
8 changes: 8 additions & 0 deletions birdnet_analyzer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
C_PBMODEL = None


def resetCustomClassifier():
global C_INTERPRETER
global C_PBMODEL

C_INTERPRETER = None
C_PBMODEL = None


def loadModel(class_output=True):
"""Initializes the BirdNET Model.
Expand Down

0 comments on commit ca3f962

Please sign in to comment.