Views
No views yet
HF Wrapper
│
├─1─▶ GET /upload-url (get presigned S3 URL)
│
├─2─▶ PUT image directly to S3 (free, bypasses API Gateway)
│
├─3─▶ POST /detect {"job_id", "s3_url"} (tiny payload)
│
└─4─▶ GET /status/{job_id} (poll until complete)1// HTTP URL
2{"inputs": "https://example.com/image.jpg"}
3
4// Data URL (base64 encoded)
5{"inputs": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."}
6
7// Raw base64
8{"inputs": "iVBORw0KGgoAAAANSUhEUgAAAAUA..."}1{
2 "predictions": [
3 {
4 "id": 1,
5 "label": "callout",
6 "class_id": 0,
7 "confidence": 0.95,
8 "bbox": {
9 "x1": 100,
10 "y1": 200,
11 "x2": 300,
12 "y2": 400
13 }
14 }
15 ],
16 "total_detections": 1,
17 "image": "base64_encoded_image",
18 "image_width": 1920,
19 "image_height": 1080
20}[x, y, width, height] (xywh format){"x1", "y1", "x2", "y2"} (xyxy format)| Secret | Description |
|---|---|
API_GATEWAY_URL | Full URL of the API Gateway endpoint (e.g., https://xxx.execute-api.us-east-1.amazonaws.com/dev) |
API_KEY | API key for authentication |
1import requests
2
3HF_ENDPOINT = "https://your-endpoint.endpoints.huggingface.cloud"
4HF_TOKEN = "your-hf-token"
5
6response = requests.post(
7 HF_ENDPOINT,
8 headers={"Authorization": f"Bearer {HF_TOKEN}"},
9 json={"inputs": "https://example.com/architectural-drawing.png"}
10)
11
12result = response.json()
13print(f"Found {result['total_detections']} callouts")
14for pred in result["predictions"]:
15 print(f" Callout {pred['id']}: {pred['bbox']}, confidence={pred['confidence']}")1curl -X POST https://your-endpoint.endpoints.huggingface.cloud \
2 -H "Authorization: Bearer $HF_TOKEN" \
3 -H "Content-Type: application/json" \
4 -d '{"inputs": "https://example.com/architectural-drawing.png"}'1{
2 "error": "Description of the error",
3 "predictions": [],
4 "total_detections": 0,
5 "image": ""
6}