From 6154906cb62e16f070eb8a1d82aa05bf352e6402 Mon Sep 17 00:00:00 2001 From: Josef Haupt Date: Wed, 14 Aug 2024 16:17:25 +0200 Subject: [PATCH] Clean up (#409) * remove build files, move GUI-Version to build process --------- Co-authored-by: Josef Haupt --- .gitignore | 1 + config.py | 3 -- extra-hooks/hook-gradio.py | 3 -- extra-hooks/hook-gradio_client.py | 3 -- extra-hooks/hook-librosa.py | 3 -- gui.py | 6 +-- gui/gui.js | 74 ++++++++++++++++--------------- 7 files changed, 43 insertions(+), 50 deletions(-) delete mode 100644 extra-hooks/hook-gradio.py delete mode 100644 extra-hooks/hook-gradio_client.py delete mode 100644 extra-hooks/hook-librosa.py diff --git a/.gitignore b/.gitignore index bfb66f51..f74e890a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ installers/ desktop.ini *.iss *deploy* +*hook* # Custom classifier checkpoints/custom/ diff --git a/config.py b/config.py index 8cd95a0a..713385db 100644 --- a/config.py +++ b/config.py @@ -2,9 +2,6 @@ # Misc settings # ################# -# GUI version -GUI_VERSION: str = "1.2.0" - # Random seed for gaussian noise RANDOM_SEED: int = 42 diff --git a/extra-hooks/hook-gradio.py b/extra-hooks/hook-gradio.py deleted file mode 100644 index 1e0aa9be..00000000 --- a/extra-hooks/hook-gradio.py +++ /dev/null @@ -1,3 +0,0 @@ -from PyInstaller.utils.hooks import collect_data_files - -datas = collect_data_files("gradio") diff --git a/extra-hooks/hook-gradio_client.py b/extra-hooks/hook-gradio_client.py deleted file mode 100644 index 2f5fd45d..00000000 --- a/extra-hooks/hook-gradio_client.py +++ /dev/null @@ -1,3 +0,0 @@ -from PyInstaller.utils.hooks import collect_data_files - -datas = collect_data_files("gradio_client") diff --git a/extra-hooks/hook-librosa.py b/extra-hooks/hook-librosa.py deleted file mode 100644 index 25686ad5..00000000 --- a/extra-hooks/hook-librosa.py +++ /dev/null @@ -1,3 +0,0 @@ -from PyInstaller.utils.hooks import collect_data_files - -datas = collect_data_files("librosa") diff --git a/gui.py b/gui.py index e3f761d9..b2f3e9ad 100644 --- a/gui.py +++ b/gui.py @@ -937,7 +937,7 @@ def build_footer(): f"""
-
GUI version: {cfg.GUI_VERSION}
+
GUI version: {os.environ['GUI_VERSION'] if FROZEN else 'main'}
Model version: {cfg.MODEL_VERSION}
K. Lisa Yang Center for Conservation Bioacoustics
Chemnitz University of Technology
@@ -1587,14 +1587,14 @@ def create_log_plot(positives, negatives, fig_num=None): if 0 > x_val > 1: continue - x_vals.append(x_val) + x_vals.append([x_val]) y_val.append(1 if fl in positives else 0) except ValueError: pass if (len(positives) + len(negatives)) >= 2 and len(set(y_val)) > 1: log_model = linear_model.LogisticRegression(C=55) - log_model.fit([[x] for x in x_vals], y_val) + log_model.fit(x_vals, y_val) Xs = np.linspace(0, 10, 200) Ys = expit(Xs * log_model.coef_ + log_model.intercept_).ravel() target_ps = [0.85, 0.9, 0.95, 0.99] diff --git a/gui/gui.js b/gui/gui.js index 6d380fc0..3d0e304a 100644 --- a/gui/gui.js +++ b/gui/gui.js @@ -1,45 +1,49 @@ function init() { function checkForNewerVersion() { - console.log("Checking for newer version..."); + let gui_version_element = document.getElementById("current-version") + + if (gui_version_element && gui_version_element.textContent != "main") { + console.log("Checking for newer version..."); - function sendGetRequest(url) { - return new Promise((resolve, reject) => { - const xhr = new XMLHttpRequest(); - xhr.open("GET", url); - xhr.onload = () => { - if (xhr.status === 200) { - resolve(xhr.responseText); - } else { - reject(new Error(`Request failed with status ${xhr.status}`)); - } - }; - xhr.onerror = () => { - reject(new Error("Request failed")); - }; - xhr.send(); - }); - } + function sendGetRequest(url) { + return new Promise((resolve, reject) => { + const xhr = new XMLHttpRequest(); + xhr.open("GET", url); + xhr.onload = () => { + if (xhr.status === 200) { + resolve(xhr.responseText); + } else { + reject(new Error(`Request failed with status ${xhr.status}`)); + } + }; + xhr.onerror = () => { + reject(new Error("Request failed")); + }; + xhr.send(); + }); + } - const apiUrl = "https://api.github.com/repos/kahst/BirdNET-Analyzer/releases/latest"; + const apiUrl = "https://api.github.com/repos/kahst/BirdNET-Analyzer/releases/latest"; - sendGetRequest(apiUrl) - .then(response => { - const current_version = "v" + document.getElementById("current-version").textContent; - const response_object = JSON.parse(response); - const latest_version = response_object.tag_name; + sendGetRequest(apiUrl) + .then(response => { + const current_version = "v" + document.getElementById("current-version").textContent; + const response_object = JSON.parse(response); + const latest_version = response_object.tag_name; - if (current_version !== latest_version) { - const updateNotification = document.getElementById("update-available"); + if (current_version !== latest_version) { + const updateNotification = document.getElementById("update-available"); - updateNotification.style.display = "block"; - const linkElement = updateNotification.getElementsByTagName("a")[0] - linkElement.href = response_object.html_url; - linkElement.target = "_blank"; - } - }) - .catch(error => { - console.error(error); - }); + updateNotification.style.display = "block"; + const linkElement = updateNotification.getElementsByTagName("a")[0] + linkElement.href = response_object.html_url; + linkElement.target = "_blank"; + } + }) + .catch(error => { + console.error(error); + }); + } } function overwriteStyles() {