diff --git a/Help/settings.html b/Help/settings.html index b9c61af8..b267bead 100644 --- a/Help/settings.html +++ b/Help/settings.html @@ -30,7 +30,8 @@
Migrants and Owls. Just report detections relating to these species' calls (song detections are +
Birds in your Region. Exclude birds unlikely to be found in your location.
+Nocturnal Birds. Just report detections relating to these species' calls (song detections are excluded).
All birds. Include birdsong as well as calls, also includes species not known to call at night.
diff --git a/js/BirdNet2.4.js b/js/BirdNet2.4.js index d0a822f5..e158c238 100644 --- a/js/BirdNet2.4.js +++ b/js/BirdNet2.4.js @@ -1,7 +1,7 @@ const tf = require('@tensorflow/tfjs-node'); const fs = require('node:fs'); const path = require('node:path'); -let DEBUG = false; +let DEBUG = true; let BACKEND; //GLOBALS @@ -135,7 +135,7 @@ break; if (DEBUG) { console.log(`Setting list to ${myModel.list}`); } -myModel.setList(); +await myModel.setList(); postMessage({ message: "update-list", blocked: BLOCKED_IDS, @@ -178,7 +178,9 @@ class Model { { weightPathPrefix: this.appPath }); this.model_loaded = true; this.inputShape = [...this.model.inputs[0].shape]; - this.metadata_model = await tf.loadGraphModel(path.join(this.appPath, 'mdata', 'model.json')); + const mdata_model_path = this.appPath + 'mdata/model.json' + this.metadata_model = await tf.loadGraphModel(mdata_model_path, + ); await this.setList(); } } @@ -211,16 +213,15 @@ class Model { 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(); - console.log('Most common species @ (' + lat + '/' + lon + ') in week ' + week + ':'); let count = 0 - for (let i = 0; i < mdata_probs_sorted.length; i++) { - const index = mdata_probs.indexOf(mdata_probs_sorted[i]); - if (mdata_probs_sorted[i] > 0.004) { + for (let i = 0; i < mdata_probs.length; i++) { + if (mdata_probs[i] > 0.004) { count++; - console.log(this.labels[index] + ': ' + mdata_probs_sorted[i]); + DEBUG && console.log("including:", this.labels[i] + ': ' + mdata_probs[i]); } else { - // Hack to add Dotterel - if (! this.labels[index].includes('Dotterel')) BLOCKED_IDS.push(index) + DEBUG && console.log("Excluding:", this.labels[i] + ': ' + mdata_probs[i]); + // Hack to add Dotterel?? + if (! this.labels[i].includes('Dotterel')) BLOCKED_IDS.push(i) } } console.log('Total species considered at this location: ', count) diff --git a/js/model.js b/js/model.js index a8326bd3..e3936684 100644 --- a/js/model.js +++ b/js/model.js @@ -179,10 +179,11 @@ class Model { this.model_loaded = true; this.inputShape = [...this.model.inputs[0].shape]; - this.metadata_model = await tf.loadGraphModel(path.join( - this.appPath, '..', 'BirdNET_GLOBAL_6K_V2.4_Model_TFJS', 'static', 'model', 'mdata', 'model.json' - )); - this.mdata_labels = JSON.parse(fs.readFileSync(path.join(__dirname, `..`, 'BirdNET_GLOBAL_6K_V2.4_Model_TFJS', 'static', 'model', 'labels.json'), "utf8")); + this.metadata_model = await tf.loadGraphModel( + this.appPath + '../BirdNET_GLOBAL_6K_V2.4_Model_TFJS/static/model/mdata/model.json' + ); + const mdata_label_path = path.join(__dirname, '..','BirdNET_GLOBAL_6K_V2.4_Model_TFJS','static','model','labels.json') + this.mdata_labels = JSON.parse(fs.readFileSync(mdata_label_path, "utf8")); await this.setList(); } }