upgrade Gradio and restore predict API route
Browse filesBump the Space to Gradio 6.9 so custom POST endpoints are supported again, wire the JSON predict route through gr.api.post, and update the demo client to use the generated /post/predict path.
Made-with: Cursor
- README.md +1 -1
- app.py +8 -1
- requirements.txt +1 -1
- test_demo/run.mjs +1 -1
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 📉
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
python_version: 3.10.13
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.9.0
|
| 8 |
python_version: 3.10.13
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
app.py
CHANGED
|
@@ -385,5 +385,12 @@ with gr.Blocks(title="Orient-Anything-V2 Demo") as demo:
|
|
| 385 |
postprocess=True
|
| 386 |
)
|
| 387 |
|
| 388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
demo.launch(show_api=False)
|
|
|
|
| 385 |
postprocess=True
|
| 386 |
)
|
| 387 |
|
| 388 |
+
@gr.api.post("/predict")
|
| 389 |
+
async def predict_api(
|
| 390 |
+
image_ref: UploadFile = File(...),
|
| 391 |
+
image_tgt: UploadFile | None = File(None),
|
| 392 |
+
do_rm_bkg: bool = Form(True),
|
| 393 |
+
) -> dict[str, float | int]:
|
| 394 |
+
return await predict(image_ref, image_tgt, do_rm_bkg)
|
| 395 |
+
|
| 396 |
demo.launch(show_api=False)
|
requirements.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
matplotlib
|
| 4 |
pydantic>=2.11,<2.12
|
| 5 |
-
gradio==
|
| 6 |
onnxruntime
|
| 7 |
rembg
|
| 8 |
accelerate==1.8.1
|
|
|
|
| 2 |
|
| 3 |
matplotlib
|
| 4 |
pydantic>=2.11,<2.12
|
| 5 |
+
gradio==6.9.0
|
| 6 |
onnxruntime
|
| 7 |
rembg
|
| 8 |
accelerate==1.8.1
|
test_demo/run.mjs
CHANGED
|
@@ -10,7 +10,7 @@ const outputDir = join(scriptDir, "outputs");
|
|
| 10 |
|
| 11 |
const apiUrl =
|
| 12 |
process.env.ORIENT_ANYTHING_API_URL ??
|
| 13 |
-
"https://choephix-orient-anything-v2.hf.space/predict";
|
| 14 |
const removeBackground = (process.env.ORIENT_ANYTHING_REMOVE_BG ?? "true") !== "false";
|
| 15 |
|
| 16 |
const mimeTypes = {
|
|
|
|
| 10 |
|
| 11 |
const apiUrl =
|
| 12 |
process.env.ORIENT_ANYTHING_API_URL ??
|
| 13 |
+
"https://choephix-orient-anything-v2.hf.space/post/predict";
|
| 14 |
const removeBackground = (process.env.ORIENT_ANYTHING_REMOVE_BG ?? "true") !== "false";
|
| 15 |
|
| 16 |
const mimeTypes = {
|