# Palm Oil Ripeness AI - Mobile App This Flutter application ports the AI-driven palm oil ripeness detection system to mobile devices. It allows for gallery-based analysis with local history storage and health alerts. ## πŸ›  Features - **AI Inference**: On-device TFLite processing for ripeness classification. - **Gallery Analysis**: Pick photos directly from the device gallery. - **History Vault**: Local storage of detection results using SQFlite. - **Health Alerts**: Immediate UI feedback for abnormal bunches. ## πŸš€ Setup & Installation ### Prerequisites - [Flutter SDK](https://docs.flutter.dev/get-started/install) installed and added to your PATH. - Android Studio or VS Code with Flutter extension. - A physical Android device connected via USB with "Developer Options" and "USB Debugging" enabled. ### 1. Initialize Project Navigate to the mobile project directory and fetch dependencies: ```bash cd palm_oil_mobile flutter pub get ``` ### 2. Run the App To test the app with full AI performance, run it in **Release Mode**: ```bash flutter run --release ``` ## πŸ§ͺ Testing Instructions 1. **Launch the App**: Open the app on your device. 2. **Select Gallery Analysis**: Tap on the **Analyze Gallery** card. 3. **Pick a Photo**: Grant gallery permissions and select a photo of a palm oil bunch. 4. **Observe Results**: * The app will display "Initializing AI..." while processing. * The detected grade and confidence score will appear. * πŸ”΄ **Health Alert**: If "Empty_Bunch" or "Abnormal" is detected, a red warning box will show. 5. **Check History**: Navigate back to the Home screen and select **History Vault** to see your past detections. 6. **Re-examine**: Tap on any history card to view the detailed summary. ## πŸ— Project Structure (Flutter Beginner's Guide) As you're new to Flutter, here’s a map of where the important logic lives. All your custom code is inside the `lib/` folder: ### 1. `lib/main.dart` The **entry point** of the application. This is where the app theme is defined and the first screen (`HomeScreen`) is launched. ### 2. `lib/models/` * **`palm_record.dart`**: Defines the "blueprint" for a detection result. If you want to store more data (like GPS coordinates or weather), you'd add fields here. ### 3. `lib/services/` This folder contains "behind-the-scenes" logic: * **`yolo_service.dart`**: Wraps the AI model. This is where the TFLite model is initialized and where image inference happens. * **`database_helper.dart`**: Manages the local SQLite database (`palm_oil_history.db`). Change this if you need to update the database schema. ### 4. `lib/screens/` This is where the **UI** lives: * **`home_screen.dart`**: The main dashboard. * **`analysis_screen.dart`**: The UI for image selection, showing the loading spinner, and displaying the AI results. * **`history_screen.dart`**: The list view for previous records and the detail modal. ### 5. `assets/` Located at the root of the project. This contains your non-code files: * `models/best.tflite`: The trained brain of the app. * `labels/labels.txt`: The names of the classes the model can recognize. ## βš™οΈ Configuration * **`pubspec.yaml`**: The project's manifest. This is where you add new dependencies (like camera or GPS plugins) and register new assets.