Giter Site home page Giter Site logo

ethan-nelson / birdnetlib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joeweiss/birdnetlib

0.0 1.0 0.0 175.34 MB

A python api for BirdNET-Lite and BirdNET-Analyzer

License: GNU General Public License v3.0

Python 99.72% Dockerfile 0.28%

birdnetlib's Introduction

birdnetlib

PyPI Test

A python api for BirdNET-Analyzer and BirdNET-Lite

Installation

birdnetlib requires Python 3.7+ and prior installation of Tensorflow Lite, librosa and ffmpeg. See BirdNET-Analyzer for more details on installing the Tensorflow-related dependencies.

pip install birdnetlib

Documentation

birdnetlib provides a common interface for BirdNET-Analyzer and BirdNET-Lite.

Using BirdNET-Analyzer

To use the newer BirdNET-Analyzer model, use the Analyzer class.

from birdnetlib import Recording
from birdnetlib.analyzer import Analyzer
from datetime import datetime

# Load and initialize the BirdNET-Analyzer models.
analyzer = Analyzer()

recording = Recording(
    analyzer,
    "sample.mp3",
    lat=35.4244,
    lon=-120.7463,
    date=datetime(year=2022, month=5, day=10), # use date or week_48
    min_conf=0.25,
)
recording.analyze()
print(recording.detections)

Using BirdNET-Lite

To use the BirdNET-Lite model, use the LiteAnalyzer class.

from birdnetlib import Recording
from birdnetlib.analyzer_lite import LiteAnalyzer
from datetime import datetime

# Load and initialize the BirdNET-Lite models.
analyzer = LiteAnalyzer()

recording = Recording(
    analyzer,
    "sample.mp3",
    lat=35.4244,
    lon=-120.7463,
    date=datetime(year=2022, month=5, day=10), # use date or week_48
    min_conf=0.25,
)
recording.analyze()
print(recording.detections) # Returns list of detections.

recording.detections contains a list of detected species, along with time ranges and confidence value.

[{'common_name': 'House Finch',
  'confidence': 0.5744,
  'end_time': 12.0,
  'scientific_name': 'Haemorhous mexicanus',
  'start_time': 9.0},
 {'common_name': 'House Finch',
  'confidence': 0.4496,
  'end_time': 15.0,
  'scientific_name': 'Haemorhous mexicanus',
  'start_time': 12.0}]

Utility classes

DirectoryAnalyzer

DirectoryAnalyzer can process a directory and analyze contained files.

def on_analyze_complete(recording):
    print(recording.path)
    pprint(recording.detections)

directory = DirectoryAnalyzer(
    "/Birds/mp3_dir",
    patterns=["*.mp3", "*.wav"]
)
directory.on_analyze_complete = on_analyze_complete
directory.process()

See the full example for analyzer options and error handling callbacks.

DirectoryWatcher

DirectoryWatcher can watch a directory and analyze new files as they are created.

def on_analyze_complete(recording):
    print(recording.path)
    pprint(recording.detections)

watcher = DirectoryWatcher("/Birds/mp3_dir")
watcher.on_analyze_complete = on_analyze_complete
watcher.watch()

See the full example for analyzer options and error handling callbacks.

SpeciesList

SpeciesList uses BirdNET-Analyzer to predict species lists from location and date.

species = SpeciesList()
species_list = species.return_list(
    lon=-120.7463, lat=35.4244, date=datetime(year=2022, month=5, day=10)
)
print(species_list)
# [{'scientific_name': 'Haemorhous mexicanus', 'common_name': 'House Finch', 'threshold': 0.8916686}, ...]

Additional examples

About BirdNET-Lite and BirdNET-Analyzer

birdnetlib uses models provided by BirdNET-Lite and BirdNET-Analyzer under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License.

BirdNET-Lite and BirdNET-Analyzer were developed by the K. Lisa Yang Center for Conservation Bioacoustics at the Cornell Lab of Ornithology.

For more information on BirdNET analyzers, please see the project repositories below:

BirdNET-Analyzer

BirdNET-Lite

birdnetlib is not associated with BirdNET-Lite, BirdNET-Analyzer or the K. Lisa Yang Center for Conservation Bioacoustics.

About birdnetlib

birdnetlib is maintained by Joe Weiss. Contributions are welcome.

Project Goals

  • Establish a unified API for interacting with Tensorflow-based BirdNET analyzers
  • Enable python-based test cases for BirdNET analyzers
  • Make it easier to use BirdNET in python-based projects
  • Make it easier to migrate to new BirdNET versions/models as they become available

birdnetlib's People

Contributors

joeweiss avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.