Jyothirmai commited on
Commit
2139c81
β€’
1 Parent(s): 849c8db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -23
app.py CHANGED
@@ -37,20 +37,6 @@ with gr.Blocks() as demo:
37
  gr.HTML("<h1 style='text-align: center;'>MedViT: A Vision Transformer-Driven Method for Generating Medical Reports πŸ₯πŸ€–</h1>")
38
  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>")
39
 
40
-
41
- examples_list = [
42
- ['https://imgur.com/W1pIr9b', 'Caption for image 1'],
43
- ['https://imgur.com/MLJaWnf', 'Caption for image 2']
44
- ]
45
- examples = gr.Examples(examples_list,
46
- inputs="image",
47
- outputs=["image", "text"],
48
- label="Example Images",
49
- fn=render_image
50
- )
51
-
52
- image_table = gr.Dataframe(headers=['image', 'caption'], datatype=['html', 'str'])
53
-
54
 
55
  with gr.Row():
56
  model_choice = gr.Radio(["CLIP-GPT2", "ViT-GPT2", "ViT-CoAttention"], label="Select Model")
@@ -59,14 +45,6 @@ with gr.Blocks() as demo:
59
 
60
  caption = gr.Textbox(label="Generated Caption")
61
 
62
-
63
- # Function to populate table rows when an example image is clicked
64
- def populate_table_from_example(image_path, caption):
65
- new_row = [[render_image(image_path)], [caption]]
66
- image_table.append(new_row)
67
-
68
- examples.click(populate_table_from_example, inputs=examples, outputs=image_table)
69
-
70
 
71
  def predict(img, model_name):
72
  if model_name == "CLIP-GPT2":
@@ -81,7 +59,6 @@ with gr.Blocks() as demo:
81
 
82
  # Event handlers
83
  generate_button.click(predict, [image, model_choice], caption) # Trigger prediction on button click
84
- sample_images_gallery.change(predict, [sample_images_gallery, model_choice], caption) # Handle sample images
85
 
86
 
87
  demo.launch()
 
37
  gr.HTML("<h1 style='text-align: center;'>MedViT: A Vision Transformer-Driven Method for Generating Medical Reports πŸ₯πŸ€–</h1>")
38
  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>")
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  with gr.Row():
42
  model_choice = gr.Radio(["CLIP-GPT2", "ViT-GPT2", "ViT-CoAttention"], label="Select Model")
 
45
 
46
  caption = gr.Textbox(label="Generated Caption")
47
 
 
 
 
 
 
 
 
 
48
 
49
  def predict(img, model_name):
50
  if model_name == "CLIP-GPT2":
 
59
 
60
  # Event handlers
61
  generate_button.click(predict, [image, model_choice], caption) # Trigger prediction on button click
 
62
 
63
 
64
  demo.launch()