zhiqiulin commited on
Commit
db4a96c
1 Parent(s): ef893ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -25
app.py CHANGED
@@ -73,22 +73,22 @@ example_prompt0 = "Two dogs of different breeds playfully chasing around a tree"
73
  example_prompt1 = "Two dogs of the same breed playing on the grass"
74
  ###
75
 
76
- # Create the first demo
77
- demo_vqascore = gr.Interface(
78
- fn=generate, # function to call
79
- inputs=[
80
- gr.Dropdown(["clip-flant5-xl", "clip-flant5-xxl"], label="Model Name"),
81
- gr.Image(type="filepath"),
82
- gr.Textbox(label="Prompt")
83
- ], # define the types of inputs
84
- examples=[
85
- ["clip-flant5-xl", example_imgs[0], example_prompt0],
86
- ["clip-flant5-xl", example_imgs[0], example_prompt1],
87
- ],
88
- outputs="number", # define the type of output
89
- title="VQAScore", # title of the app
90
- description="This model evaluates the similarity between an image and a text prompt."
91
- )
92
 
93
  # # Create the second demo
94
  # demo_vqascore_ranking = gr.Interface(
@@ -116,7 +116,7 @@ def load_example(model_name, images, prompt):
116
  # Create the second demo
117
  with gr.Blocks() as demo_vqascore_ranking:
118
  gr.Markdown("# VQAScore Ranking\nThis model ranks a gallery of images based on their similarity to a text prompt.")
119
- model_dropdown = gr.Dropdown(["clip-flant5-xl", "clip-flant5-xxl"], label="Model Name")
120
  gallery = gr.Gallery(label="Generated Images", elem_id="input-gallery", columns=4, allow_preview=True)
121
  prompt = gr.Textbox(label="Prompt")
122
  rank_button = gr.Button("Rank Images")
@@ -128,19 +128,21 @@ with gr.Blocks() as demo_vqascore_ranking:
128
  example1_button = gr.Button("Load Example 1")
129
  example2_button = gr.Button("Load Example 2")
130
 
131
- example1_button.click(fn=lambda: load_example("clip-flant5-xl", example_imgs, example_prompt0), inputs=[], outputs=[model_dropdown, gallery, prompt])
132
- example2_button.click(fn=lambda: load_example("clip-flant5-xl", example_imgs, example_prompt1), inputs=[], outputs=[model_dropdown, gallery, prompt])
133
 
134
  # Layout to allow user to input their own data
135
  with gr.Row():
136
  gr.Column([model_dropdown, gallery, prompt, rank_button])
137
  gr.Column([example1_button, example2_button])
138
 
139
-
 
 
140
 
141
- # Combine the demos into a tabbed interface
142
- tabbed_interface = gr.TabbedInterface([demo_vqascore, demo_vqascore_ranking], ["VQAScore", "VQAScore Ranking"])
143
 
144
- # Launch the tabbed interface
145
- tabbed_interface.queue()
146
- tabbed_interface.launch(share=False)
 
73
  example_prompt1 = "Two dogs of the same breed playing on the grass"
74
  ###
75
 
76
+ # # Create the first demo
77
+ # demo_vqascore = gr.Interface(
78
+ # fn=generate, # function to call
79
+ # inputs=[
80
+ # gr.Dropdown(["clip-flant5-xxl", "clip-flant5-xl", ], label="Model Name"),
81
+ # gr.Image(type="filepath"),
82
+ # gr.Textbox(label="Prompt")
83
+ # ], # define the types of inputs
84
+ # examples=[
85
+ # ["clip-flant5-xl", example_imgs[0], example_prompt0],
86
+ # ["clip-flant5-xl", example_imgs[0], example_prompt1],
87
+ # ],
88
+ # outputs="number", # define the type of output
89
+ # title="VQAScore", # title of the app
90
+ # description="This model evaluates the similarity between an image and a text prompt."
91
+ # )
92
 
93
  # # Create the second demo
94
  # demo_vqascore_ranking = gr.Interface(
 
116
  # Create the second demo
117
  with gr.Blocks() as demo_vqascore_ranking:
118
  gr.Markdown("# VQAScore Ranking\nThis model ranks a gallery of images based on their similarity to a text prompt.")
119
+ model_dropdown = gr.Dropdown(["clip-flant5-xxl", "clip-flant5-xl"], label="Model Name")
120
  gallery = gr.Gallery(label="Generated Images", elem_id="input-gallery", columns=4, allow_preview=True)
121
  prompt = gr.Textbox(label="Prompt")
122
  rank_button = gr.Button("Rank Images")
 
128
  example1_button = gr.Button("Load Example 1")
129
  example2_button = gr.Button("Load Example 2")
130
 
131
+ example1_button.click(fn=lambda: load_example("clip-flant5-xxl", example_imgs, example_prompt0), inputs=[], outputs=[model_dropdown, gallery, prompt])
132
+ example2_button.click(fn=lambda: load_example("clip-flant5-xxl", example_imgs, example_prompt1), inputs=[], outputs=[model_dropdown, gallery, prompt])
133
 
134
  # Layout to allow user to input their own data
135
  with gr.Row():
136
  gr.Column([model_dropdown, gallery, prompt, rank_button])
137
  gr.Column([example1_button, example2_button])
138
 
139
+ # Launch the interface
140
+ demo_vqascore_ranking.queue()
141
+ demo_vqascore_ranking.launch(share=False)
142
 
143
+ # # Combine the demos into a tabbed interface
144
+ # tabbed_interface = gr.TabbedInterface([demo_vqascore, demo_vqascore_ranking], ["VQAScore", "VQAScore Ranking"])
145
 
146
+ # # Launch the tabbed interface
147
+ # tabbed_interface.queue()
148
+ # tabbed_interface.launch(share=False)