You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Yolo/android/README.md
+55-96Lines changed: 55 additions & 96 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,32 @@
3
3
## 🐦 Android Bird Detection App with ExecuTorch
4
4
5
5
A real-time bird detection and species identification Android app using YOLO + EfficientNet models deployed via Meta's ExecuTorch framework. The app provides session-based bird watching with automatic logging, thumbnails, and timestamps for backyard bird enthusiasts.
6
-
Bird Detection Feature: Uses a two-stage pipeline where YOLO (COCO class 14) detects birds in camera frames, then EfficientNet classifier identifies the specific species from 525 possible bird types with 96.8% accuracy.
7
6
8
-
## Model Download and Conversion
7
+
**Bird Detection Feature:** Uses a two-stage pipeline where YOLO (COCO class 14) detects birds in camera frames, then EfficientNet classifier identifies the specific species from 525 possible bird types with 96.8% accuracy.
8
+
9
+
## Prerequisites
9
10
10
-
### Step 1: Download Models
11
+
Install PyTorch and ExecuTorch by following the [ExecuTorch installation guide](https://docs.pytorch.org/executorch/main/getting-started.html), which pins the compatible torch version. The simplest path is:
11
12
12
-
#### Bird Classifier Model
13
+
```bash
14
+
pip install executorch
15
+
```
13
16
14
-
Install dependencies
17
+
Then install the remaining dependencies:
15
18
19
+
```bash
20
+
pip install transformers ultralytics
16
21
```
22
+
23
+
For Android-specific setup, see the [Android section](https://docs.pytorch.org/executorch/main/android-section.html) of the ExecuTorch docs.
24
+
25
+
## Model Download and Conversion
26
+
27
+
### Step 1: Download and Convert Bird Classifier Model
28
+
29
+
Create `convert_bird_classifier.py`:
30
+
31
+
```python
17
32
import torch
18
33
from transformers import AutoModelForImageClassification
print("Bird classifier converted to bird_classifier.pte")
59
+
```bash
60
+
python convert_bird_classifier.py
105
61
```
106
62
107
-
### Convert YOLO Model
63
+
### Step 2: Convert YOLO Model to .pte Format
108
64
109
-
convert_yolo.py
110
-
This script works for both YOLOv8 and YOLOv26 - just change the model filename.
65
+
Create `convert_yolo.py`:
111
66
112
-
```
67
+
```python
113
68
from ultralytics importYOLO
114
69
import torch
115
70
from torch.export import export
@@ -137,25 +92,28 @@ with open("yolo_detector.pte", "wb") as f:
137
92
print("YOLO model converted to yolo_detector.pte")
138
93
```
139
94
140
-
#### Auto-Detection: The app automatically detects which YOLO version you're using (v8 or v26) based on the model's output format. No code changes needed when switching between versions!
95
+
**Auto-Detection:** The app automatically detects which YOLO version you're using (v8 or v26) based on the model's output format. No code changes needed when switching between versions!
141
96
142
-
### Generate Bird Species Names
97
+
### Step 3: Generate Bird Species Names
143
98
144
-
extract_species_names.py
99
+
Create `extract_species_names.py`:
145
100
146
-
```
101
+
```python
147
102
from transformers import AutoModelForImageClassification
148
103
import json
149
-
model = AutoModelForImageClassification.from_pretrained('./bird_classifier_model')
104
+
105
+
model = AutoModelForImageClassification.from_pretrained('chriamue/bird_classifier_model')
150
106
species_names = [model.config.id2label[i] for i inrange(len(model.config.id2label))]
107
+
151
108
withopen('bird_species.json', 'w') as f:
152
-
json.dump(species_names, f, indent=2)
109
+
json.dump(species_names, f, indent=2)
110
+
153
111
print(f"Saved {len(species_names)} bird species names to bird_species.json")
0 commit comments