kamera-linux commited on
Commit
0d156c1
·
verified ·
1 Parent(s): 685d3f3

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: de
3
+ license: mit
4
+ tags:
5
+ - image-classification
6
+ - birds
7
+ - german-birds
8
+ - computer-vision
9
+ - efficientnet
10
+ - wildlife
11
+ datasets:
12
+ - custom
13
+ metrics:
14
+ - accuracy
15
+ - f1
16
+ model-index:
17
+ - name: german-bird-classifier-v2
18
+ results:
19
+ - task:
20
+ type: image-classification
21
+ name: Image Classification
22
+ dataset:
23
+ name: German Garden Birds
24
+ type: custom
25
+ metrics:
26
+ - type: accuracy
27
+ value: 0.9971
28
+ name: Accuracy
29
+ - type: f1
30
+ value: 0.997
31
+ name: Macro F1-Score
32
+ ---
33
+
34
+ # German Bird Classifier v2 🐦
35
+
36
+ **High-accuracy German garden bird species classifier based on EfficientNet-B2.**
37
+
38
+ This is **version 2** of the German bird classifier with significantly improved performance:
39
+ - ✅ **99.71% accuracy** (vs. 87.69% in v1)
40
+ - ✅ **42× fewer errors** (3 vs. 128 misclassifications)
41
+ - ✅ **Perfect classification** for 5 out of 8 species
42
+
43
+ ## Model Description
44
+
45
+ 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.
46
+
47
+ **Architecture:** EfficientNet-B2
48
+ **Framework:** PyTorch + Hugging Face Transformers
49
+ **Input:** RGB images (224×224)
50
+ **Output:** 8 species classes with confidence scores
51
+
52
+ ## Supported Species
53
+
54
+ 1. **Blaumeise** (Blue Tit) - *Cyanistes caeruleus*
55
+ 2. **Grünling** (European Greenfinch) - *Chloris chloris*
56
+ 3. **Haussperling** (House Sparrow) - *Passer domesticus*
57
+ 4. **Kernbeißer** (Hawfinch) - *Coccothraustes coccothraustes*
58
+ 5. **Kleiber** (Eurasian Nuthatch) - *Sitta europaea*
59
+ 6. **Kohlmeise** (Great Tit) - *Parus major*
60
+ 7. **Rotkehlchen** (European Robin) - *Erithacus rubecula*
61
+ 8. **Sumpfmeise** (Marsh Tit) - *Poecile palustris*
62
+
63
+ ## Performance
64
+
65
+ ### Overall Metrics (Validation Set: 1,040 images)
66
+
67
+ | Metric | Value |
68
+ |--------|-------|
69
+ | **Accuracy** | **99.71%** |
70
+ | **Macro F1-Score** | **99.7%** |
71
+ | **Weighted F1-Score** | **99.7%** |
72
+ | **Correct Classifications** | 1,037 / 1,040 |
73
+ | **Misclassifications** | 3 |
74
+
75
+ ### Per-Species Performance
76
+
77
+ | Species | Precision | Recall | F1-Score | Samples |
78
+ |---------|-----------|--------|----------|---------|
79
+ | Blaumeise | 98.5% | 100.0% | 99.2% | 130 |
80
+ | Grünling | 100.0% | 100.0% | **100.0%** | 130 |
81
+ | Haussperling | 100.0% | 100.0% | **100.0%** | 130 |
82
+ | Kernbeißer | 100.0% | 100.0% | **100.0%** | 130 |
83
+ | Kleiber | 100.0% | 100.0% | **100.0%** | 130 |
84
+ | Kohlmeise | 99.2% | 99.2% | 99.2% | 130 |
85
+ | Rotkehlchen | 100.0% | 99.2% | 99.6% | 130 |
86
+ | Sumpfmeise | 100.0% | 99.2% | 99.6% | 130 |
87
+
88
+ **5 out of 8 species achieve perfect 100% F1-score!**
89
+
90
+ ### Comparison to v1
91
+
92
+ | Metric | v1 | v2 | Improvement |
93
+ |--------|----|----|-------------|
94
+ | **Overall Accuracy** | 87.69% | **99.71%** | **+12.0pp** |
95
+ | **Macro F1-Score** | 87.3% | **99.7%** | **+12.4pp** |
96
+ | **Misclassifications** | 128 | **3** | **-97.7%** |
97
+ | **Error Rate Reduction** | - | - | **42.7×** |
98
+
99
+ **Biggest improvements:**
100
+ - 🎯 **Grünling:** 58.7% → 100.0% F1 (+41.3pp)
101
+ - 🎯 **Haussperling:** 72.0% → 100.0% F1 (+28.0pp)
102
+ - 🎯 **Rotkehlchen:** 89.5% → 99.6% F1 (+10.1pp)
103
+
104
+ ## Usage
105
+
106
+ ### Quick Start
107
+
108
+ ```python
109
+ from transformers import AutoImageProcessor, AutoModelForImageClassification
110
+ from PIL import Image
111
+ import torch
112
+
113
+ # Load model and processor
114
+ model_name = "kamera-linux/german-bird-classifier-v2"
115
+ processor = AutoImageProcessor.from_pretrained(model_name)
116
+ model = AutoModelForImageClassification.from_pretrained(model_name)
117
+
118
+ # Load and preprocess image
119
+ image = Image.open("bird.jpg")
120
+ inputs = processor(images=image, return_tensors="pt")
121
+
122
+ # Predict
123
+ with torch.no_grad():
124
+ outputs = model(**inputs)
125
+ logits = outputs.logits
126
+ predicted_class = logits.argmax(-1).item()
127
+ confidence = torch.softmax(logits, dim=-1)[0][predicted_class].item()
128
+
129
+ # Get species name
130
+ species = model.config.id2label[predicted_class]
131
+ print(f"Species: {species} (Confidence: {confidence:.2%})")
132
+ ```
133
+
134
+ ### Using vogel-model-trainer CLI
135
+
136
+ ```bash
137
+ # Install the toolkit
138
+ pip install vogel-model-trainer
139
+
140
+ # Classify images
141
+ vogel-trainer classify \
142
+ --species-model kamera-linux/german-bird-classifier-v2 \
143
+ ~/bird-photos/ \
144
+ --sort-output ~/sorted/ \
145
+ --min-confidence 0.90 \
146
+ --csv-report results.csv
147
+
148
+ # Evaluate model performance
149
+ vogel-trainer evaluate \
150
+ --species-model kamera-linux/german-bird-classifier-v2 \
151
+ --test-dir ~/test-dataset/ \
152
+ --export-json metrics.json
153
+ ```
154
+
155
+ ### Batch Processing
156
+
157
+ ```python
158
+ from transformers import pipeline
159
+
160
+ # Create classifier pipeline
161
+ classifier = pipeline(
162
+ "image-classification",
163
+ model="kamera-linux/german-bird-classifier-v2",
164
+ device=0 # GPU
165
+ )
166
+
167
+ # Classify multiple images
168
+ images = ["bird1.jpg", "bird2.jpg", "bird3.jpg"]
169
+ results = classifier(images, top_k=3)
170
+
171
+ for img, preds in zip(images, results):
172
+ print(f"\n{img}:")
173
+ for pred in preds:
174
+ print(f" {pred['label']}: {pred['score']:.2%}")
175
+ ```
176
+
177
+ ## Training Details
178
+
179
+ ### Dataset
180
+
181
+ - **Training images:** 4,160 (520 per species)
182
+ - **Validation images:** 1,040 (130 per species)
183
+ - **Source:** Real-world bird feeder camera footage
184
+ - **Image size:** 224×224 pixels
185
+ - **Perfectly balanced:** Equal samples per class
186
+
187
+ ### Training Configuration
188
+
189
+ ```
190
+ Model: google/efficientnet-b2
191
+ Epochs: 50 (with early stopping)
192
+ Batch Size: 32
193
+ Learning Rate: 0.0001
194
+ Optimizer: AdamW
195
+ Scheduler: Cosine with warmup
196
+ Augmentation: Heavy
197
+ - Random rotation
198
+ - Random horizontal flip
199
+ - Color jitter
200
+ - Random brightness/contrast
201
+ Early Stopping Patience: 15 epochs
202
+ Hardware: NVIDIA RTX 2070 SUPER (8GB)
203
+ Training Time: ~35 minutes
204
+ Framework: PyTorch 2.9.1 + Transformers 4.57.1
205
+ ```
206
+
207
+ ### Data Processing
208
+
209
+ Images were extracted from videos using YOLOv8n bird detection:
210
+ 1. **Detection:** Birds detected in video frames
211
+ 2. **Extraction:** Cropped bird regions saved as images
212
+ 3. **Deduplication:** Similar frames removed using perceptual hashing
213
+ 4. **Organization:** Manual verification and species labeling
214
+ 5. **Split:** 80% training, 20% validation
215
+
216
+ ## Model Size & Performance
217
+
218
+ | Metric | Value |
219
+ |--------|-------|
220
+ | **Model Size** | 16 MB (safetensors) |
221
+ | **Parameters** | ~9.1M |
222
+ | **Inference Speed (GPU)** | ~100 images/sec |
223
+ | **Inference Speed (CPU)** | ~10 images/sec |
224
+ | **Memory Usage (GPU)** | ~300 MB |
225
+ | **Memory Usage (CPU)** | ~200 MB |
226
+
227
+ ## Limitations & Bias
228
+
229
+ ### Known Limitations
230
+
231
+ 1. **Species Scope:** Only trained on 8 common German garden birds
232
+ 2. **Tit Confusion:** Occasional confusion between similar tit species (Blaumeise, Kohlmeise, Sumpfmeise)
233
+ 3. **Image Quality:** Best performance on clear, well-lit images
234
+ 4. **Pose Dependency:** Trained primarily on frontal/side views from bird feeders
235
+ 5. **Juvenile Birds:** May struggle with juvenile plumage variations
236
+ 6. **Seasonal Variations:** Limited seasonal plumage data
237
+
238
+ ### Potential Biases
239
+
240
+ - **Feeder Bias:** Trained on bird feeder footage, may not generalize to natural settings
241
+ - **Geographic Bias:** German garden birds, regional appearance variations may exist
242
+ - **Equipment Bias:** Optimized for similar camera setups and lighting conditions
243
+
244
+ ### Error Analysis
245
+
246
+ The 3 misclassifications on validation set:
247
+ 1. **Kohlmeise → Blaumeise** (91% confidence) - Similar coloring in poor lighting
248
+ 2. **Rotkehlchen → Blaumeise** (23% confidence) - Low confidence, model uncertain
249
+ 3. **Sumpfmeise → Kohlmeise** (76% confidence) - Very similar tit species
250
+
251
+ **Recommendation:** Use `--min-confidence 0.85` threshold to filter uncertain predictions.
252
+
253
+ ## Intended Use
254
+
255
+ ### Primary Use Cases
256
+
257
+ ✅ **Automated bird feeder monitoring**
258
+ ✅ **Citizen science bird counting**
259
+ ✅ **Wildlife camera image classification**
260
+ ✅ **Educational bird identification apps**
261
+ ✅ **Biodiversity research**
262
+
263
+ ### Out-of-Scope Uses
264
+
265
+ ❌ Classifying non-German bird species
266
+ ❌ Identifying birds outside the 8 trained species
267
+ ❌ Medical/diagnostic applications
268
+ ❌ Legal evidence or regulatory decisions
269
+ ❌ Security/surveillance applications
270
+
271
+ ## Citation
272
+
273
+ If you use this model in your research, please cite:
274
+
275
+ ```bibtex
276
+ @misc{german-bird-classifier-v2,
277
+ title={German Bird Classifier v2: High-Accuracy Garden Bird Species Classification},
278
+ author={kamera-linux},
279
+ year={2025},
280
+ publisher={Hugging Face},
281
+ url={https://huggingface.co/kamera-linux/german-bird-classifier-v2}
282
+ }
283
+ ```
284
+
285
+ ## Related Resources
286
+
287
+ - **Training Toolkit:** [vogel-model-trainer](https://github.com/kamera-linux/vogel-model-trainer)
288
+ - **PyPI Package:** [vogel-model-trainer](https://pypi.org/project/vogel-model-trainer/)
289
+ - **v1 Model (deprecated):** [german-bird-classifier](https://huggingface.co/kamera-linux/german-bird-classifier)
290
+ - **Documentation:** [GitHub README](https://github.com/kamera-linux/vogel-model-trainer/blob/main/README.md)
291
+
292
+ ## License
293
+
294
+ This model is released under the MIT License. See the [LICENSE](https://github.com/kamera-linux/vogel-model-trainer/blob/main/LICENSE) file for details.
295
+
296
+ ## Acknowledgments
297
+
298
+ - **Ultralytics** for YOLOv8 bird detection
299
+ - **Hugging Face** for Transformers library and model hosting
300
+ - **PyTorch Team** for the deep learning framework
301
+ - **Google** for EfficientNet architecture
302
+
303
+ ---
304
+
305
+ **Trained with ❤️ using [vogel-model-trainer](https://github.com/kamera-linux/vogel-model-trainer)**
config.json ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "EfficientNetForImageClassification"
4
+ ],
5
+ "batch_norm_eps": 0.001,
6
+ "batch_norm_momentum": 0.99,
7
+ "depth_coefficient": 1.0,
8
+ "depth_divisor": 8,
9
+ "depthwise_padding": [],
10
+ "drop_connect_rate": 0.2,
11
+ "dropout_rate": 0.2,
12
+ "dtype": "float32",
13
+ "expand_ratios": [
14
+ 1,
15
+ 6,
16
+ 6,
17
+ 6,
18
+ 6,
19
+ 6,
20
+ 6
21
+ ],
22
+ "hidden_act": "swish",
23
+ "hidden_dim": 1280,
24
+ "id2label": {
25
+ "0": "blaumeise",
26
+ "1": "gr\u00fcnling",
27
+ "2": "haussperling",
28
+ "3": "kernbei\u00dfer",
29
+ "4": "kleiber",
30
+ "5": "kohlmeise",
31
+ "6": "rotkehlchen",
32
+ "7": "sumpfmeise"
33
+ },
34
+ "image_size": 224,
35
+ "in_channels": [
36
+ 32,
37
+ 16,
38
+ 24,
39
+ 40,
40
+ 80,
41
+ 112,
42
+ 192
43
+ ],
44
+ "initializer_range": 0.02,
45
+ "kernel_sizes": [
46
+ 3,
47
+ 3,
48
+ 5,
49
+ 3,
50
+ 5,
51
+ 5,
52
+ 3
53
+ ],
54
+ "label2id": {
55
+ "blaumeise": 0,
56
+ "gr\u00fcnling": 1,
57
+ "haussperling": 2,
58
+ "kernbei\u00dfer": 3,
59
+ "kleiber": 4,
60
+ "kohlmeise": 5,
61
+ "rotkehlchen": 6,
62
+ "sumpfmeise": 7
63
+ },
64
+ "model_type": "efficientnet",
65
+ "num_block_repeats": [
66
+ 1,
67
+ 2,
68
+ 2,
69
+ 3,
70
+ 3,
71
+ 4,
72
+ 1
73
+ ],
74
+ "num_channels": 3,
75
+ "num_hidden_layers": 64,
76
+ "out_channels": [
77
+ 16,
78
+ 24,
79
+ 40,
80
+ 80,
81
+ 112,
82
+ 192,
83
+ 320
84
+ ],
85
+ "out_features": null,
86
+ "pooling_type": "mean",
87
+ "squeeze_expansion_ratio": 0.25,
88
+ "stage_names": [
89
+ "stem",
90
+ "stage1",
91
+ "stage2",
92
+ "stage3",
93
+ "stage4",
94
+ "stage5",
95
+ "stage6",
96
+ "stage7"
97
+ ],
98
+ "strides": [
99
+ 1,
100
+ 2,
101
+ 2,
102
+ 2,
103
+ 1,
104
+ 2,
105
+ 1
106
+ ],
107
+ "transformers_version": "4.57.1",
108
+ "width_coefficient": 1.0
109
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ccb4d1b06b5467538ae410fb5ba64c7959d0c3bc80f3858daf20e9acf4ecae0b
3
+ size 16285880
preprocessor_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": {
3
+ "height": 289,
4
+ "width": 289
5
+ },
6
+ "do_center_crop": false,
7
+ "do_normalize": true,
8
+ "do_rescale": true,
9
+ "do_resize": true,
10
+ "image_mean": [
11
+ 0.485,
12
+ 0.456,
13
+ 0.406
14
+ ],
15
+ "image_processor_type": "EfficientNetImageProcessor",
16
+ "image_std": [
17
+ 0.47853944,
18
+ 0.4732864,
19
+ 0.47434163
20
+ ],
21
+ "include_top": true,
22
+ "resample": 0,
23
+ "rescale_factor": 0.00392156862745098,
24
+ "rescale_offset": false,
25
+ "size": {
26
+ "height": 224,
27
+ "width": 224
28
+ }
29
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a15fcfe7b375866e2ccdaaeb75a29e149d8c521bbdbb94de0ebce24eb938e73
3
+ size 5905
training_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name": "google/efficientnet-b2",
3
+ "species": [
4
+ "blaumeise",
5
+ "gr\u00fcnling",
6
+ "haussperling",
7
+ "kernbei\u00dfer",
8
+ "kleiber",
9
+ "kohlmeise",
10
+ "rotkehlchen",
11
+ "sumpfmeise"
12
+ ],
13
+ "num_classes": 8,
14
+ "timestamp": "20251214_235745",
15
+ "batch_size": 32,
16
+ "num_epochs": 50,
17
+ "learning_rate": 0.0001
18
+ }