Detecting Pigeons in Images using Machine Learning:
The application uses environment variables for configuration. Create a .env file in the project root:
cp .env.example .envThen edit .env with your settings. See .env.example for all available options.
PGUARD_MODEL_DIR: Folder path in which models are stored locallyPGUARD_MODEL_FILE: File name of the model to use (if it does not exist locally, it will be downloaded from the model releases)PGUARD_STREAM_URL: URL of the video streamPGUARD_CONFIDENCE_THRESHOLD: Detection confidence threshold (0.0-1.0)PGUARD_PUSHOVER_ENABLED: Enable/disable Pushover notificationsPGUARD_PUSHOVER_USER_KEY: Your Pushover user keyPGUARD_PUSHOVER_API_TOKEN: Your Pushover API token- See
.env.examplefor complete list
Prerequisites:
Detection on local image
docker run --rm \
--device /dev/hailo0:/dev/hailo0 \
-v $(pwd)/.env.hailo:/app/.env \
-v $(pwd)/models:/app/models \
-v $(pwd)/data:/data \
ghcr.io/pigeon-guard/app:latest-slim --image /data/test-image.jpg
Detection on local video file
docker run --rm \
--device /dev/hailo0:/dev/hailo0 \
-v $(pwd)/.env.hailo:/app/.env \
-v $(pwd)/models:/app/models \
-v $(pwd)/data:/data \
ghcr.io/pigeon-guard/app:latest-slim --video /data/test-video.mp4 [--video-save /data/test-video-output.mp4]
Continuous detection in video stream over the network
docker run -d --restart always --name pguard \
--device /dev/hailo0:/dev/hailo0 \
-v $(pwd)/.env.hailo:/app/.env \
-v $(pwd)/models:/app/models \
-v $(pwd)/detections:/app/detections \
-v $(pwd)/logs:/app/logs \
ghcr.io/pigeon-guard/app:latest-slim
Detection on local image
docker run --rm \
-v $(pwd)/.env:/app/.env \
-v $(pwd)/models:/app/models \
-v $HOME/Downloads:/data \
ghcr.io/pigeon-guard/app:latest --image /data/test-image.jpg
Detection on local video file
docker run --rm \
-v $(pwd)/.env:/app/.env \
-v $(pwd)/models:/app/models \
-v $HOME/Downloads:/data \
ghcr.io/pigeon-guard/app:latest --video /data/test-video.mp4 [--video-save /data/test-video-output.mp4]
Continuous detection in video stream over the network
docker run -d --restart always --name pguard \
-v $(pwd)/.env:/app/.env \
-v $(pwd)/models:/app/models \
-v $(pwd)/detections:/app/detections \
-v $(pwd)/logs:/app/logs \
ghcr.io/pigeon-guard/app:latest
Detection on single image
./app.sh --image <path>Continuous detection in interactive mode
./app.shCustom environment file
./app.sh --env-file .env.productionRun the unit tests:
source .venv/bin/activate
python3 -m unittest discover testsRun tests with verbose output:
python3 -m unittest discover -v testsRun a specific test file:
python3 -m unittest tests.test_event_busThe project includes comprehensive unit tests for:
- Event bus system
- Event handlers (detection and notification)
- Video stream observer
- Pushover notifier
Tests use mocks for external dependencies (cv2, requests, file I/O) and are fully automated via GitHub Actions.
See tests/README.md for more details.
