Simple Flask API that accepts images and returns YOLOv5n object detections as JSON.
GET /health – readiness/liveness checkPOST /detect – submit an image via multipart upload or via URL in JSONNavigate to System > Containers > Projects in your group or device configuration.
Click Add.
Give the project a name ("API"), then click the Compose tab.
Paste the following into the compose area:
version: '2.4'
services:
api:
image: cpcontainer/image-detect-api
container_name: api
ports:
- '5000:5000'
The service will listen on http://{router_ip}:5000.
File upload:
curl -s -X POST http://localhost:5000/detect \
-F image=@/path/to/image.jpg
Image URL:
curl -s -X POST http://localhost:5000/detect \
-H 'Content-Type: application/json' \
-d '{"url":"https://example.com/image.jpg"}'
Health check:
curl -s http://localhost:5000/health
{
"num_detections": 2,
"detections": [
{
"class": "person",
"class_id": 0,
"confidence": 0.87,
"box": { "x1": 12, "y1": 34, "x2": 123, "y2": 210 }
}
]
}
yolov5n) is loaded once at startup via torch.hub.ultralytics/yolov5:latest-arm64. For non-arm64 hosts, switch the base image accordingly.Content type
Image
Digest
sha256:c7448b507…
Size
605.8 MB
Last updated
12 months ago
docker pull cpcontainer/image-detect-api