Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -109,8 +109,36 @@ demo_vqascore_ranking = gr.Interface(
|
|
109 |
allow_flagging='never'
|
110 |
)
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
# Combine the demos into a tabbed interface
|
113 |
-
tabbed_interface = gr.TabbedInterface([demo_vqascore, demo_vqascore_ranking], ["VQAScore", "VQAScore Ranking"])
|
114 |
|
115 |
# Launch the tabbed interface
|
116 |
tabbed_interface.queue()
|
|
|
109 |
allow_flagging='never'
|
110 |
)
|
111 |
|
112 |
+
# Custom component for loading examples
|
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_beta:
|
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")
|
121 |
+
prompt = gr.Textbox(label="Prompt")
|
122 |
+
rank_button = gr.Button("Rank Images")
|
123 |
+
ranked_gallery = gr.Gallery(label="Ranked Images with Scores")
|
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-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 |
# Combine the demos into a tabbed interface
|
141 |
+
tabbed_interface = gr.TabbedInterface([demo_vqascore, demo_vqascore_ranking, demo_vqascore_ranking_beta], ["VQAScore", "VQAScore Ranking"])
|
142 |
|
143 |
# Launch the tabbed interface
|
144 |
tabbed_interface.queue()
|