malanafghan commited on
Commit
e3e881d
·
verified ·
1 Parent(s): 584f79b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import gradio as gr
2
  import torch
3
- gr.HTML('<div style="text-align: center; margin-bottom: 20px;"><img src="insightray_icon.svg" width="100" style="display: inline-block;"/></div>')
4
  from PIL import Image
5
  import torch.nn.functional as F
6
  from monai.networks.nets import DenseNet121
@@ -85,14 +84,21 @@ def predict(image_input, modality):
85
  generic_report = get_generic_report(body_part, conf_body_percent)
86
  return f"**Selected modality:** {modality}\n{generic_report}"
87
 
88
- gr.Interface(
89
- fn=predict,
90
- inputs=[
91
- gr.Image(type="pil", label="Upload Medical Image"),
92
- gr.Radio(choices=["Chest X‑ray", "Head CT", "Hand X‑ray", "Abdomen CT", "Breast MRI", "Chest CT"],
93
- label="Select Modality", value="Chest X‑ray")
94
- ],
95
- outputs="text",
96
- title="InsightRay Multi‑Modality Medical AI",
97
- description="Choose the image type and upload."
98
- ).launch()
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import torch
 
3
  from PIL import Image
4
  import torch.nn.functional as F
5
  from monai.networks.nets import DenseNet121
 
84
  generic_report = get_generic_report(body_part, conf_body_percent)
85
  return f"**Selected modality:** {modality}\n{generic_report}"
86
 
87
+ # ---------- Gradio interface with logo using Blocks ----------
88
+ with gr.Blocks(title="InsightRay – Multi‑Modality Medical AI") as demo:
89
+ gr.HTML('<div style="text-align: center; margin-bottom: 20px;"><img src="insightray_icon.svg" width="100" style="display: inline-block;"/></div>')
90
+ gr.Markdown("## InsightRay – Multi‑Modality Medical AI")
91
+ gr.Markdown("Choose the image type and upload a medical image. For chest X‑ray and head CT, detailed AI reports are generated.")
92
+
93
+ with gr.Row():
94
+ with gr.Column():
95
+ image_input = gr.Image(type="pil", label="Upload Medical Image")
96
+ modality = gr.Radio(choices=["Chest X‑ray", "Head CT", "Hand X‑ray", "Abdomen CT", "Breast MRI", "Chest CT"],
97
+ label="Select Modality", value="Chest X‑ray")
98
+ submit_btn = gr.Button("Analyse")
99
+ with gr.Column():
100
+ output = gr.Textbox(label="AI Report", lines=20)
101
+
102
+ submit_btn.click(fn=predict, inputs=[image_input, modality], outputs=output)
103
+
104
+ demo.launch()