Day 55: Project checkpoint: person + garment detector deployed
First pipeline component, deployed
The detector is the pipeline's entry point, so deploy it as a service now β the same FastAPI-behind-NestJS shape from Stage 0 and Stage 1. It takes an image, returns detected person and garment boxes with classes and confidences. Deploying each component as you finish it (rather than all at once at the end) means integration bugs surface early and small.
from fastapi import FastAPI, UploadFile
from ultralytics import YOLO
import numpy as np, cv2
app = FastAPI()
model = YOLO("garment_detector.pt") # your fine-tuned weights, loaded once
@app.post("/detect")
async def detect(file: UploadFile):
img = cv2.imdecode(np.frombuffer(await file.read(), np.uint8), cv2.IMREAD_COLOR)
results = model(img)[0]
return {
"detections": [
{"class": model.names[int(b.cls)],
"confidence": round(float(b.conf), 3),
"box": b.xyxy[0].tolist()}
for b in results.boxes
]
}Ship the detector
Deploy /detect on the droplet, front it with NestJS, and verify it returns sensible person + garment boxes on new photos. Record its per-request latency (Day 44's habit) β the whole pipeline's budget is the sum of its stages, so you'll want each stage's cost as you add pose, segmentation, and parsing.
Key terms
- Incremental deployment
- Deploying each pipeline component as it is completed, so integration issues surface early rather than all at once.
- Latency budget
- A pipeline's total time constraint, spent across its stages; each stage's cost is tracked against it.
Why deploy the detector as a service now, rather than waiting until the whole pipeline is built?