Spaces:
Runtime error
Runtime error
Kottu
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,29 +24,29 @@ sample_images = [
|
|
| 24 |
"CXR195_IM-0618-1001.png"
|
| 25 |
]
|
| 26 |
|
| 27 |
-
# Gradio interface
|
| 28 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
| 29 |
with gr.Row():
|
| 30 |
-
image = gr.Image(label="Upload Chest X-ray")
|
| 31 |
sample_images_gallery = gr.Gallery(
|
| 32 |
-
sample_images,
|
| 33 |
label="Sample Images",
|
| 34 |
-
)
|
| 35 |
-
with gr.Row():
|
| 36 |
-
model_choice = gr.Radio(["CLIP-GPT2", "ViT-GPT2", "ViT-CoAttention"], label="Select Model")
|
| 37 |
with gr.Row():
|
| 38 |
-
|
|
|
|
|
|
|
| 39 |
|
| 40 |
def predict(img, model_name):
|
| 41 |
if model_name == "CLIP-GPT2":
|
| 42 |
-
return generate_caption_clipgpt(img)
|
| 43 |
-
# elif model_name == "ViT-GPT2":
|
| 44 |
-
# return generate_caption_vitgpt(img)
|
| 45 |
else:
|
| 46 |
return "Caption generation for this model is not yet implemented."
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
|
| 52 |
demo.launch()
|
|
|
|
| 24 |
"CXR195_IM-0618-1001.png"
|
| 25 |
]
|
| 26 |
|
|
|
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
+
gr.HTML("<h1 style='text-align: center;'>MedViT: A Vision Transformer-Driven Method for Generating Medical Reports 🏥🤖</h1>")
|
| 29 |
+
gr.HTML("<p style='text-align: center;'>You can generate captions by uploading an X-Ray and selecting a model of your choice below</p>")
|
| 30 |
+
|
| 31 |
with gr.Row():
|
| 32 |
+
image = gr.Image(label="Upload Chest X-ray")
|
| 33 |
sample_images_gallery = gr.Gallery(
|
| 34 |
+
sample_images,
|
| 35 |
label="Sample Images",
|
| 36 |
+
)
|
|
|
|
|
|
|
| 37 |
with gr.Row():
|
| 38 |
+
model_choice = gr.Radio(["CLIP-GPT2", "ViT-GPT2", "ViT-CoAttention"], label="Select Model")
|
| 39 |
+
generate_button = gr.Button("Generate Caption")
|
| 40 |
+
caption = gr.Textbox(label="Generated Caption")
|
| 41 |
|
| 42 |
def predict(img, model_name):
|
| 43 |
if model_name == "CLIP-GPT2":
|
| 44 |
+
return generate_caption_clipgpt(img)
|
|
|
|
|
|
|
| 45 |
else:
|
| 46 |
return "Caption generation for this model is not yet implemented."
|
| 47 |
|
| 48 |
+
generate_button.click(predict, [image, model_choice], caption) # Trigger prediction on button click
|
| 49 |
+
sample_images_gallery.change(predict, [sample_images_gallery, model_choice], caption) # Handle sample images
|
| 50 |
+
|
| 51 |
|
| 52 |
demo.launch()
|