Skip to content

Commit

Permalink
testing combo of location and notcturnal birdds
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattk70 committed Feb 9, 2024
1 parent a975eae commit 6ea5b23
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
25 changes: 25 additions & 0 deletions js/listWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,35 @@ class Model {
}
} else {
// BirdNET nocturnal bird filter
const additionalIDs = [];
for (let i = 0; i < this.labels.length; i++) {
const item = this.labels[i];
if (ACTIVITY_INDEX[item] !== 1 && BIRDNET_NOT_BIRDS.indexOf(item) < 0) includedIDs.push(i);
}
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();
for (let i = 0; i < mdata_probs.length; i++) {
const index = i; // mdata_probs.indexOf(mdata_probs_sorted[i]);
if (mdata_probs[index] < threshold) {
DEBUG && console.log('Excluding:', this.mdata_labels[index] + ': ' + mdata_probs[index]);
} else {
const latin = this.mdata_labels[index].split('_')[0];
// Use the reduce() method to accumulate the indices of species containing the latin name
const foundIndices = this.labels.reduce((indices, element, index) => {
element.includes(latin) && indices.push(index);
return indices;
}, []);
foundIndices.forEach(index => {
// If we want an override list...=>
//if (! ['Dotterel', 'Stone-curlew', 'Spotted Crake'].some(this.labels[index])) BLOCKED_IDS.push(index)
additionalIDs.push(index)
DEBUG && console.log('Including: ', index, 'name', this.labels[index], 'probability', mdata_probs[i].toFixed(3) )
})
}
}
includedIDs = includedIDs.filter(id => additionalIDs.includes(id));

}
} else {

Expand Down
6 changes: 3 additions & 3 deletions js/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3057,9 +3057,9 @@ const prepSummaryStatement = (included) => {
message: 'get-list',
model: STATE.model,
listType: STATE.list,
lat: lat,
lon: lon,
week: week,
lat: lat || STATE.lat,
lon: lon || STATE.lon,
week: week || STATE.week,
useWeek: STATE.useWeek,
threshold: STATE.speciesThreshold
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"bugs": {
"url": "https://github.com/mattk70/Chirpity-Electron/issues"
},
"homepage": "https://github.com/mattk70/Chirpity-Electron#readme",
"homepage": "https://chirpity.mattkirkland.co.uk",
"devDependencies": {
"@playwright/test": "^1.39.0",
"electron": "^27.1.3",
Expand Down

0 comments on commit 6ea5b23

Please sign in to comment.