A service to detect if a given image of palm is ripe or not. A R&D initiated for Swopt
|
|
3 napja | |
|---|---|---|
| src | 3 napja | |
| .env | 3 napja | |
| .gitignore | 4 napja | |
| README.md | 3 napja | |
| Streamlit.md | 4 napja | |
| best.pt | 4 napja | |
| demo_app.py | 4 napja | |
| main.py | 3 napja | |
| test_model.py | 4 napja | |
| train_script.py | 4 napja | |
| yolov8n.pt | 4 napja |
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 and a Streamlit Dashboard, both integrated into an agentic n8n workflow.
git clone <your-repo-url>
cd palm-oil-ai
python -m venv venv
# Windows: venv\Scripts\activate | Mac: source venv/bin/activate
pip install ultralytics fastapi uvicorn streamlit python-multipart pillow
/datasets.Train the model:
python train_script.py
best.pt from runs/detect/train/weights/ to the project root.The new architecture decouples the vision logic from the API entry point. You can run it either via the root wrapper or directly as a module:
# Option 1: Using the root wrapper
python main.py
# Option 2: Running as a module
python -m src.api.main
By default, the server runs on http://localhost:8000.
| Endpoint | Method | Description |
|---|---|---|
/detect |
POST |
Simple YOLO detection (Returns JSON) |
/analyze |
POST |
Detection + Vertex Vectorization + MongoDB Archival |
/get_confidence |
GET |
Returns the current model confidence setting |
/set_confidence |
POST |
Updates the global model confidence setting |
The Streamlit app still provides the user interface for manual testing.
# Run the Streamlit app
streamlit run demo_app.py
---
## 📂 Repository Structure
```text
├── datasets/ # Labeled images (Train/Valid/Test)
├── runs/ # YOLO training logs and output weights
├── main.py # FastAPI Inference Server (for n8n)
├── demo_app.py # Streamlit Dashboard (for demos)
├── train_script.py # Throttled training configuration
├── best.pt # THE BRAIN: The trained model weights
└── README.md # Documentation