Skip to content

Commit 907a13a

Browse files
committed
Merge origin/main into yolo-download
2 parents 03ce038 + b818840 commit 907a13a

154 files changed

Lines changed: 10451 additions & 520 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/android-build.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
name: Android Build
88

99
on:
10+
pull_request:
1011
schedule:
1112
# Run nightly at midnight UTC
1213
- cron: '0 0 * * *'
@@ -35,38 +36,49 @@ jobs:
3536
path: mv3/android/MV3Demo
3637
- name: YoloDemo
3738
path: Yolo/android
39+
- name: WhisperDemo
40+
path: whisper/android/WhisperApp
41+
require_aar: true
42+
- name: ParakeetDemo
43+
path: parakeet/android/ParakeetApp
44+
require_aar: true
3845

3946

4047
name: Build ${{ matrix.name }}
4148
steps:
4249
- name: Checkout repository
50+
if: ${{ !matrix.require_aar || inputs.local_aar }}
4351
uses: actions/checkout@v4
4452

4553
- name: Set up JDK 17
54+
if: ${{ !matrix.require_aar || inputs.local_aar }}
4655
uses: actions/setup-java@v4
4756
with:
4857
java-version: '17'
4958
distribution: 'temurin'
5059

5160
- name: Setup Gradle
61+
if: ${{ !matrix.require_aar || inputs.local_aar }}
5262
uses: gradle/actions/setup-gradle@v4
5363

5464
- name: Download local AAR
55-
if: ${{ inputs.local_aar && (matrix.name == 'LlamaDemo' || matrix.name == 'YoloDemo') }}
65+
if: ${{ inputs.local_aar && (matrix.name == 'LlamaDemo' || matrix.name == 'YoloDemo' || matrix.name == 'WhisperDemo' || matrix.name == 'ParakeetDemo') }}
5666
run: |
5767
mkdir -p ${{ matrix.path }}/app/libs
5868
curl -fL -o ${{ matrix.path }}/app/libs/executorch.aar "${{ inputs.local_aar }}"
5969
6070
- name: Build with Gradle
71+
if: ${{ !matrix.require_aar || inputs.local_aar }}
6172
working-directory: ${{ matrix.path }}
6273
run: |
63-
if [ -n "${{ inputs.local_aar }}" ] && ([ "${{ matrix.name }}" == "LlamaDemo" ] || [ "${{ matrix.name }}" == "YoloDemo" ]); then
74+
if [ -n "${{ inputs.local_aar }}" ] && ([ "${{ matrix.name }}" == "LlamaDemo" ] || [ "${{ matrix.name }}" == "YoloDemo" ] || [ "${{ matrix.name }}" == "WhisperDemo" ] || [ "${{ matrix.name }}" == "ParakeetDemo" ]); then
6475
./gradlew build --no-daemon -PuseLocalAar=true
6576
else
6677
./gradlew build --no-daemon
6778
fi
6879
6980
- name: Rename APKs with demo name
81+
if: ${{ !matrix.require_aar || inputs.local_aar }}
7082
working-directory: ${{ matrix.path }}/app/build/outputs/apk/
7183
run: |
7284
find . -name "*.apk" -type f -print0 | while IFS= read -r -d '' apk; do
@@ -78,6 +90,7 @@ jobs:
7890
done
7991
8092
- name: Upload build artifacts
93+
if: ${{ !matrix.require_aar || inputs.local_aar }}
8194
uses: actions/upload-artifact@v4
8295
with:
8396
name: ${{ matrix.name }}-apk

.gitignore

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,27 @@ build/
1313
*.pte
1414
*.ptd
1515

16+
# DMG files (should be distributed via GitHub Releases)
17+
*.dmg
18+
*.dmg.*
19+
1620
# Xcode
1721
xcuserdata/
1822
.build/
1923
.swiftpm/
2024
*.xcworkspace/
2125
*.xcframework/
22-
*.iml
2326

27+
# Android / IntelliJ
28+
*.iml
2429
.gradle
25-
/local.properties
26-
./idea
27-
/.idea/caches
28-
/.idea/libraries
29-
/.idea/modules.xml
30-
/.idea/workspace.xml
31-
/.idea/navEditor.xml
32-
/.idea/assetWizardSettings.xml
33-
.DS_Store
30+
.idea/
31+
local.properties
3432
/captures
3533
.externalNativeBuild
3634
.cxx
37-
local.properties
3835
*.aar
36+
37+
node_modules/
38+
__pycache__/
39+
.cursor/

.gitmodules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@
33
url = https://github.com/pytorch/executorch.git
44
branch = release/1.0
55

6-
[submodule "program-data-separation/cpp/executorch"]
7-
path = program-data-separation/cpp/executorch
8-
url = https://github.com/pytorch/executorch.git
9-
branch = main

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ BSD License
22

33
For "ExecuTorch" software
44

5-
Copyright (c) Meta Platforms, Inc. and affiliates.
5+
Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
66

77
Redistribution and use in source and binary forms, with or without modification,
88
are permitted provided that the following conditions are met:

Yolo/android/README.md

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,62 @@ Bird Detection Feature: Uses a two-stage pipeline where YOLO (COCO class 14) det
1414
Install dependencies
1515

1616
```
17-
pip install transformers torch pillow executorch
18-
Download EfficientNet bird classifier
19-
python -c "
20-
from transformers import AutoImageProcessor, AutoModelForImageClassification
21-
import torch
22-
model_name = 'dennisjooo/Birds-Classifier-EfficientNetB2'
23-
processor = AutoImageProcessor.from_pretrained(model_name)
24-
model = AutoModelForImageClassification.from_pretrained(model_name)
25-
model.save_pretrained('./bird_classifier_model')
26-
processor.save_pretrained('./bird_classifier_model')
27-
print('Bird classifier downloaded')
17+
import torch
18+
from transformers import AutoModelForImageClassification
19+
from torch.export import export
20+
from executorch.exir import to_edge_transform_and_lower
21+
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
22+
23+
# Download and load model
24+
model = AutoModelForImageClassification.from_pretrained("chriamue/bird-species-classifier")
25+
model.eval()
26+
27+
# Export to ExecuTorch
28+
example_input = torch.randn(1, 3, 224, 224)
29+
exported_program = export(model, (example_input,))
30+
edge_program = to_edge_transform_and_lower(
31+
exported_program,
32+
partitioner=[XnnpackPartitioner()]
33+
)
34+
et_program = edge_program.to_executorch()
35+
36+
# Save as .pte file
37+
with open("bird_classifier.pte", "wb") as f:
38+
et_program.write_to_file(f)
39+
print("Bird classifier converted to bird_classifier.pte")
40+
41+
Run it from a regular terminal (not Claude Code) to avoid the proxy block:
42+
43+
cd /home/sidart/executorch
44+
python convert_bird_classifier.py
2845
"
2946
```
3047

31-
### YOLO Detection Model
48+
## Detection Model
49+
50+
The app supports both v8 and v26 and automatically detects which version you're using based on the model output format.
3251

33-
Install YOLOv8
52+
Install Ultralytics:
3453

3554
```
3655
pip install ultralytics
37-
Download YOLO model
56+
```
57+
58+
### Download model
59+
60+
#### Option 1: v8
3861
python -c "
39-
from ultralytics import YOLO
40-
model = YOLO('yolov8n.pt') # nano version for mobile
41-
print('YOLO model downloaded')
62+
from ultralytics import
63+
model = ('v8n.pt') # nano version for mobile
64+
print('v8 model downloaded')
65+
"
66+
```
67+
68+
#### Option 2: v26 (Recommended - Faster & More Accurate)
69+
python -c "
70+
from ultralytics import
71+
model = ('26n.pt') # nano version for mobile
72+
print('v26 model downloaded')
4273
"
4374
```
4475

@@ -76,31 +107,38 @@ print("Bird classifier converted to bird_classifier.pte")
76107
### Convert YOLO Model
77108

78109
convert_yolo.py
110+
This script works for both YOLOv8 and YOLOv26 - just change the model filename.
79111

80112
```
81113
from ultralytics import YOLO
82114
import torch
83115
from torch.export import export
84116
from executorch.exir import to_edge_transform_and_lower
85117
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
86-
Load YOLO model
87-
yolo = YOLO('yolov8n.pt')
118+
119+
# Load YOLO model
120+
# Use 'yolov8n.pt' for YOLOv8 OR 'yolo26n.pt' for YOLOv26
121+
yolo = YOLO('yolo26n.pt') # Recommended: YOLOv26 for better performance
88122
pytorch_model = yolo.model
89123
pytorch_model.eval()
90-
Export to ExecuTorch
124+
125+
# Export to ExecuTorch
91126
example_input = torch.randn(1, 3, 640, 640)
92127
exported_program = export(pytorch_model, (example_input,))
93128
edge_program = to_edge_transform_and_lower(
94-
exported_program,
95-
partitioner=[XnnpackPartitioner()]
129+
exported_program,
130+
partitioner=[XnnpackPartitioner()]
96131
)
97132
et_program = edge_program.to_executorch()
98-
Save as .pte file
133+
134+
# Save as .pte file
99135
with open("yolo_detector.pte", "wb") as f:
100-
et_program.write_to_file(f)
136+
et_program.write_to_file(f)
101137
print("YOLO model converted to yolo_detector.pte")
102138
```
103139

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!
141+
104142
### Generate Bird Species Names
105143

106144
extract_species_names.py

Yolo/android/app/build.gradle.kts

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,78 +7,80 @@
77
*/
88

99
plugins {
10-
id("com.android.application")
11-
id("org.jetbrains.kotlin.android")
10+
alias(libs.plugins.android.application)
11+
alias(libs.plugins.kotlin.android)
12+
alias(libs.plugins.kotlin.compose)
1213
}
1314

1415
val qnnVersion: String? = project.findProperty("qnnVersion") as? String
1516
val useLocalAar: Boolean? = (project.findProperty("useLocalAar") as? String)?.toBoolean()
1617

1718
android {
18-
namespace = "com.example.executorchyolodemo"
19-
compileSdk = 34
19+
namespace = "com.example.executorchyolodemo"
20+
compileSdk = 35
2021

21-
defaultConfig {
22-
applicationId = "com.example.executorchyolodemo"
23-
minSdk = 28
24-
targetSdk = 33
25-
versionCode = 1
26-
versionName = "1.0"
22+
defaultConfig {
23+
applicationId = "com.example.executorchyolodemo"
24+
minSdk = 28
25+
targetSdk = 35
26+
versionCode = 1
27+
versionName = "1.0"
2728

28-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
29-
vectorDrawables { useSupportLibrary = true }
30-
externalNativeBuild { cmake { cppFlags += "" } }
31-
}
29+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
30+
vectorDrawables { useSupportLibrary = true }
31+
externalNativeBuild { cmake { cppFlags += "" } }
32+
}
3233

33-
buildTypes {
34-
release {
35-
isMinifyEnabled = false
36-
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
34+
buildTypes {
35+
release {
36+
isMinifyEnabled = false
37+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
38+
}
39+
}
40+
compileOptions {
41+
sourceCompatibility = JavaVersion.VERSION_11
42+
targetCompatibility = JavaVersion.VERSION_11
43+
}
44+
kotlinOptions {
45+
jvmTarget = "11"
3746
}
38-
}
39-
compileOptions {
40-
sourceCompatibility = JavaVersion.VERSION_1_8
41-
targetCompatibility = JavaVersion.VERSION_1_8
42-
}
43-
kotlinOptions { jvmTarget = "1.8" }
44-
buildFeatures { compose = true }
45-
composeOptions { kotlinCompilerExtensionVersion = "1.5.14" }
46-
packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } }
47+
buildFeatures {
48+
compose = true
49+
}
50+
packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } }
4751
}
4852

4953
dependencies {
50-
implementation("androidx.core:core-ktx:1.9.0")
51-
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
52-
implementation("androidx.activity:activity-compose:1.7.0")
53-
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
54-
implementation("androidx.compose.ui:ui")
55-
implementation("androidx.compose.ui:ui-graphics")
56-
implementation("androidx.compose.ui:ui-tooling-preview")
57-
implementation("androidx.compose.material3:material3")
58-
implementation("androidx.appcompat:appcompat:1.6.1")
59-
implementation("androidx.camera:camera-core:1.3.0-rc02")
60-
implementation("androidx.constraintlayout:constraintlayout:2.2.0-alpha12")
61-
implementation("com.facebook.fbjni:fbjni:0.5.1")
62-
implementation("com.google.code.gson:gson:2.8.6")
63-
if (useLocalAar == true) {
64-
implementation(files("libs/executorch.aar"))
65-
} else {
66-
implementation("org.pytorch:executorch-android:1.1.0")
67-
}
68-
69-
implementation("com.google.android.material:material:1.12.0")
70-
implementation("androidx.activity:activity:1.9.0")
71-
implementation("org.json:json:20250107")
72-
testImplementation("junit:junit:4.13.2")
73-
androidTestImplementation("androidx.test.ext:junit:1.1.5")
74-
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
75-
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
76-
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
77-
debugImplementation("androidx.compose.ui:ui-tooling")
78-
debugImplementation("androidx.compose.ui:ui-test-manifest")
54+
implementation(libs.androidx.core.ktx)
55+
implementation(libs.androidx.lifecycle.runtime.ktx)
56+
implementation(libs.androidx.activity.compose)
57+
implementation(platform(libs.androidx.compose.bom))
58+
implementation(libs.androidx.ui)
59+
implementation(libs.androidx.ui.graphics)
60+
implementation(libs.androidx.ui.tooling.preview)
61+
implementation(libs.androidx.material3)
62+
implementation(libs.androidx.appcompat)
63+
implementation(libs.material)
64+
implementation("androidx.constraintlayout:constraintlayout:2.2.0")
65+
implementation("com.facebook.fbjni:fbjni:0.5.1")
66+
implementation("com.google.code.gson:gson:2.10.1")
67+
if (useLocalAar == true) {
68+
implementation(files("libs/executorch.aar"))
69+
} else {
70+
implementation("org.pytorch:executorch-android:1.1.0")
71+
}
72+
implementation("androidx.activity:activity:1.9.0")
73+
implementation("org.json:json:20250107")
74+
testImplementation(libs.junit)
75+
androidTestImplementation(libs.androidx.junit)
76+
androidTestImplementation(libs.androidx.espresso.core)
77+
androidTestImplementation(platform(libs.androidx.compose.bom))
78+
androidTestImplementation(libs.androidx.ui.test.junit4)
79+
debugImplementation(libs.androidx.ui.tooling)
80+
debugImplementation(libs.androidx.ui.test.manifest)
7981

80-
implementation ("androidx.camera:camera-camera2:1.3.0")
81-
implementation ("androidx.camera:camera-lifecycle:1.3.0")
82-
implementation ("androidx.camera:camera-view:1.3.0")
83-
implementation ("com.google.code.gson:gson:2.10.1")
82+
implementation(libs.androidx.camera.core)
83+
implementation(libs.androidx.camera.camera2)
84+
implementation(libs.androidx.camera.lifecycle)
85+
implementation(libs.androidx.camera.view)
8486
}

0 commit comments

Comments
 (0)