zenlio/seed-segmentation-deploy
Seed Segmentation Server Prototype
Minimal deployable server inference core for seed segmentation.
It removes the old app concerns:
- no auth
- no MongoDB
- no history
- no Socket.IO
- no Node backend
- no web/mobile app
- no MobileSAM
- FastSAM-s ONNX is available as an optional quality refiner
Runtime flow:
web browser
-> upload image
-> server YOLOv8 segmentation ONNX
-> optional FastSAM-s ONNX / CPU edge refinement
-> overlay PNG / JSON resultThis folder is only for the web/server target. The mobile APK target must keep its own TFLite model inside the APK and run inference locally without internet.
Structure
seed_deploy/
├── app.py
├── requirements.txt
├── Dockerfile
├── grain.settings.json
├── model/
│ └── best.onnx
└── grain_pipeline/Defaults
The deployment defaults are intentionally conservative:
max_side = 768
conf = 0.25
iou = 0.60
max_det = 300
mode = balancedThese replace the previous heavy prototype defaults such as conf=0.03 and max_det=5000.
Modes:
fast = YOLO ONNX only, fastest
balanced = YOLO ONNX + FastSAM only when candidate count is small enough
quality = YOLO ONNX + FastSAM + CPU mask refine, slowest but best mask qualityFor dense seed piles, quality can be slow because it may refine many individual grain candidates. For customer demos, start with balanced; use quality for images where mask boundary quality matters more than latency.
Run Locally With Python
cd D:\seed\seed_deploy
python -m pip install -r requirements.txt
python -m uvicorn app:app --host 127.0.0.1 --port 8000 --reloadOpen:
http://127.0.0.1:8000/API docs:
http://127.0.0.1:8000/docsRun With Docker
Build:
cd D:\seed\seed_deploy
docker build -t seed-segmentation-prototype .Run:
docker run -d --name seed-segmentation-prototype -p 8001:7860 seed-segmentation-prototypeOpen:
http://127.0.0.1:8001/Stop:
docker rm -f seed-segmentation-prototypeAPI
GET /health
Returns service status.
POST /segment
Returns overlay PNG directly.
curl.exe -o overlay.png `
-F "image=@D:\seed\test_images\sample.jpg;type=image/jpeg" `
"http://127.0.0.1:8001/segment"Optional query parameters:
max_side=768
conf=0.25
iou=0.60
max_det=300
mode=balancedExample:
curl.exe -o overlay.png `
-F "image=@D:\seed\test_images\sample.jpg;type=image/jpeg" `
"http://127.0.0.1:8001/segment?max_side=768&conf=0.25&max_det=300&mode=balanced"Response headers:
X-Seed-Count
X-Candidate-Count
X-Model
X-Refiner
X-Refiner-AppliedPOST /analyze
Returns JSON with summary, measurements, and overlay PNG as base64.
curl.exe -o result.json `
-F "image=@D:\seed\test_images\sample.jpg;type=image/jpeg" `
"http://127.0.0.1:8001/analyze"Response shape:
{
"ok": true,
"image": {
"width": 700,
"height": 392,
"original_width": 700,
"original_height": 392,
"scale": 1.0
},
"pipeline": "yolo8_nano_segment_deploy",
"model": "best.onnx",
"settings": {
"maxSide": 768,
"confidence": 0.25,
"iou": 0.6,
"maxDet": 300,
"preprocess": false
},
"candidate_count": 297,
"refiner": "FastSAM-s.onnx",
"refiner_applied": false,
"refiner_skip_reason": "candidate_count>80",
"summary": {
"count": 286
},
"measurements": [],
"overlay_png_base64": "..."
}Deployment Notes
Recommended first deployment targets:
- Hugging Face Spaces Docker for a free public AI demo.
- Render Docker Web Service for a simple public API.
Keep the first cloud version CPU-only and YOLO-only. Add storage, auth, history, or mobile inference later.
Web vs Mobile Architecture
The project has two separate deployment targets:
Web demo
-> model lives on server
-> seed_deploy Docker API runs best.onnx
Mobile APK
-> model lives inside APK
-> Flutter app runs assets/models/best_float16.tflite locally
-> no internet required for normal analysisDo not make the mobile app depend on this Docker service for normal operation. The server API is for web/public demo and optional sync/debug workflows only.
