zhiqiulin commited on
Commit
748aa2b
·
verified ·
1 Parent(s): 7b21cbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -18
app.py CHANGED
@@ -113,28 +113,61 @@ example_prompt1 = "Two dogs of the same breed playing on the grass"
113
  def load_example(model_name, images, prompt):
114
  return model_name, images, prompt
115
 
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"], value="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")
123
- ranked_gallery = gr.Gallery(label="Ranked Images with Scores", elem_id="ranked-gallery", columns=4, allow_preview=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
- rank_button.click(fn=rank_images, inputs=[model_dropdown, gallery, prompt], outputs=ranked_gallery)
126
 
127
- # Custom example buttons
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()
 
113
  def load_example(model_name, images, prompt):
114
  return model_name, images, prompt
115
 
116
+
117
+ demo_vqascore_ranking = gr.Interface(
118
+ fn=rank_images, # function to call
119
+ inputs=[
120
+ gr.Dropdown(["clip-flant5-xxl", "clip-flant5-xl"], label="Model Name"),
121
+ gr.Gallery(label="Generated Images", elem_id="input-gallery", columns=4, allow_preview=True),
122
+ gr.Textbox(label="Prompt")
123
+ ], # define the types of inputs
124
+ examples=[
125
+ ["clip-flant5-xxl", example_imgs, example_prompt0],
126
+ ["clip-flant5-xxl", example_imgs, example_prompt1],
127
+ ],
128
+ outputs=gr.Gallery(label="Ranked Images with Scores", elem_id="ranked-gallery", columns=4, allow_preview=True), # define the type of output
129
+ title="VQAScore Ranking", # title of the app
130
+ description="This model ranks a gallery of images based on their similarity to a text prompt."
131
+ )
132
+
133
+ # demo_vqascore = gr.Interface(
134
+ # fn=generate, # function to call
135
+ # inputs=[
136
+ # gr.Dropdown(["clip-flant5-xxl", "clip-flant5-xl", ], label="Model Name"),
137
+ # gr.Image(type="filepath"),
138
+ # gr.Textbox(label="Prompt")
139
+ # ], # define the types of inputs
140
+ # examples=[
141
+ # ["clip-flant5-xl", example_imgs[0], example_prompt0],
142
+ # ["clip-flant5-xl", example_imgs[0], example_prompt1],
143
+ # ],
144
+ # outputs="number", # define the type of output
145
+ # title="VQAScore", # title of the app
146
+ # description="This model evaluates the similarity between an image and a text prompt."
147
+ # )
148
+
149
+ # # Create the second demo
150
+ # with gr.Blocks() as demo_vqascore_ranking:
151
+ # gr.Markdown("# VQAScore Ranking\nThis model ranks a gallery of images based on their similarity to a text prompt.")
152
+ # model_dropdown = gr.Dropdown(["clip-flant5-xxl", "clip-flant5-xl"], value="clip-flant5-xxl", label="Model Name")
153
+ # gallery = gr.Gallery(label="Generated Images", elem_id="input-gallery", columns=4, allow_preview=True)
154
+ # prompt = gr.Textbox(label="Prompt")
155
+ # rank_button = gr.Button("Rank Images")
156
+ # ranked_gallery = gr.Gallery(label="Ranked Images with Scores", elem_id="ranked-gallery", columns=4, allow_preview=True)
157
 
158
+ # rank_button.click(fn=rank_images, inputs=[model_dropdown, gallery, prompt], outputs=ranked_gallery)
159
 
160
+ # # Custom example buttons
161
+ # example1_button = gr.Button("Load Example 1")
162
+ # example2_button = gr.Button("Load Example 2")
163
 
164
+ # example1_button.click(fn=lambda: load_example("clip-flant5-xxl", example_imgs, example_prompt0), inputs=[], outputs=[model_dropdown, gallery, prompt])
165
+ # example2_button.click(fn=lambda: load_example("clip-flant5-xxl", example_imgs, example_prompt1), inputs=[], outputs=[model_dropdown, gallery, prompt])
166
 
167
+ # # Layout to allow user to input their own data
168
+ # with gr.Row():
169
+ # gr.Column([model_dropdown, gallery, prompt, rank_button])
170
+ # gr.Column([example1_button, example2_button])
171
 
172
  # Launch the interface
173
  demo_vqascore_ranking.queue()