BirdFSD-YOLOv5
Build and train a custom model to identify birds visiting bird feeders.
π Documentation
Requirements
- π python>=3.8
π Getting started
Fork and clone this repository
- First, fork the repository.
- Enable workflows in your fork:
- Then, click on and enable all the workflows that are highlighted wuth a red square in the image below:
- Clone the repository:
git clone https://github.com/bird-feeder/BirdFSD-YOLOv5.git
cd BirdFSD-YOLOv5
git clone https://github.com/ultralytics/yolov5.git
Install dependencies
- If you're on an Apple silicon device (Apple M1), follow the instructions here. Otherwise, run:
pip install -r requirements.txt
Instructions for Apple M1 users
Click here
# Skip this if you're not on an Apple silicon device!
# If you don't have conda, install it:
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh"
bash "Miniforge3-MacOSX-arm64.sh" -b
rm "Miniforge3-MacOSX-arm64.sh"
conda init zsh
source ~/.zshrc
conda activate
# Then, run:
yes | pip uninstall grpcio
conda install grpcio --yes
pip install -r requirements.txt
Build the package
poetry build
pip install .
π± Environment Variables
- rename
.env.example
to.env
, then edit the values based on the table below.
mv .env.example .env
nano .env # or with any other editor
# See the table for details about the environment variables.
Name | Value |
---|---|
TOKEN | Label-Studio Access Token . |
LS_HOST | The URL of the label-studio app (e.g., https://label-studio.example.com) β make sure you include https:// in the URL. |
DB_CONNECTION_STRING | MongoDB connection string (e.g., mongodb://mongodb0.example.com:27017 ). See this article for details. |
DB_NAME | Name of the main MongoDB database (default: label_studio ). |
S3_ACCESS_KEY | (Optional) The S3 bucket's Access Key ID . |
S3_SECRET_KEY | (Optional) The S3 bucket's Secret Key . |
S3_REGION | (Optional) The S3 bucket's region (default: us-east-1 ). |
S3_ENDPOINT | (Optional) The S3 bucket's endpoint/URL server. |
EXCLUDE_LABELS | (Optional) Comma-separated list of labels to exclude from processing (e.g., label a,label b). |
- When you're done editing the
.env
file, run:
python birdfsd_yolov5/model_utils/check_env_file.py --env-file .env
ποΈ Setup
- To use the GitHub Actions workflows (recommended!), you will need to add every environment variable and its value from
.env
to theSecrets
of your fork (you can findSecrets
underSettings
).
π§ Dataset preparation
-
Option 1: Run the
JSON to YOLOv5 (data preprocessing)
workflow under githubActions
. -
Option 2: Run it locally with:
python birdfsd_yolov5/preprocessing/json2yolov5.py mv dataset-YOLO/dataset_config.yml . python birdfsd_yolov5/model_utils/relative_to_abs.py
1
β‘ TrainingUse the Colab notebook:
π Prediction
π³ Using Docker
docker pull alyetama/birdfsd-yolov5:latest
Example Usage
docker run -it --env-file .env alyetama/birdfsd-yolov5 python birdfsd_yolov5/preprocessing/json2yolov5.py