File size: 9,311 Bytes
0d156c1
 
157b856
0d156c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80b5750
0d156c1
 
 
 
 
 
 
 
 
 
80b5750
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
---
language: de
license: apache-2.0
tags:
- image-classification
- birds
- german-birds
- computer-vision
- efficientnet
- wildlife
datasets:
- custom
metrics:
- accuracy
- f1
model-index:
- name: german-bird-classifier-v2
  results:
  - task:
      type: image-classification
      name: Image Classification
    dataset:
      name: German Garden Birds
      type: custom
    metrics:
    - type: accuracy
      value: 0.9971
      name: Accuracy
    - type: f1
      value: 0.997
      name: Macro F1-Score
---

# German Bird Classifier v2 🐦

**High-accuracy German garden bird species classifier based on EfficientNet-B2.**

This is **version 2** of the German bird classifier with significantly improved performance:
-**99.71% accuracy** (vs. 87.69% in v1)
-**42× fewer errors** (3 vs. 128 misclassifications)
-**Perfect classification** for 5 out of 8 species

## Model Description

This model classifies 8 common German garden bird species from images. It was trained using the [vogel-model-trainer](https://github.com/kamera-linux/vogel-model-trainer) toolkit on 4,160 training images extracted from real-world bird feeder camera footage.

**Architecture:** EfficientNet-B2  
**Framework:** PyTorch + Hugging Face Transformers  
**Input:** RGB images (224×224)  
**Output:** 8 species classes with confidence scores

## Supported Species

1. **Blaumeise** (Blue Tit) - *Cyanistes caeruleus*
2. **Grünling** (European Greenfinch) - *Chloris chloris*
3. **Haussperling** (House Sparrow) - *Passer domesticus*
4. **Kernbeißer** (Hawfinch) - *Coccothraustes coccothraustes*
5. **Kleiber** (Eurasian Nuthatch) - *Sitta europaea*
6. **Kohlmeise** (Great Tit) - *Parus major*
7. **Rotkehlchen** (European Robin) - *Erithacus rubecula*
8. **Sumpfmeise** (Marsh Tit) - *Poecile palustris*

## Performance

### Overall Metrics (Validation Set: 1,040 images)

| Metric | Value |
|--------|-------|
| **Accuracy** | **99.71%** |
| **Macro F1-Score** | **99.7%** |
| **Weighted F1-Score** | **99.7%** |
| **Correct Classifications** | 1,037 / 1,040 |
| **Misclassifications** | 3 |

### Per-Species Performance

| Species | Precision | Recall | F1-Score | Samples |
|---------|-----------|--------|----------|---------|
| Blaumeise | 98.5% | 100.0% | 99.2% | 130 |
| Grünling | 100.0% | 100.0% | **100.0%** | 130 |
| Haussperling | 100.0% | 100.0% | **100.0%** | 130 |
| Kernbeißer | 100.0% | 100.0% | **100.0%** | 130 |
| Kleiber | 100.0% | 100.0% | **100.0%** | 130 |
| Kohlmeise | 99.2% | 99.2% | 99.2% | 130 |
| Rotkehlchen | 100.0% | 99.2% | 99.6% | 130 |
| Sumpfmeise | 100.0% | 99.2% | 99.6% | 130 |

**5 out of 8 species achieve perfect 100% F1-score!**

### Comparison to v1

| Metric | v1 | v2 | Improvement |
|--------|----|----|-------------|
| **Overall Accuracy** | 87.69% | **99.71%** | **+12.0pp** |
| **Macro F1-Score** | 87.3% | **99.7%** | **+12.4pp** |
| **Misclassifications** | 128 | **3** | **-97.7%** |
| **Error Rate Reduction** | - | - | **42.7×** |

**Biggest improvements:**
- 🎯 **Grünling:** 58.7% → 100.0% F1 (+41.3pp)
- 🎯 **Haussperling:** 72.0% → 100.0% F1 (+28.0pp)
- 🎯 **Rotkehlchen:** 89.5% → 99.6% F1 (+10.1pp)

## Usage

### Quick Start

```python
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import torch

# Load model and processor
model_name = "kamera-linux/german-bird-classifier-v2"
processor = AutoImageProcessor.from_pretrained(model_name)
model = AutoModelForImageClassification.from_pretrained(model_name)

# Load and preprocess image
image = Image.open("bird.jpg")
inputs = processor(images=image, return_tensors="pt")

# Predict
with torch.no_grad():
    outputs = model(**inputs)
    logits = outputs.logits
    predicted_class = logits.argmax(-1).item()
    confidence = torch.softmax(logits, dim=-1)[0][predicted_class].item()

# Get species name
species = model.config.id2label[predicted_class]
print(f"Species: {species} (Confidence: {confidence:.2%})")
```

### Using vogel-model-trainer CLI

```bash
# Install the toolkit
pip install vogel-model-trainer

# Classify images
vogel-trainer classify \
  --species-model kamera-linux/german-bird-classifier-v2 \
  ~/bird-photos/ \
  --sort-output ~/sorted/ \
  --min-confidence 0.90 \
  --csv-report results.csv

# Evaluate model performance
vogel-trainer evaluate \
  --species-model kamera-linux/german-bird-classifier-v2 \
  --test-dir ~/test-dataset/ \
  --export-json metrics.json
```

### Batch Processing

```python
from transformers import pipeline

# Create classifier pipeline
classifier = pipeline(
    "image-classification",
    model="kamera-linux/german-bird-classifier-v2",
    device=0  # GPU
)

# Classify multiple images
images = ["bird1.jpg", "bird2.jpg", "bird3.jpg"]
results = classifier(images, top_k=3)

for img, preds in zip(images, results):
    print(f"\n{img}:")
    for pred in preds:
        print(f"  {pred['label']}: {pred['score']:.2%}")
```

## Training Details

### Dataset

- **Training images:** 4,160 (520 per species)
- **Validation images:** 1,040 (130 per species)
- **Source:** Real-world bird feeder camera footage
- **Image size:** 224×224 pixels
- **Perfectly balanced:** Equal samples per class

### Training Configuration

```
Model: google/efficientnet-b2
Epochs: 50 (with early stopping)
Batch Size: 32
Learning Rate: 0.0001
Optimizer: AdamW
Scheduler: Cosine with warmup
Augmentation: Heavy
  - Random rotation
  - Random horizontal flip
  - Color jitter
  - Random brightness/contrast
Early Stopping Patience: 15 epochs
Hardware: NVIDIA RTX 2070 SUPER (8GB)
Training Time: ~35 minutes
Framework: PyTorch 2.9.1 + Transformers 4.57.1
```

### Data Processing

Images were extracted from videos using YOLOv8n bird detection:
1. **Detection:** Birds detected in video frames
2. **Extraction:** Cropped bird regions saved as images
3. **Deduplication:** Similar frames removed using perceptual hashing
4. **Organization:** Manual verification and species labeling
5. **Split:** 80% training, 20% validation

## Model Size & Performance

| Metric | Value |
|--------|-------|
| **Model Size** | 16 MB (safetensors) |
| **Parameters** | ~9.1M |
| **Inference Speed (GPU)** | ~100 images/sec |
| **Inference Speed (CPU)** | ~10 images/sec |
| **Memory Usage (GPU)** | ~300 MB |
| **Memory Usage (CPU)** | ~200 MB |

## Limitations & Bias

### Known Limitations

1. **Species Scope:** Only trained on 8 common German garden birds
2. **Tit Confusion:** Occasional confusion between similar tit species (Blaumeise, Kohlmeise, Sumpfmeise)
3. **Image Quality:** Best performance on clear, well-lit images
4. **Pose Dependency:** Trained primarily on frontal/side views from bird feeders
5. **Juvenile Birds:** May struggle with juvenile plumage variations
6. **Seasonal Variations:** Limited seasonal plumage data

### Potential Biases

- **Feeder Bias:** Trained on bird feeder footage, may not generalize to natural settings
- **Geographic Bias:** German garden birds, regional appearance variations may exist
- **Equipment Bias:** Optimized for similar camera setups and lighting conditions

### Error Analysis

The 3 misclassifications on validation set:
1. **Kohlmeise → Blaumeise** (91% confidence) - Similar coloring in poor lighting
2. **Rotkehlchen → Blaumeise** (23% confidence) - Low confidence, model uncertain
3. **Sumpfmeise → Kohlmeise** (76% confidence) - Very similar tit species

**Recommendation:** Use `--min-confidence 0.85` threshold to filter uncertain predictions.

## Intended Use

### Primary Use Cases**Automated bird feeder monitoring****Citizen science bird counting****Wildlife camera image classification****Educational bird identification apps****Biodiversity research**

### Out-of-Scope Uses

❌ Classifying non-German bird species  
❌ Identifying birds outside the 8 trained species  
❌ Medical/diagnostic applications  
❌ Legal evidence or regulatory decisions  
❌ Security/surveillance applications

## Citation

If you use this model in your research, please cite:

```bibtex
@misc{german-bird-classifier-v2,
  title={German Bird Classifier v2: High-Accuracy Garden Bird Species Classification},
  author={kamera-linux},
  year={2025},
  publisher={Hugging Face},
  url={https://huggingface.co/kamera-linux/german-bird-classifier-v2}
}
```

## Related Resources

- **Training Toolkit:** [vogel-model-trainer](https://github.com/kamera-linux/vogel-model-trainer)
- **PyPI Package:** [vogel-model-trainer](https://pypi.org/project/vogel-model-trainer/)
- **v1 Model (deprecated):** [german-bird-classifier](https://huggingface.co/kamera-linux/german-bird-classifier)
- **Documentation:** [GitHub README](https://github.com/kamera-linux/vogel-model-trainer/blob/main/README.md)

## License

This model is released under the **Apache License 2.0**. See the [LICENSE](https://huggingface.co/kamera-linux/german-bird-classifier-v2/blob/main/LICENSE) file for details.

## Acknowledgments

- **Ultralytics** for YOLOv8 bird detection
- **Hugging Face** for Transformers library and model hosting
- **PyTorch Team** for the deep learning framework
- **Google** for EfficientNet architecture

---

**Trained with ❤️ using [vogel-model-trainer](https://github.com/kamera-linux/vogel-model-trainer)**