--- title: Amazon Trailer Inspector emoji: 🚛 colorFrom: blue colorTo: indigo sdk: docker app_file: app.py pinned: false license: mit --- # 🚛 Amazon Trailer Inspector — REST API AI-powered trailer inspection pipeline exposed as a **REST API**. Submit up to **6 labeled images** and receive a structured JSON inspection report. --- ## Endpoint ### `POST /inspect` Submit all images in one request. All aspects are analyzed **in parallel**. #### Request Body (JSON) ```json { "images": [ { "label": "front_left", "image_base64": "" }, { "label": "front_right", "image_base64": "" }, { "label": "rear_left", "image_base64": "" }, { "label": "rear_right", "image_base64": "" }, { "label": "inside", "image_base64": "" }, { "label": "door", "image_base64": "" } ] } ``` **Accepted labels:** `front_left`, `front_right`, `rear_left`, `rear_right`, `inside`, `door` - Images can be raw base64 OR a data-URI (`data:image/jpeg;base64,...`) - All 6 images are optional — only send the ones you have - Each label can appear at most once per request - `rear_left` and `rear_right` must **both** be present for full rear confirmation --- #### Response Body (JSON) ```json { "status": "success", "images_received": ["front_left", "front_right", "rear_left", "rear_right", "inside", "door"], "labels_missing": [], "report": { "front": { "label": "Front Left / Right", "images_provided": ["front_left", "front_right"], "components": { "Sensors": "detected", "GPS Device": "missing", "Prime Logo": "detected", "Trailer ID Label": "detected" }, "notes": [] }, "rear": { "label": "Rear Left / Right", "images_provided": ["rear_left", "rear_right"], "components": { "Side Skirts / Fins": { "status": "detected", "count": "2/2" }, "Edge Kit": { "status": "partially detected (left side only)", "count": "1/2" } }, "notes": [] }, "inside": { "label": "Inside Trailer", "images_provided": ["inside"], "components": { "Side Guards": "detected", "Flooring": "detected" }, "notes": [] }, "door": { "label": "Door Details", "images_provided": ["door"], "components": { "Latch Kit & Lash Links": "detected", "Grote LED Lights": "missing" }, "notes": [] } } } ``` --- ## Component Values | Aspect | Component Values | |--------|-----------------| | Front | `"detected"` or `"missing"` (OR logic — detected if found in either left or right image) | | Rear | `"detected"`, `"partially detected (left side only)"`, `"partially detected (right side only)"`, or `"missing"` — plus `count` (`"2/2"`, `"1/2"`, `"0/2"`) | | Inside | `"detected"` or `"missing"` | | Door | `"detected"` or `"missing"` | --- ## Notes Field The `notes` array in each aspect section contains warnings such as: - `"front_left: image missing from input"` — label was not submitted - `"rear_right: invalid image (wrong angle/side)"` — model rejected the image - `"door: invalid image (not a valid rear door view)"` — wrong image type --- ## Other Endpoints | Method | Path | Description | |--------|------------|--------------------------| | GET | `/` | Service info | | GET | `/health` | HF_TOKEN status + models | | GET | `/docs` | Interactive Swagger UI | --- ## Setup Space Settings → **Repository Secrets** → add `GEMINI_API_KEY` Get a **free** Gemini API key at [aistudio.google.com/apikey](https://aistudio.google.com/apikey) No credit card required — free tier includes **1,500 requests/day**. --- ## Models (Google Gemini, free tier) 1. `gemini-2.0-flash` — primary (best quality + speed, free) 2. `gemini-2.0-flash-lite` — fallback 1 (lighter 2.0 variant, free tier) 3. `gemini-1.5-flash-latest` — fallback 2 (1.5 gen, stable free tier)