matsant01 commited on
Commit
56c5ad3
·
1 Parent(s): c61e1ad

Minor changes

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -131,7 +131,7 @@ def display_new_sample(state: dict, available_ids: list[str]):
131
 
132
  if not sample_data:
133
  return {
134
- prompt_display: gr.update(value="No more samples available. Thank you!"),
135
  input_bg_display: gr.update(value=None, visible=False),
136
  input_fg_display: gr.update(value=None, visible=False),
137
  output_a_display: gr.update(value=None, visible=False),
@@ -139,7 +139,7 @@ def display_new_sample(state: dict, available_ids: list[str]):
139
  choice_button_a: gr.update(visible=False),
140
  choice_button_b: gr.update(visible=False),
141
  next_button: gr.update(visible=False),
142
- status_display: gr.update(value="Completed!"),
143
  app_state: state,
144
  available_samples_state: remaining_ids
145
  }
@@ -159,7 +159,7 @@ def display_new_sample(state: dict, available_ids: list[str]):
159
  }
160
 
161
  return {
162
- prompt_display: gr.update(value=f"Prompt: {sample_data['prompt']}"),
163
  input_bg_display: gr.update(value=sample_data["input_bg"], visible=True),
164
  input_fg_display: gr.update(value=sample_data["input_fg"], visible=True),
165
  output_a_display: gr.update(value=output_a["path"], visible=True),
@@ -167,7 +167,7 @@ def display_new_sample(state: dict, available_ids: list[str]):
167
  choice_button_a: gr.update(visible=True, interactive=True),
168
  choice_button_b: gr.update(visible=True, interactive=True),
169
  next_button: gr.update(visible=False),
170
- status_display: gr.update(value="Please choose the image you prefer."),
171
  app_state: state,
172
  available_samples_state: remaining_ids
173
  }
@@ -189,7 +189,7 @@ def record_preference(choice: str, state: dict, request: gr.Request):
189
  choice_button_a: gr.update(interactive=False),
190
  choice_button_b: gr.update(interactive=False),
191
  next_button: gr.update(visible=True, interactive=True),
192
- status_display: gr.update(value="Error: Session state lost. Click Next Sample."),
193
  app_state: state
194
  }
195
 
@@ -227,7 +227,7 @@ def record_preference(choice: str, state: dict, request: gr.Request):
227
  choice_button_a: gr.update(interactive=False),
228
  choice_button_b: gr.update(interactive=False),
229
  next_button: gr.update(visible=True, interactive=True),
230
- status_display: gr.update(value=f"Error saving preference locally: {e}. Click Next."),
231
  app_state: state
232
  }
233
 
@@ -235,7 +235,7 @@ def record_preference(choice: str, state: dict, request: gr.Request):
235
  choice_button_a: gr.update(interactive=False),
236
  choice_button_b: gr.update(interactive=False),
237
  next_button: gr.update(visible=True, interactive=True),
238
- status_display: gr.update(value=f"Preference recorded (Chose {choice}). Click Next Sample."),
239
  app_state: state
240
  }
241
 
@@ -284,22 +284,28 @@ def handle_choice_b(state: dict, request: gr.Request):
284
  with gr.Blocks(title="Image Composition User Study") as demo:
285
  gr.Markdown("# Image Composition User Study")
286
  gr.Markdown(
287
- "Please look at the input images and the prompt below. "
288
  "Then, compare the two output images (Output A and Output B) and click the button below the one you prefer."
289
  )
290
 
291
  app_state = gr.State({})
292
  available_samples_state = gr.State(INITIAL_SAMPLE_IDS)
293
 
294
- prompt_display = gr.Textbox(label="Prompt", interactive=False)
295
- status_display = gr.Textbox(label="Status", value="Loading first sample...", interactive=False)
296
 
 
297
  with gr.Row():
298
- input_bg_display = gr.Image(label="Input Background", type="filepath", height=300, width=300, interactive=False)
299
- input_fg_display = gr.Image(label="Input Foreground", type="filepath", height=300, width=300, interactive=False)
 
 
 
 
 
 
300
 
301
  gr.Markdown("---")
302
- gr.Markdown("## Choose your preferred output:")
303
 
304
  with gr.Row():
305
  with gr.Column():
@@ -309,7 +315,7 @@ with gr.Blocks(title="Image Composition User Study") as demo:
309
  output_b_display = gr.Image(label="Output B", type="filepath", height=400, width=400, interactive=False)
310
  choice_button_b = gr.Button("Choose Output B", variant="primary")
311
 
312
- next_button = gr.Button("Next Sample", visible=False)
313
 
314
  demo.load(
315
  fn=display_new_sample,
 
131
 
132
  if not sample_data:
133
  return {
134
+ prompt_display: gr.update(value="**Prompt:** No more samples available. Thank you!"),
135
  input_bg_display: gr.update(value=None, visible=False),
136
  input_fg_display: gr.update(value=None, visible=False),
137
  output_a_display: gr.update(value=None, visible=False),
 
139
  choice_button_a: gr.update(visible=False),
140
  choice_button_b: gr.update(visible=False),
141
  next_button: gr.update(visible=False),
142
+ status_display: gr.update(value="**Status:** Completed!"),
143
  app_state: state,
144
  available_samples_state: remaining_ids
145
  }
 
159
  }
160
 
161
  return {
162
+ prompt_display: gr.update(value=f"**Prompt:** {sample_data['prompt']}"),
163
  input_bg_display: gr.update(value=sample_data["input_bg"], visible=True),
164
  input_fg_display: gr.update(value=sample_data["input_fg"], visible=True),
165
  output_a_display: gr.update(value=output_a["path"], visible=True),
 
167
  choice_button_a: gr.update(visible=True, interactive=True),
168
  choice_button_b: gr.update(visible=True, interactive=True),
169
  next_button: gr.update(visible=False),
170
+ status_display: gr.update(value="**Status:** Please choose the image you prefer."),
171
  app_state: state,
172
  available_samples_state: remaining_ids
173
  }
 
189
  choice_button_a: gr.update(interactive=False),
190
  choice_button_b: gr.update(interactive=False),
191
  next_button: gr.update(visible=True, interactive=True),
192
+ status_display: gr.update(value="**Status:** Error: Session state lost. Click Next Sample."),
193
  app_state: state
194
  }
195
 
 
227
  choice_button_a: gr.update(interactive=False),
228
  choice_button_b: gr.update(interactive=False),
229
  next_button: gr.update(visible=True, interactive=True),
230
+ status_display: gr.update(value=f"**Status:** Error saving preference locally: {e}. Click Next."),
231
  app_state: state
232
  }
233
 
 
235
  choice_button_a: gr.update(interactive=False),
236
  choice_button_b: gr.update(interactive=False),
237
  next_button: gr.update(visible=True, interactive=True),
238
+ status_display: gr.update(value=f"**Status:** Preference recorded (Chose {choice}). Click Next Sample."),
239
  app_state: state
240
  }
241
 
 
284
  with gr.Blocks(title="Image Composition User Study") as demo:
285
  gr.Markdown("# Image Composition User Study")
286
  gr.Markdown(
287
+ "> Please look at the input images and the prompt below. "
288
  "Then, compare the two output images (Output A and Output B) and click the button below the one you prefer."
289
  )
290
 
291
  app_state = gr.State({})
292
  available_samples_state = gr.State(INITIAL_SAMPLE_IDS)
293
 
294
+ status_display = gr.Markdown("**Status:** Loading first sample...")
 
295
 
296
+ gr.Markdown("## Inputs")
297
  with gr.Row():
298
+ prompt_display = gr.Markdown("**Prompt:** Loading...")
299
+ with gr.Row():
300
+ with gr.Column():
301
+ gr.Markdown("<div style='text-align: center;'>Input Background</div>")
302
+ input_bg_display = gr.Image(type="filepath", height=250, width=250, interactive=False, show_label=False)
303
+ with gr.Column():
304
+ gr.Markdown("<div style='text-align: center;'>Input Foreground</div>")
305
+ input_fg_display = gr.Image(type="filepath", height=250, width=250, interactive=False, show_label=False)
306
 
307
  gr.Markdown("---")
308
+ gr.Markdown("## Choose your preferred output")
309
 
310
  with gr.Row():
311
  with gr.Column():
 
315
  output_b_display = gr.Image(label="Output B", type="filepath", height=400, width=400, interactive=False)
316
  choice_button_b = gr.Button("Choose Output B", variant="primary")
317
 
318
+ next_button = gr.Button("🔁 Next Sample 🔁", visible=False)
319
 
320
  demo.load(
321
  fn=display_new_sample,