patrickvonplaten
commited on
Commit
•
1a07b97
1
Parent(s):
bb0ddd0
Update app.py
Browse files
app.py
CHANGED
@@ -132,13 +132,13 @@ def process(dataframe, row_number=0):
|
|
132 |
submission_names[dataframe.iloc[row_number][f"choice_{i}"]]
|
133 |
for i in range(len(SUBMISSIONS))
|
134 |
]
|
135 |
-
images =
|
136 |
|
137 |
prompt = SUBMISSIONS[choices[0]][int(image_id)]["Prompt"]
|
138 |
prompt = PROMPT_FORMAT.format(prompt)
|
139 |
counter = f"{row_number + 1}/{NUM_QUESTIONS}"
|
140 |
|
141 |
-
return images, prompt, counter
|
142 |
|
143 |
|
144 |
def write_result(user_choice, row_number, dataframe):
|
@@ -193,7 +193,7 @@ EXPLANATION = """\n\n
|
|
193 |
1. Click on 'Start'
|
194 |
2. A prompt and 4 different images are displayed
|
195 |
3. Select your favorite image
|
196 |
-
4. Click on '
|
197 |
5. After 10 rounds your favorite diffusion model is displayed
|
198 |
"""
|
199 |
|
@@ -240,7 +240,19 @@ with gr.Blocks() as demo:
|
|
240 |
gallery = gr.Gallery(
|
241 |
label="All images", show_label=False, elem_id="gallery"
|
242 |
).style(columns=GALLERY_COLUMN_NUM, object_fit="contain", preview=True)
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
with gr.Column(visible=False):
|
246 |
selected_image = gr.Number(label="Selected index", value=-1, precision=0)
|
@@ -259,7 +271,7 @@ with gr.Blocks() as demo:
|
|
259 |
inputs=[row_number, dataframe],
|
260 |
outputs=[intro_view, result_view, gallery_view, result]
|
261 |
).then(
|
262 |
-
fn=process, inputs=[dataframe], outputs=[
|
263 |
)
|
264 |
|
265 |
gallery.select(
|
@@ -279,7 +291,7 @@ with gr.Blocks() as demo:
|
|
279 |
).then(
|
280 |
fn=process,
|
281 |
inputs=[dataframe, row_number],
|
282 |
-
outputs=[
|
283 |
).then(
|
284 |
fn=lambda x: 0 if x == NUM_QUESTIONS else x,
|
285 |
inputs=[row_number],
|
|
|
132 |
submission_names[dataframe.iloc[row_number][f"choice_{i}"]]
|
133 |
for i in range(len(SUBMISSIONS))
|
134 |
]
|
135 |
+
images = (SUBMISSIONS[c][int(image_id)]["images"] for c in choices)
|
136 |
|
137 |
prompt = SUBMISSIONS[choices[0]][int(image_id)]["Prompt"]
|
138 |
prompt = PROMPT_FORMAT.format(prompt)
|
139 |
counter = f"{row_number + 1}/{NUM_QUESTIONS}"
|
140 |
|
141 |
+
return *images, prompt, counter
|
142 |
|
143 |
|
144 |
def write_result(user_choice, row_number, dataframe):
|
|
|
193 |
1. Click on 'Start'
|
194 |
2. A prompt and 4 different images are displayed
|
195 |
3. Select your favorite image
|
196 |
+
4. Click on 'Confirm'
|
197 |
5. After 10 rounds your favorite diffusion model is displayed
|
198 |
"""
|
199 |
|
|
|
240 |
gallery = gr.Gallery(
|
241 |
label="All images", show_label=False, elem_id="gallery"
|
242 |
).style(columns=GALLERY_COLUMN_NUM, object_fit="contain", preview=True)
|
243 |
+
with gr.Blocks():
|
244 |
+
with gr.Row() as images:
|
245 |
+
image_1 = gr.Image(interactive=False)
|
246 |
+
image_2 = gr.Image(interactive=False)
|
247 |
+
image_3 = gr.Image(interactive=False)
|
248 |
+
image_4 = gr.Image(interactive=False)
|
249 |
+
with gr.Row():
|
250 |
+
image1_button = gr.Button("1").style(full_width=False)
|
251 |
+
image2_button = gr.Button("2").style(full_width=False)
|
252 |
+
image3_button = gr.Button("3").style(full_width=False)
|
253 |
+
image4_button = gr.Button("4").style(full_width=False)
|
254 |
+
|
255 |
+
next_button = gr.Button("Confirm").style(full_width=True)
|
256 |
|
257 |
with gr.Column(visible=False):
|
258 |
selected_image = gr.Number(label="Selected index", value=-1, precision=0)
|
|
|
271 |
inputs=[row_number, dataframe],
|
272 |
outputs=[intro_view, result_view, gallery_view, result]
|
273 |
).then(
|
274 |
+
fn=process, inputs=[dataframe], outputs=[image_1, image_2, image_3, image_4, prompt, counter]
|
275 |
)
|
276 |
|
277 |
gallery.select(
|
|
|
291 |
).then(
|
292 |
fn=process,
|
293 |
inputs=[dataframe, row_number],
|
294 |
+
outputs=[image_1, image_2, image_3, image_4, prompt, counter]
|
295 |
).then(
|
296 |
fn=lambda x: 0 if x == NUM_QUESTIONS else x,
|
297 |
inputs=[row_number],
|