|
|
@@ -1,57 +1,106 @@
|
|
|
-# Palm Oil Fruit Ripeness Recognition Service
|
|
|
+## README.md
|
|
|
|
|
|
-A server-side application for identifying the ripeness of palm oil fruits using computer vision.
|
|
|
+# Palm Oil Ripeness Agent (n8n + YOLOv8)
|
|
|
|
|
|
-## Overview
|
|
|
+This project uses a custom-trained **YOLOv8** model to detect the ripeness of Palm Oil Fresh Fruit Bunches (FFB). It features a local Python FastAPI server that integrates into an **agentic n8n workflow**, storing results and embeddings in **MongoDB Atlas**.
|
|
|
|
|
|
-This project provides a recognition service for palm oil fruit ripeness. It is designed to assist in the automation of the harvesting process by providing accurate assessment of fruit maturity.
|
|
|
+## 🚀 Project Overview
|
|
|
|
|
|
-## Features
|
|
|
+1. **Model:** YOLOv8 Nano (custom-trained on Roboflow dataset).
|
|
|
+2. **Server:** FastAPI (Python) hosting the model for inference.
|
|
|
+3. **Database:** MongoDB Atlas (Vector Search for historical similarity).
|
|
|
+4. **Orchestration:** n8n (Agentic workflow for decision making).
|
|
|
|
|
|
-- **Ripeness Classification**: Uses advanced image recognition to categorize palm oil fruits (e.g., Unripe, Under-ripe, Ripe, Over-ripe).
|
|
|
-- **API Interface**: Built to serve mobile and web clients for real-time recognition.
|
|
|
+---
|
|
|
|
|
|
-## Getting Started
|
|
|
+## 🛠 Prerequisites
|
|
|
|
|
|
-### Prerequisites
|
|
|
+* Python 3.10+
|
|
|
+* n8n (Desktop or Self-hosted)
|
|
|
+* MongoDB Atlas Account (with Vector Search index enabled)
|
|
|
+* *Optional:* NVIDIA GPU with CUDA for faster training.
|
|
|
|
|
|
-- Python 3.8+
|
|
|
-- Virtual environment (recommended)
|
|
|
+---
|
|
|
|
|
|
-### Installation
|
|
|
+## 📦 Setup Instructions
|
|
|
|
|
|
-1. **Clone the repository**:
|
|
|
- ```powershell
|
|
|
- git clone <repository-url>
|
|
|
- cd palm-oil-ai
|
|
|
- ```
|
|
|
+### 1. Clone & Environment
|
|
|
|
|
|
-2. **Set up virtual environment**:
|
|
|
- ```powershell
|
|
|
- python -m venv venv
|
|
|
- .\venv\Scripts\Activate.ps1
|
|
|
- ```
|
|
|
+```bash
|
|
|
+git clone <your-repo-url>
|
|
|
+cd palm-oil-ai
|
|
|
+python -m venv venv
|
|
|
+# Windows: venv\Scripts\activate | Mac: source venv/bin/activate
|
|
|
+pip install -r requirements.txt
|
|
|
+
|
|
|
+```
|
|
|
+
|
|
|
+### 2. Dataset Preparation
|
|
|
+
|
|
|
+1. Download the dataset from [Roboflow Universe](https://www.google.com/search?q=https://universe.roboflow.com/assignment-vvtq7/oil-palm-ripeness/).
|
|
|
+2. Unzip into the `/datasets` folder.
|
|
|
+3. Ensure your `data.yaml` matches the local paths:
|
|
|
+```yaml
|
|
|
+train: ../datasets/train/images
|
|
|
+val: ../datasets/valid/images
|
|
|
+
|
|
|
+```
|
|
|
|
|
|
-3. **Install dependencies**:
|
|
|
- ```powershell
|
|
|
- pip install -r requirements.txt
|
|
|
- ```
|
|
|
- *(Note: Ensure requirements.txt is created/updated as the project develops)*
|
|
|
|
|
|
-### Running the Server
|
|
|
|
|
|
-To start the recognition service:
|
|
|
+### 3. Training the Model
|
|
|
+
|
|
|
+To train locally without hanging your PC, use the throttled script:
|
|
|
+
|
|
|
+```bash
|
|
|
+python train_script.py
|
|
|
|
|
|
-```powershell
|
|
|
-# Assuming a FastAPI/Uvicorn setup (common for such services)
|
|
|
-uvicorn main:app --reload
|
|
|
```
|
|
|
|
|
|
-## Dataset
|
|
|
+* **Outputs:** The best model will be saved at `runs/detect/train/weights/best.pt`.
|
|
|
+* **Move it:** Copy `best.pt` to the root directory for the server to use.
|
|
|
+
|
|
|
+### 4. Running the Inference Server
|
|
|
+
|
|
|
+```bash
|
|
|
+python main.py
|
|
|
+
|
|
|
+```
|
|
|
+
|
|
|
+The server will start at `http://localhost:8000`.
|
|
|
+
|
|
|
+* **Endpoint:** `POST /detect`
|
|
|
+* **Payload:** Multipart Form-data (Key: `file`, Value: `image.jpg`)
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 🤖 n8n Integration
|
|
|
+
|
|
|
+The n8n workflow follows this logic:
|
|
|
+
|
|
|
+1. **Trigger:** Receives image (Telegram/Webhook).
|
|
|
+2. **HTTP Request:** Sends image to `localhost:8000/detect`.
|
|
|
+3. **MongoDB Node:** Performs Vector Search using the returned embedding.
|
|
|
+4. **Agent Logic:** Final ripeness determination based on model confidence + DB similarity.
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 📂 Repository Structure
|
|
|
+
|
|
|
+```text
|
|
|
+├── datasets/ # Labeled images from Roboflow
|
|
|
+├── runs/ # YOLO training logs and weights
|
|
|
+├── main.py # FastAPI Inference Server
|
|
|
+├── train_script.py # Local training configuration
|
|
|
+├── best.pt # The "Brain" (Trained Model)
|
|
|
+├── requirements.txt # dependencies
|
|
|
+└── README.md # You are here
|
|
|
+
|
|
|
+```
|
|
|
|
|
|
-This project uses the YOLOv8 dataset format for training and evaluation:
|
|
|
-- YOLOv8 Dataset: `oil palm ripeness.v5-roboflow-instant-2--eval-.yolov8`
|
|
|
+---
|
|
|
|
|
|
-## License
|
|
|
+## 📝 Future Improvements
|
|
|
|
|
|
-[License Type] - See LICENSE file for details.
|
|
|
+* Implement **CLIP** embeddings for higher-accuracy vector similarity.
|
|
|
+* Add a **Streamlit** dashboard for manual batch verification.
|