File size: 2,262 Bytes
76436f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
license: gpl-3.0
tags:
  - bird-classification
  - onnx
  - efficientnet
  - raspberry-pi
  - hailo
  - computer-vision
  - real-time
datasets:
  - duyminhle/nabirds
model-index:
  - name: EfficientNet-B7 Backyard Feeder Bird Classifier
    results: []
---

# 🐦 EfficientNet-B7 β€” Backyard Feeder Bird Classifier

Custom ONNX-based bird classification model trained on a filtered subset of the [NABirds dataset](https://dl.allaboutbirds.org/nabirds), optimized for backyard bird feeders.

> Designed to run on a Raspberry Pi + Hailo-8 setup in real-time as part of the [Birdwatcher Project](https://github.com/n2b8/birdwatcher)

---

## 🧠 Model Details

- Architecture: EfficientNet-B7
- Resolution: `600Γ—600`
- Precision: Mixed (AMP)
- Format: ONNX
- Classes: 95 backyard species + `not_a_bird`
- Validation Accuracy: **93.14%** @ Epoch 23
- Optimized for inference on edge devices (e.g., Raspberry Pi 5 + Hailo-8)

---

## πŸ“ Files

- `efficientnet_b7_backyard_feeder_birds.onnx` β€” Trained ONNX model
- `class_labels_v3.txt` β€” One class label per line

---

## πŸ› οΈ Intended Use

- **Use Case:** Real-time fine-grained classification of birds visiting backyard feeders
- **Hardware:** Optimized for Raspberry Pi + Hailo-8 AI accelerator
- **Pipeline:** Captures images via YOLOv8 detection, then classifies via this model

---

## 🐍 Example Inference Code

```python
import onnxruntime as ort
import numpy as np
from PIL import Image

# Load model
session = ort.InferenceSession("efficientnet_b7_backyard_feeder_birds.onnx")

# Preprocess
img = Image.open("bird.jpg").resize((600, 600))
x = np.array(img).astype(np.float32) / 255.0
x = np.transpose(x, (2, 0, 1))[np.newaxis, :]  # CHW + batch

# Predict
outputs = session.run(None, {"input": x})
pred_idx = np.argmax(outputs[0])
```

---

## πŸ“Š Training

- Dataset: Subset of NABirds (filtered for common backyard species)
- Augmentations: Flip, rotation, brightness
- Regularization: Dropout, label smoothing
- Loss: Cross-entropy
- Optimizer: AdamW
- Early stopping enabled

---

## πŸ”— Related Repos

- [Birdwatcher Project (GitHub)](https://github.com/n2b8/birdwatcher)
- [NABirds Dataset (Kaggle)](https://www.kaggle.com/datasets/duyminhle/nabirds)

---

## πŸ“œ License

GPLv3