Skip to main content

A bird species classifier

Project description

NABirds Species Classifier

Binocular

This project provides a pretrained, species-level bird classifier for North American birds, built on the NABirds dataset. It uses a powerful DINOv2 Vision Transformer (ViT) backbone with a linear probe, allowing for accurate and efficient classification.

The model can be easily loaded and used for inference directly from the Hugging Face Hub.

Quick Start: Inference with a Pretrained Model

Get predictions from the pretrained model in just a few lines of code.

1. Setup

First, set up the environment and install the required dependencies.

# Clone the repository
git clone https://github.com/jiujiuche/Binocular.git
cd Binocular

# Create a virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

2. Run Inference

Use the example script to run inference on an image of your choice. The script will automatically download the pretrained model from the Hugging Face Hub.

python Binocular/examples/huggingface_inference.py \
    --repo-id "jiujiuche/Binocular" \
    --image "path/to/your/bird_image.jpg"

The output will be a list of the top 5 predicted bird species and their confidence scores.

Training (Optional)

This repository also contains the full pipeline for training the model from scratch.

Dataset Setup

  1. Download the NABirds dataset from https://dl.allaboutbirds.org/nabirds.
  2. Extract the dataset files into the Binocular/datasets/nabirds/ directory.

Training Command

The training process is managed through a main script that uses configuration files to define the training parameters.

# Example for training on an M2 Mac
python Binocular/scripts/train.py --config Binocular/configs/m2_dev.yaml

# Example for training on a CUDA-enabled GPU
python Binocular/scripts/train.py --config Binocular/configs/rtx4090.yaml

Training configurations can be found in the Binocular/configs/ directory.

Project Structure

Binocular/
├── assets/           # Project icons
├── datasets/         # Data loaders and dataset files
├── models/           # Model implementations and inference logic
├── configs/          # Configuration files for experiments
├── scripts/          # Training, evaluation, and utility scripts
└── examples/         # Example scripts for using the models

Dependencies

  • PyTorch
  • torchvision
  • huggingface-hub
  • Pillow, tqdm, numpy, etc.

See requirements.txt for the complete list.

License

The code in this repository is provided under the MIT License. The NABirds dataset has its own license terms, which should be reviewed before use.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

binocular_birds-0.1.0.tar.gz (35.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

binocular_birds-0.1.0-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

Details for the file binocular_birds-0.1.0.tar.gz.

File metadata

  • Download URL: binocular_birds-0.1.0.tar.gz
  • Upload date:
  • Size: 35.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.19

File hashes

Hashes for binocular_birds-0.1.0.tar.gz
Algorithm Hash digest
SHA256 73a55fb07c7d4bb8658099c50b0f63641f208e36f9414df7d11b9f0ad5add0ec
MD5 11302183ed50381bd96e0739fdad1024
BLAKE2b-256 a33c764a9eac40d31063493e236846b76722cb0c64516694e8805ac85971e306

See more details on using hashes here.

File details

Details for the file binocular_birds-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for binocular_birds-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0da7a6a6c666499bcc24a8cd59145adebfaf2175454e5d87c41bc1ab10655a98
MD5 35b82e51c95f731de0c00296fa53eaf8
BLAKE2b-256 4b66ab069105d8359f18c95f26192255627352f27a93a2ccec1988520432fa42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page