Skip to content

Commit

Permalink
Added:
Browse files Browse the repository at this point in the history
 eBird frequency setting for location filter
 Species list display in help
Help option for bug reports and suggestions
Refactored results filtering
  • Loading branch information
Mattk70 committed Jan 25, 2024
1 parent 21af18f commit 53a46ad
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 74 deletions.
19 changes: 19 additions & 0 deletions Help/bugs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bug Reports</title>
</head>
<body>

<h4>Have you hit on a problem, or perhaps you have a suggestion?</h4>

If you have, then I'd be happy to hear about it. I keep track of <a href="https://github.com/Mattk70/Chirpity-Electron/issues" target="_blank">issues and suggestions on Github</a>.

<p>Take a look at what others have been reporting, if you think you have a similar problem or suggestion, add a comment to the thread.</p>

<p> If, on the other hand, you think you've got something new, go on and add an issue - I'll get back to you as soon as I can. </p>
I can't promise I'll make everything right, but I probably won't fix what I don't know about &#x00AF;\\_(ツ)_/&#x00AF; </p><p>Meanwhile, I hope you find Chirpity useful!</p>

</body>
</html>
4 changes: 4 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ footer {
max-width: 70px;
}

#speciesModal {
max-height: 90%;
}

/* Flip comment icons */

.flipped {
Expand Down
28 changes: 23 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ <h5>Saved Records</h5>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" id="navbarSettings" onclick="placeMap('settingsMap')"
data-bs-toggle="dropdown">Settings</a>
data-bs-toggle="dropdown" data-bs-auto-close="false">Settings</a>
<ul id="settingsMenu" class="nav-item dropdown-menu">
<li>
<form id="settingsForm" class="fs-6">
Expand All @@ -243,7 +243,7 @@ <h5>Saved Records</h5>
<div class="form-group rounded p-2 mb-2 bg-light"><span
class="circle"
title="Determines the minimum confidence required for results to be returned">?</span>
<label for="confidence">Set threshold:</label>
<label for="confidence">Set confidence threshold:</label>
<div class="input-group">
<input type="range" class="form-control-range"
id="confidence" min="5" max="100" step="5">
Expand All @@ -258,7 +258,7 @@ <h5>Saved Records</h5>
<span class="circle"
title="Filters the detections returned in results.">?</span>
<div class="row pe-3">
<label class="col-auto ps-0" for="list-to-use">Show:</label>
<label class="col-auto ps-0" for="list-to-use">List:</label>
<select class="form-select col" id="list-to-use">
<option value="location">Local Birds</option>
<option value="migrants">Nocturnal Birds</option>
Expand All @@ -267,6 +267,18 @@ <h5>Saved Records</h5>
</select>
</div>
</div>
<div class="form-group rounded p-2 mb-2 bg-light" id="species-threshold-el">
<div class="row">
<div class="input-group col">
<span class="input-group-text pe-2">Threshold:</span>
<input id="species-frequency-threshold" type="number"
class="form-control ps-2 rounded-3 w-25" value="0.005" step="0.001" min="0.001" max="1"
aria-label="species frequency threshold" aria-describedby="species-frequency-threshold">
<span class="circle"
title="Set the minimum eBird checklist frequency for a bird to be included">?</span>
</div>
</div>
</div>
<div class="form-group rounded p-2 mb-2 bg-light">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox"
Expand Down Expand Up @@ -658,6 +670,12 @@ <h5>Saved Records</h5>
<span class="material-symbols-outlined">tour</span> Show Tour
</a>
</li>
<div class="dropdown-divider"></div>
<li>
<a class="dropdown-item" id="bugs" href="#">
<span class="material-symbols-outlined">bug_report</span> Issues, queries or bugs?
</a>
</li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -758,10 +776,10 @@ <h5 class="modal-title" id="helpModalLabel">Help</h5>
</div>
<!-- Species Modal -->
<div class="modal fade" id="speciesModal" tabindex="-1" aria-labelledby="speciesModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="modal-dialog modal-dialog-centered ">
<div class="modal-content">
<div class="modal-header justify-content-center">
<h5 class="modal-title" id="speciesModalLabel">Detected Species</h5>
<h5 class="modal-title" id="speciesModalLabel">Current Species List</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div id="speciesModalBody" class="modal-body"></div>
Expand Down
15 changes: 9 additions & 6 deletions js/BirdNet2.4.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ onmessage = async (e) => {
myModel.lat = parseFloat(e.data.lat);
myModel.lon = parseFloat(e.data.lon);
myModel.week = parseInt(e.data.week);
myModel.speciesThreshold = parseFloat(e.data.threshold);
await myModel.loadModel();
postMessage({
message: "update-list",
Expand Down Expand Up @@ -137,6 +138,7 @@ onmessage = async (e) => {
myModel.lat = parseFloat(e.data.lat);
myModel.lon = parseFloat(e.data.lon);
myModel.week = parseInt(e.data.week) || myModel.week;
myModel.speciesThreshold = parseFloat(e.data.threshold);
DEBUG && console.log(`Setting list to ${myModel.list}`);
await myModel.setList();
postMessage({
Expand Down Expand Up @@ -208,26 +210,27 @@ class Model {
BLOCKED_IDS = [];
if (this.list === "everything") return
// Dummy location and week
const lat = myModel.lat;
const lon = myModel.lon;
const week = myModel.week;
const lat = this.lat;
const lon = this.lon;
const week = this.week;
console.log('lat', lat, 'lon', lon, 'week', week)
this.mdata_input = tf.tensor([lat, lon, week]).expandDims(0);
const mdata_prediction = this.metadata_model.predict(this.mdata_input);
const mdata_probs = await mdata_prediction.data();
const mdata_probs_sorted = mdata_probs.slice().sort().reverse();
let count = 0
for (let i = 0; i < mdata_probs.length; i++) {
if (mdata_probs[i] > 0.004) {
if (mdata_probs[i] > this.speciesThreshold) {
count++;
DEBUG && console.log("including:", this.labels[i] + ': ' + mdata_probs[i]);
} else {
DEBUG && console.log("Excluding:", this.labels[i] + ': ' + mdata_probs[i]);
// Hack to add Dotterel??
if (! this.labels[i].includes('Dotterel')) BLOCKED_IDS.push(i)
//if (! this.labels[i].includes('Dotterel'))
BLOCKED_IDS.push(i)
}
}
console.log('Total species considered at this location: ', count)
//console.log('Total species considered at this location: ', count)
// get the indices of any items in the blacklist, GRAYLIST
// if (this.list === 'birds') {
// // find the position of the blocked items in the label list
Expand Down
16 changes: 11 additions & 5 deletions js/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ tf.setBackend(backend).then(async () => {
myModel = new Model(appPath, list, version);
myModel.height = height;
myModel.width = width;
myModel.list = e.data.list;
myModel.lat = parseFloat(e.data.lat);
myModel.lon = parseFloat(e.data.lon);
myModel.week = parseInt(e.data.week);
myModel.week = parseInt(e.data.week) || myModel.week;
myModel.speciesThreshold = parseFloat(e.data.threshold);
myModel.labels = labels;
await myModel.loadModel();
postMessage({
Expand Down Expand Up @@ -133,6 +135,10 @@ break;
}
case "list": {
myModel.list = e.data.list;
myModel.lat = parseFloat(e.data.lat);
myModel.lon = parseFloat(e.data.lon);
myModel.week = parseInt(e.data.week) || myModel.week;
myModel.speciesThreshold = parseFloat(e.data.threshold);
if (DEBUG) {
console.log(`Setting list to ${myModel.list}`);
}
Expand Down Expand Up @@ -204,9 +210,9 @@ class Model {
async setList() {
BLOCKED_IDS = [];
if (this.list === "location") {
const lat = myModel.lat;
const lon = myModel.lon;
const week = myModel.week;
const lat = this.lat;
const lon = this.lon;
const week = this.week;
this.mdata_input = tf.tensor([lat, lon, week]).expandDims(0);
const mdata_prediction = this.metadata_model.predict(this.mdata_input);
const mdata_probs = await mdata_prediction.data();
Expand All @@ -215,7 +221,7 @@ class Model {
let count = 0
for (let i = 0; i < mdata_probs.length; i++) {
const index = i; // mdata_probs.indexOf(mdata_probs_sorted[i]);
if (mdata_probs[index] > 0.004) {
if (mdata_probs[index] > this.speciesThreshold) {
count++
DEBUG && console.log('Including:', this.mdata_labels[index] + ': ' + mdata_probs[index]);
} else {
Expand Down
3 changes: 2 additions & 1 deletion js/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export class State {
this.GET_RESULT_SQL = undefined,
this.lat = undefined,
this.lon = undefined,
this.locationID = undefined
this.locationID = undefined,
this.speciesThreshold = undefined
}


Expand Down
Loading

0 comments on commit 53a46ad

Please sign in to comment.