Skip to content

Commit

Permalink
Clean up (#409)
Browse files Browse the repository at this point in the history
* remove build files, move GUI-Version to build process

---------

Co-authored-by: Josef Haupt <[email protected]>
  • Loading branch information
Josef-Haupt and Josef Haupt authored Aug 14, 2024
1 parent 132b6f8 commit 6154906
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ installers/
desktop.ini
*.iss
*deploy*
*hook*

# Custom classifier
checkpoints/custom/
Expand Down
3 changes: 0 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
# Misc settings #
#################

# GUI version
GUI_VERSION: str = "1.2.0"

# Random seed for gaussian noise
RANDOM_SEED: int = 42

Expand Down
3 changes: 0 additions & 3 deletions extra-hooks/hook-gradio.py

This file was deleted.

3 changes: 0 additions & 3 deletions extra-hooks/hook-gradio_client.py

This file was deleted.

3 changes: 0 additions & 3 deletions extra-hooks/hook-librosa.py

This file was deleted.

6 changes: 3 additions & 3 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ def build_footer():
f"""
<div style='display: flex; justify-content: space-around; align-items: center; padding: 10px; text-align: center'>
<div>
<div style="display: flex;flex-direction: row;">GUI version:&nbsp<span id="current-version">{cfg.GUI_VERSION}</span><span style="display: none" id="update-available"><a>+</a></span></div>
<div style="display: flex;flex-direction: row;">GUI version:&nbsp<span id="current-version">{os.environ['GUI_VERSION'] if FROZEN else 'main'}</span><span style="display: none" id="update-available"><a>+</a></span></div>
<div>Model version: {cfg.MODEL_VERSION}</div>
</div>
<div>K. Lisa Yang Center for Conservation Bioacoustics<br>Chemnitz University of Technology</div>
Expand Down Expand Up @@ -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]
Expand Down
74 changes: 39 additions & 35 deletions gui/gui.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down

0 comments on commit 6154906

Please sign in to comment.