Spaces:
Running
on
T4
Running
on
T4
Commit
·
ff3e3e4
1
Parent(s):
bf3f725
feat(download): make /download public; docs: add HTTP_API_Documentation.txt
Browse files- HTTP_API_Documentation.txt +49 -0
- api/main.py +1 -1
HTTP_API_Documentation.txt
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
HTTP API Documentation
|
| 2 |
+
|
| 3 |
+
- Base URL: https://logicgoinfotechspaces-object-remover.hf.space
|
| 4 |
+
- Auth (optional): set API_TOKEN on server; send Authorization: Bearer <API_TOKEN>
|
| 5 |
+
|
| 6 |
+
Endpoints
|
| 7 |
+
- GET /health
|
| 8 |
+
- POST /upload-image (form-data: image=file) -> {"id":"<image_id>","filename":"..."}
|
| 9 |
+
- POST /upload-mask (form-data: mask=file) -> {"id":"<mask_id>","filename":"..."}
|
| 10 |
+
- POST /inpaint (JSON: { "image_id": "...", "mask_id": "..." }) -> returns image/png directly
|
| 11 |
+
- POST /inpaint-multipart (form-data: image, mask) -> {"result":"output_xxx.png"}
|
| 12 |
+
- GET /download/{filename} (only needed if you have a filename)
|
| 13 |
+
|
| 14 |
+
Curl examples
|
| 15 |
+
|
| 16 |
+
Health:
|
| 17 |
+
curl -H "Authorization: Bearer <API_TOKEN>" https://logicgoinfotechspaces-object-remover.hf.space/health
|
| 18 |
+
|
| 19 |
+
Upload image:
|
| 20 |
+
curl -H "Authorization: Bearer <API_TOKEN>" \
|
| 21 |
+
-F image=@image.png \
|
| 22 |
+
https://logicgoinfotechspaces-object-remover.hf.space/upload-image
|
| 23 |
+
|
| 24 |
+
Upload mask (PNG recommended):
|
| 25 |
+
curl -H "Authorization: Bearer <API_TOKEN>" \
|
| 26 |
+
-F mask=@mask.png \
|
| 27 |
+
https://logicgoinfotechspaces-object-remover.hf.space/upload-mask
|
| 28 |
+
|
| 29 |
+
Inpaint (IDs) — returns image directly:
|
| 30 |
+
curl -H "Authorization: Bearer <API_TOKEN>" \
|
| 31 |
+
-H "Content-Type: application/json" \
|
| 32 |
+
-d '{"image_id":"<image_id>","mask_id":"<mask_id>"}' \
|
| 33 |
+
https://logicgoinfotechspaces-object-remover.hf.space/inpaint \
|
| 34 |
+
-o result.png
|
| 35 |
+
|
| 36 |
+
Inpaint (multipart) — returns filename:
|
| 37 |
+
curl -H "Authorization: Bearer <API_TOKEN>" \
|
| 38 |
+
-F image=@image.png \
|
| 39 |
+
-F mask=@mask.png \
|
| 40 |
+
https://logicgoinfotechspaces-object-remover.hf.space/inpaint-multipart
|
| 41 |
+
|
| 42 |
+
Download (only if you have a filename):
|
| 43 |
+
curl -H "Authorization: Bearer <API_TOKEN>" \
|
| 44 |
+
-L https://logicgoinfotechspaces-object-remover.hf.space/download/output_xxx.png \
|
| 45 |
+
-o result.png
|
| 46 |
+
|
| 47 |
+
Notes
|
| 48 |
+
- For masks: RGBA with alpha=0 = remove; otherwise any pixel > 0 = remove.
|
| 49 |
+
- 404 Not Found on /inpaint usually means the server restarted and IDs expired — re-upload to get fresh IDs.
|
api/main.py
CHANGED
|
@@ -169,7 +169,7 @@ def inpaint_multipart(
|
|
| 169 |
|
| 170 |
|
| 171 |
@app.get("/download/{filename}")
|
| 172 |
-
def download_file(filename: str
|
| 173 |
path = os.path.join(OUTPUT_DIR, filename)
|
| 174 |
if not os.path.isfile(path):
|
| 175 |
raise HTTPException(status_code=404, detail="file not found")
|
|
|
|
| 169 |
|
| 170 |
|
| 171 |
@app.get("/download/{filename}")
|
| 172 |
+
def download_file(filename: str):
|
| 173 |
path = os.path.join(OUTPUT_DIR, filename)
|
| 174 |
if not os.path.isfile(path):
|
| 175 |
raise HTTPException(status_code=404, detail="file not found")
|