Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,10 +9,9 @@ service = HFDiffusionService()
|
|
| 9 |
def generate_ct(mask_image: Image.Image):
|
| 10 |
"""
|
| 11 |
Takes a PIL image mask and returns a generated CT scan (PIL Image).
|
| 12 |
-
Gradio
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
-
return result
|
| 16 |
|
| 17 |
# Create a Gradio interface for your Space
|
| 18 |
demo = gr.Interface(
|
|
@@ -21,7 +20,7 @@ demo = gr.Interface(
|
|
| 21 |
outputs=gr.Image(type="pil", label="Generated CT Scan"),
|
| 22 |
title="Conditional Diffusion Medical Image Generator",
|
| 23 |
description="Draw or upload a mask to generate a synthetic CT scan using the conditional diffusion model.",
|
| 24 |
-
|
| 25 |
)
|
| 26 |
|
| 27 |
# Launch the Gradio app with API mode (no SSR)
|
|
@@ -29,8 +28,6 @@ if __name__ == "__main__":
|
|
| 29 |
demo.launch(
|
| 30 |
server_name="0.0.0.0",
|
| 31 |
server_port=7860,
|
| 32 |
-
share=False,
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
ssr_mode=False # ✅ Force classic Gradio mode to expose /api/predict/
|
| 36 |
-
)
|
|
|
|
| 9 |
def generate_ct(mask_image: Image.Image):
|
| 10 |
"""
|
| 11 |
Takes a PIL image mask and returns a generated CT scan (PIL Image).
|
| 12 |
+
Gradio automatically converts the PIL image to base64 for API responses.
|
| 13 |
"""
|
| 14 |
+
return service.generate_image(mask_image)
|
|
|
|
| 15 |
|
| 16 |
# Create a Gradio interface for your Space
|
| 17 |
demo = gr.Interface(
|
|
|
|
| 20 |
outputs=gr.Image(type="pil", label="Generated CT Scan"),
|
| 21 |
title="Conditional Diffusion Medical Image Generator",
|
| 22 |
description="Draw or upload a mask to generate a synthetic CT scan using the conditional diffusion model.",
|
| 23 |
+
flagging_mode="never" # ✅ Updated to new syntax
|
| 24 |
)
|
| 25 |
|
| 26 |
# Launch the Gradio app with API mode (no SSR)
|
|
|
|
| 28 |
demo.launch(
|
| 29 |
server_name="0.0.0.0",
|
| 30 |
server_port=7860,
|
| 31 |
+
share=False, # Hugging Face provides the endpoint
|
| 32 |
+
show_error=True,
|
| 33 |
+
ssr_mode=False_
|
|
|
|
|
|