Jyothirmai commited on
Commit
75d178b
1 Parent(s): 37335e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -13
app.py CHANGED
@@ -1,22 +1,19 @@
1
  import gradio as gr
2
  from PIL import Image
3
  import clipGPT
 
4
  import skimage.io as io
5
  import PIL.Image
6
 
7
- # Define model loading functions (if needed)
8
- def load_model_1(): # CLIP-GPT2
9
- # Load model components here if necessary
10
- return None
11
-
12
- # ... load_model_2(), load_model_3() - Define if and when needed
13
 
14
  # Caption generation functions
15
  def generate_caption_clipgpt(image):
16
  caption = clipGPT.generate_caption_clipgpt(image)
17
  return caption
18
 
19
- # ... Add more caption generation functions for future models
 
 
20
 
21
  # Sample image paths
22
  sample_images = [
@@ -27,15 +24,12 @@ sample_images = [
27
  "CXR195_IM-0618-1001.png"
28
  ]
29
 
30
- def load_image(path):
31
- return Image.open(path)
32
-
33
  # Gradio interface
34
  with gr.Blocks() as demo:
35
  with gr.Row():
36
  image = gr.Image(label="Upload Chest X-ray")
37
  sample_images_gallery = gr.Gallery(
38
- [load_image(path) for path in sample_images],
39
  label="Sample Images",
40
  )
41
  with gr.Row():
@@ -45,9 +39,9 @@ with gr.Blocks() as demo:
45
 
46
  def predict(img, model_name):
47
  if model_name == "CLIP-GPT2":
48
- print(img)
49
  return generate_caption_clipgpt(img)
50
- # Add elif blocks for "ViT-GPT2", "ViT-CoAttention" as you implement them
 
51
  else:
52
  return "Caption generation for this model is not yet implemented."
53
 
 
1
  import gradio as gr
2
  from PIL import Image
3
  import clipGPT
4
+ import vitGPT
5
  import skimage.io as io
6
  import PIL.Image
7
 
 
 
 
 
 
 
8
 
9
  # Caption generation functions
10
  def generate_caption_clipgpt(image):
11
  caption = clipGPT.generate_caption_clipgpt(image)
12
  return caption
13
 
14
+ def generate_caption_vitgpt(image):
15
+ caption = vitGPT.generate_caption(image)
16
+ return caption
17
 
18
  # Sample image paths
19
  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():
 
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