tan200224 commited on
Commit
47d255f
·
verified ·
1 Parent(s): f8d2c9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
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 will automatically convert the PIL image to base64 for API responses.
13
  """
14
- result = service.generate_image(mask_image)
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
- allow_flagging="never"
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, # No public Gradio share link needed; Hugging Face provides the endpoint
33
- enable_queue=True, # Enable queuing for model inference
34
- show_error=True, # Show errors in the Hugging Face Space logs
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_