Spaces:
Sleeping
Sleeping
File size: 4,145 Bytes
13ecf41 2425630 13ecf41 2425630 13ecf41 2425630 cd6bb91 2425630 cd6bb91 2425630 cd6bb91 7c1f084 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | ---
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": "<base64-string>" },
{ "label": "front_right", "image_base64": "<base64-string>" },
{ "label": "rear_left", "image_base64": "<base64-string>" },
{ "label": "rear_right", "image_base64": "<base64-string>" },
{ "label": "inside", "image_base64": "<base64-string>" },
{ "label": "door", "image_base64": "<base64-string>" }
]
}
```
**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) |