joeweiss / birdnetlib

A python api for BirdNET-Lite and BirdNET-Analyzer
https://joeweiss.github.io/birdnetlib/
Apache License 2.0
40 stars 13 forks source link

Add ability to annotate detections if species is expected #106

Closed joeweiss closed 7 months ago

joeweiss commented 7 months ago

When providing the lat/long and datetime, Analyzer filters results by an BirdNET determined expected species list. This filters out all non-bird sounds like engine, coyote, frogs, etc.

It would be helpful to have a detection return with a "in_species_list" boolean or something similar, rather then filter out non-avian sounds entirely.

Perhaps it should also include the occurrence frequency value that's output by BirdNET's species.py function.

[{'common_name': 'House Finch',
  'confidence': 0.5744,
  'end_time': 12.0,
  'in_species_list': true,
  'in_species_list_freq': 0.10,
  'scientific_name': 'Haemorhous mexicanus',
  'start_time': 9.0,
  'label': 'Haemorhous mexicanus_House Finch'},
 {'common_name': 'Coyote',
  'confidence': 0.4496,
  'end_time': 9.0,
  'in_species_list': false,
  'in_species_list_freq': null,
  'scientific_name': 'Canis latrans',
  'start_time': 6.0,
  'label': 'Coyote_Coyote'}
 {'common_name': 'House Finch',
  'confidence': 0.4496,
  'end_time': 15.0,
  'in_species_list': true,
  'in_species_list_freq': 0.40,
  'scientific_name': 'Haemorhous mexicanus',
  'start_time': 12.0,
  'label': 'Haemorhous mexicanus_House Finch'}]
joeweiss commented 7 months ago

Other options for the property name.

on_location_species_list, on_location_species_list_freq expected_location_species, expected_location_species_freq predicted_location_species, predicted_location_species_freq in_predicted_list, in_predicted_list_frequency predicted_list_inclusion, predicted_list_inclusion_freq, predicted_list_species, predicted_list_species_freq predicted_location_species, predicted_location_species_freq predicted_species_for_location, predicted_species_for_location_freq predicted_species, predicted_species_freq

joeweiss commented 7 months ago

On second thought, the occurrence frequency is not needed for this issue.

joeweiss commented 7 months ago

Current working example, is_predicted_for_location_and_date, which is very verbose, but perhaps necessary.

 {'common_name': 'Engine',
  'confidence': 0.516838550567627,
  'end_time': 114.0,
  'is_predicted_for_location_and_date': False,
  'label': 'Engine_Engine',
  'scientific_name': 'Engine',
  'start_time': 111.0},
 {'common_name': 'American Goldfinch',
  'confidence': 0.39239490032196045,
  'end_time': 120.0,
  'is_predicted_for_location_and_date': True,
  'label': 'Spinus tristis_American Goldfinch',
  'scientific_name': 'Spinus tristis',
  'start_time': 117.0}]
joeweiss commented 7 months ago

Implemented in #107, see api docs for more info.