metadata
title: Remove Photo Object
emoji: ⚡
colorFrom: pink
colorTo: purple
sdk: docker
pinned: false
license: mit
hardware: cpu-basic
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Inpainting API (FastAPI)
- Auth: optional Bearer via env
API_TOKEN. If set, sendAuthorization: Bearer <token>.
Endpoints:
GET /health→ {"status":"healthy"}POST /upload-image(form-data: image=file) → {"id":"","filename":"name.png"}POST /upload-mask(form-data: mask=file) → {"id":"","filename":"mask.png"}POST /inpaint(JSON: {image_id, mask_id}) → {"result":"output_xxx.png"}POST /inpaint-url(JSON: {image_id, mask_id}) → {"result":"output_xxx.png","url":"https://.../download/output_xxx.png"}POST /inpaint-multipart(form-data: image=file, mask=file) → {"result":"output_xxx.png"}GET /download/{filename}→ image file (public; optional for ID-based inpaint)GET /result/{filename}→ view result image in browser (public)GET /logs→ recent uploads/results
Note:
POST /inpaintreturns simple JSON with just the filename.POST /inpaint-urlreturns JSON with filename and shareable URL.- Use
/download/{filename}or/result/{filename}to access the result image. - You can optionally pass a
promptstring with/inpaint,/inpaint-url, or/inpaint-multipartto describe what should be removed; the mask still controls the exact region.
Remote inference (Gemini / Imagen edit)
- Local processing is limited to mask prep and file IO; the heavy lifting is done via Google Gemini/Imagen edit API (CPU-only container is fine).
- Required env:
GEMINI_API_KEY(orGOOGLE_API_KEY/GOOGLE_GENAI_API_KEY). - Optional env:
GEMINI_IMAGE_EDIT_MODELto override the model id (default:imagen-3.0-edit-001).GEMINI_IMAGE_EDIT_PROMPTto override the default prompt: "Remove the objects marked by the provided mask and fill the background naturally."
- Uploaded images/masks are stored in MongoDB GridFS in the
object_removerdatabase (MONGO_URI/MONGODB_URIenv); IDs returned by/upload-imageand/upload-maskare fetched back from GridFS before calling Gemini.
Local run
- Install deps:
python3 -m pip install -r requirements.txt - Run API:
python3 -m uvicorn api.main:app --host 0.0.0.0 --port 7860