A cross-platform mobile app demonstrating on-device AI for iOS and Android. This app performs real-time image classification completely locally on your device — no cloud, no network calls, 100% private.
Choose any photo from your library, and the app instantly predicts what's in it with a confidence score. Everything runs locally using native ML frameworks (Core ML for iOS, TensorFlow Lite for Android).
- Fast ⚡ - Results appear instantly (~50ms)
- Private 🔒 - Everything happens locally, photos never leave your device
- Offline 🔋 - Works anywhere, no internet required
- Accurate - Uses MobileNetV2 trained on ImageNet (1000 object classes)
- Cross-Platform 📱 - Native implementations for both iOS and Android
- SwiftUI - Modern declarative UI framework
- Core ML - Apple's machine learning framework
- MobileNetV2 - Lightweight image classification model (~17MB)
- iOS 14.0+ - Minimum deployment target
- Jetpack Compose - Modern declarative UI toolkit
- TensorFlow Lite - Google's on-device ML framework
- MobileNetV2 - Quantized model (~4MB)
- Android 7.0+ (API 24+) - Minimum SDK version
User selects photo → MobileNetV2 model → Prediction with confidence score
(runs on device)
The architecture is surprisingly simple:
- MobileNetV2 model runs locally via Core ML (iOS) or TensorFlow Lite (Android)
- Native UI handles the interface and image picker
- Image → Model → Predictions (all on device, ~50ms)
OnDeviceClassifierDemo/
├── OnDeviceClassifierDemo_iOS/ # iOS app
│ ├── OnDeviceClassifierDemo/
│ │ ├── ContentView.swift # Main UI
│ │ ├── ImagePicker.swift # Photo picker
│ │ └── Assets.xcassets
│ ├── MobileNetV2.mlmodel # Core ML model (17MB)
│ ├── OnDeviceClassifierDemo.xcodeproj
│ └── README.md
│
├── OnDeviceClassifierDemo_android/ # Android app
│ ├── app/
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ ├── res/
│ │ └── assets/
│ │ └── mobilenet_v2.tflite # TF Lite model (4MB)
│ ├── build.gradle
│ └── README.md
│
├── .gitignore # Combined iOS + Android
└── README.md # This file
- Xcode 13.0+
- iOS 14.0+ device or simulator
- macOS 11.0+ (Big Sur or later)
cd OnDeviceClassifierDemo_iOS
open OnDeviceClassifierDemo.xcodeprojBuild and run in Xcode (Cmd + R)
See iOS README for detailed setup.
- Android Studio Arctic Fox or later
- Android 7.0+ (API 24+) device or emulator
- JDK 11+
cd OnDeviceClassifierDemo_android
./gradlew buildOpen project in Android Studio and run.
See Android README for detailed setup.
| Cloud AI | On-Device AI |
|---|---|
| Network required | ✅ Works offline |
| ~500ms latency | ✅ ~50ms latency |
| Privacy concerns | ✅ 100% private |
| ✅ Infinitely scalable | Battery constrained |
| ✅ Complex models | Limited model size |
Perfect for:
- Real-time image recognition
- Privacy-sensitive applications
- Offline functionality
- Low-latency requirements
Tap "Choose Photo" → select any image → instant label appears with confidence score
| Platform | Model Size | Inference Time | Memory Usage |
|---|---|---|---|
| iOS (Core ML) | 17MB | ~50ms | ~30MB |
| Android (TF Lite) | 4MB (quantized) | ~70ms | ~25MB |
- Model: MobileNetV2
- Input: 224x224 RGB image
- Output: 1000 ImageNet class labels with probabilities
- Training Dataset: ImageNet
- Accuracy: Top-1: ~71%, Top-5: ~90%
- Support for custom ML models
- Camera integration for real-time classification
- History of predictions
- Export results
- Object detection support
- Multi-object classification
- Batch processing
MIT License - feel free to use this project for learning and building your own on-device AI apps!
- MobileNetV2 model from Apple's Core ML Model Gallery (iOS)
- TensorFlow Lite models from TensorFlow Hub (Android)
- Trained on ImageNet dataset
- Built with native frameworks: SwiftUI, Core ML, Jetpack Compose, TensorFlow Lite
Contributions are welcome! Please feel free to submit a Pull Request.
If you found this helpful, consider starring the repo! ⭐

