SilkGuard AI is an Android app that uses on-device AI to detect disease in silkworms in real time. No internet connection is required — all inference and data storage is local.
- 📷 Live camera detection — real-time bounding boxes on camera preview
- 🖼️ Photo upload — analyse a single image from gallery
- 🎬 Video upload — frame-by-frame analysis with progress indicator
- 📊 Results screen — healthy/diseased counts, infection %, rule-based recommendations
- 📜 Scan history — browsable list with filter by input type
- ⚙️ Settings — adjust confidence threshold, frame skip, video interval
The TFLite model is not included in the repository. Place the provided model file at:
assets/models/silkguard_yolo26n.tflite
The model file (silkwormdiseasedet.tflite) is already renamed and copied to this path.
| Property | Value |
|---|---|
| Architecture | YOLO26n (Nano) |
| Input tensor | [1, 640, 640, 3] — float32, RGB, normalised to [0, 1] |
| Output tensor | [1, 6, 8400] |
| Output format | [xCenter, yCenter, width, height, score_class0, score_class1] |
| Class 0 | healthy |
| Class 1 | diseased |
| Default confidence threshold | 0.45 |
| IoU threshold (NMS) | 0.50 |
- Flutter SDK ≥ 3.4.0
- Android SDK with API 34
- A physical Android device (API 24+) or emulator
# 1. Get dependencies
flutter pub get
# 2. Generate Drift database code
dart run build_runner build --delete-conflicting-outputs
# 3. Build debug APK
flutter build apk --debug
# 4. Install on connected device
flutter installThe debug APK is located at:
build/app/outputs/flutter-apk/app-debug.apk
lib/
├── main.dart # App entry point, model preloading
├── core/
│ ├── db/app_database.dart # Drift tables, DAOs, AppDatabase
│ ├── error/app_error.dart # Sealed error class hierarchy
│ ├── providers/providers.dart # Global Riverpod providers
│ └── router/app_router.dart # go_router route definitions
├── features/
│ ├── home/ # Dashboard with last scan card
│ │ ├── home_screen.dart
│ │ └── home_notifier.dart
│ ├── detection/ # Live camera + photo/video upload
│ │ ├── live_detection_screen.dart
│ │ ├── upload_screen.dart
│ │ ├── detection_notifier.dart
│ │ └── widgets/
│ │ ├── bounding_box_painter.dart # CustomPainter for boxes
│ │ └── detection_status_bar.dart # HUD overlay widget
│ ├── results/ # Scan summary + recommendation
│ │ ├── results_screen.dart
│ │ └── results_notifier.dart
│ ├── history/ # Browsable scan history
│ │ ├── history_screen.dart
│ │ └── history_notifier.dart
│ └── settings/ # Sliders for AI parameters
│ ├── settings_screen.dart
│ └── settings_notifier.dart
├── ai/
│ ├── yolo_detector.dart # TFLite inference + Isolate.run()
│ ├── detection_result.dart # DetectionResult data class
│ └── nms_helper.dart # Pure-Dart NMS algorithm
└── data/
├── models/
│ ├── scan_record.dart # ScanRecord domain model
│ └── detection_box.dart # DetectionBox domain model
└── repositories/
├── scan_repository.dart # Abstract repository interface
├── scan_repository_impl.dart# Drift-backed implementation
└── mappers.dart # Domain ↔ Drift companion helpers
| Permission | Purpose |
|---|---|
CAMERA |
Live detection via camera |
READ_EXTERNAL_STORAGE |
Gallery access (API < 33) |
READ_MEDIA_IMAGES |
Photo picker (API ≥ 33) |
READ_MEDIA_VIDEO |
Video picker (API ≥ 33) |
SilkGuard AI is 100% offline:
- Model inference runs on-device (TFLite)
- Scan history stored in local SQLite (Drift)
- Settings persisted via SharedPreferences
- No network calls at any point
| Layer | Package |
|---|---|
| UI | Flutter Material 3 |
| State | flutter_riverpod 2.5.1 |
| Navigation | go_router 13.2.0 |
| Camera | camera 0.10.5 |
| Gallery | image_picker 1.0.7 |
| Video | video_thumbnail 0.5.3 |
| AI | tflite_flutter 0.10.4 |
| Image | image 4.1.3 |
| Database | drift 2.18.0 |
| Storage | path_provider 2.1.2 |
| Preferences | shared_preferences 2.2.3 |
| Permissions | permission_handler 11.3.1 |