Skip to content
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
8 changes: 7 additions & 1 deletion birdnet_analyzer/analyze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ def set_params(
cfg.LABELS = read_lines(cfg.LABELS_FILE)
else:
cfg.APPLY_SIGMOID = False
# our output format
cfg.LABELS_FILE = os.path.join(custom_classifier, "labels", "label_names.csv")
cfg.LABELS = [line.split(",")[1] for line in read_lines(cfg.LABELS_FILE)]

if not os.path.isfile(cfg.LABELS_FILE):
cfg.LABELS_FILE = os.path.join(custom_classifier, "assets", "label.csv")
cfg.LABELS = read_lines(cfg.LABELS_FILE)
else:
cfg.LABELS = [line.split(",")[1] for line in read_lines(cfg.LABELS_FILE)]
else:
cfg.LATITUDE, cfg.LONGITUDE, cfg.WEEK = lat, lon, week
cfg.CUSTOM_CLASSIFIER = None
Expand Down
4 changes: 4 additions & 0 deletions birdnet_analyzer/gui/assets/gui.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ footer {

#single-file-output td:first-of-type span {
text-align: center;
}

.table-container>.header-row {
display: none;
}
30 changes: 28 additions & 2 deletions birdnet_analyzer/gui/assets/gui.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function init() {
function checkForNewerVersion() {
let gui_version_element = document.getElementById("current-version")

if (gui_version_element && gui_version_element.textContent != "main") {
console.log("Checking for newer version...");

Expand Down Expand Up @@ -30,7 +30,7 @@ function init() {
const current_version = document.getElementById("current-version").textContent;
const response_object = JSON.parse(response);
const latest_version = response_object.tag_name;

if (latest_version.startsWith("v")) {
latest_version = latest_version.slice(1);
}
Expand All @@ -57,6 +57,32 @@ function init() {
document.head.appendChild(styles);
}

function bindReviewKeyShortcuts() {
const posBtn = document.getElementById("positive-button");
const negBtn = document.getElementById("negative-button");
const skipBtn = document.getElementById("skip-button");
const undoBtn = document.getElementById("undo-button");

if (!posBtn || !negBtn) {
return;
}

console.log("Binding review key shortcuts...");

document.addEventListener("keydown", function (event) {
if (event.key === "ArrowRight") {
posBtn.click();
} else if (event.key === "ArrowLeft") {
negBtn.click();
} else if (event.key === "ArrowDown") {
undoBtn.click();
} else if (event.key === "ArrowUp") {
skipBtn.click();
}
});
}

checkForNewerVersion();
overwriteStyles();
bindReviewKeyShortcuts();
}
31 changes: 23 additions & 8 deletions birdnet_analyzer/gui/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,28 @@ def create_log_plot(positives, negatives, fig_num=None):
with gr.Column() as review_item_col:
with gr.Row():
with gr.Column():
spectrogram_image = gr.Plot(label=loc.localize("review-tab-spectrogram-plot-label"), show_label=False)
spectrogram_image = gr.Plot(
label=loc.localize("review-tab-spectrogram-plot-label"), show_label=False
)
with gr.Row():
spectrogram_dl_btn = gr.Button("Download spectrogram", size="sm")
regression_dl_btn = gr.Button("Download regression", size="sm")

with gr.Column():
with gr.Row():
skip_btn = gr.Button(loc.localize("review-tab-skip-button-label"))
undo_btn = gr.Button(loc.localize("review-tab-undo-button-label"))
positive_btn = gr.Button(loc.localize("review-tab-pos-button-label"))
negative_btn = gr.Button(loc.localize("review-tab-neg-button-label"))
skip_btn = gr.Button(loc.localize("review-tab-skip-button-label"), elem_id="skip-button")
undo_btn = gr.Button(loc.localize("review-tab-undo-button-label"), elem_id="undo-button")

positive_btn = gr.Button(
loc.localize("review-tab-pos-button-label"),
elem_id="positive-button",
variant="huggingface",
)
negative_btn = gr.Button(
loc.localize("review-tab-neg-button-label"),
elem_id="negative-button",
variant="huggingface",
)

with gr.Group():
review_audio = gr.Audio(
Expand Down Expand Up @@ -315,7 +326,9 @@ def update_review(next_review_state: dict, selected_species: str = None):
else:
update_dict |= {review_item_col: gr.Column(visible=False), no_samles_label: gr.Label(visible=True)}

update_dict[regression_dl_btn] = gr.Button(interactive=update_dict[species_regression_plot].constructor_args["visible"])
update_dict[regression_dl_btn] = gr.Button(
interactive=update_dict[species_regression_plot].constructor_args["visible"]
)

return update_dict

Expand Down Expand Up @@ -357,7 +370,9 @@ def toggle_autoplay(value):
def download_plot(plot, filename=""):
imgdata = base64.b64decode(plot.plot.split(",", 1)[1])
res = gu._WINDOW.create_file_dialog(
gu.webview.SAVE_DIALOG, file_types=("PNG (*.png)", "Webp (*.webp)", "JPG (*.jpg)"), save_filename=filename
gu.webview.SAVE_DIALOG,
file_types=("PNG (*.png)", "Webp (*.webp)", "JPG (*.jpg)"),
save_filename=filename,
)

if res:
Expand All @@ -382,7 +397,7 @@ def download_plot(plot, filename=""):
file_count_matrix,
species_regression_plot,
undo_btn,
regression_dl_btn
regression_dl_btn,
]

spectrogram_dl_btn.click(
Expand Down