Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -7,12 +7,8 @@ import sys
|
|
| 7 |
ROOT = Path(__file__).resolve().parent
|
| 8 |
sys.path.insert(0, str(ROOT))
|
| 9 |
|
| 10 |
-
from fastapi import FastAPI
|
| 11 |
-
from fastapi.staticfiles import StaticFiles
|
| 12 |
-
from fastapi.responses import FileResponse
|
| 13 |
-
from PIL import Image
|
| 14 |
import gradio as gr
|
| 15 |
-
import
|
| 16 |
|
| 17 |
# 1. Direct @spaces.GPU function bound to Gradio Interface
|
| 18 |
@spaces.GPU
|
|
@@ -46,24 +42,9 @@ demo = gr.Interface(
|
|
| 46 |
gr.Image(type="pil", label="Binary Predicted Mask (Threshold 0.50)")
|
| 47 |
],
|
| 48 |
title="🩺 DFU Live Segmentation System — Stage 16 Certified Candidate",
|
| 49 |
-
description="Live Diabetic Foot Ulcer Segmentation Platform.
|
| 50 |
examples=examples if examples else None
|
| 51 |
)
|
| 52 |
|
| 53 |
-
# 4. Import FastAPI application (after spaces is initialized)
|
| 54 |
-
from app.main import app as fastapi_app
|
| 55 |
-
|
| 56 |
-
# 5. Mount Next.js static assets
|
| 57 |
-
static_dir = ROOT / "static"
|
| 58 |
-
if static_dir.exists():
|
| 59 |
-
fastapi_app.mount("/_next", StaticFiles(directory=str(static_dir / "_next")), name="next_assets")
|
| 60 |
-
|
| 61 |
-
@fastapi_app.get("/ui")
|
| 62 |
-
async def serve_ui():
|
| 63 |
-
return FileResponse(static_dir / "index.html")
|
| 64 |
-
|
| 65 |
-
# 6. Mount Gradio directly at root '/'
|
| 66 |
-
app = gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 67 |
-
|
| 68 |
if __name__ == "__main__":
|
| 69 |
-
|
|
|
|
| 7 |
ROOT = Path(__file__).resolve().parent
|
| 8 |
sys.path.insert(0, str(ROOT))
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
import gradio as gr
|
| 11 |
+
from PIL import Image
|
| 12 |
|
| 13 |
# 1. Direct @spaces.GPU function bound to Gradio Interface
|
| 14 |
@spaces.GPU
|
|
|
|
| 42 |
gr.Image(type="pil", label="Binary Predicted Mask (Threshold 0.50)")
|
| 43 |
],
|
| 44 |
title="🩺 DFU Live Segmentation System — Stage 16 Certified Candidate",
|
| 45 |
+
description="Live Diabetic Foot Ulcer Segmentation Platform. Running Stage 16 Certified Boundary-only U-Net ($0.50$ frozen threshold).",
|
| 46 |
examples=examples if examples else None
|
| 47 |
)
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
if __name__ == "__main__":
|
| 50 |
+
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
|