taesiri commited on
Commit
40282f1
Β·
1 Parent(s): 3bd4178
Files changed (1) hide show
  1. app.py +31 -33
app.py CHANGED
@@ -422,7 +422,7 @@ def update_button_styles(verdict):
422
  """Update button styles based on selection"""
423
  # Update button labels to use emojis
424
  a_better_style = gr.update(
425
- value="πŸ‘ˆ A is better" if verdict == "A is better" else "πŸ‘ˆ A is better"
426
  )
427
  b_better_style = gr.update(
428
  value="πŸ‘‰ B is better" if verdict == "B is better" else "πŸ‘‰ B is better"
@@ -483,20 +483,9 @@ with gr.Blocks() as demo:
483
  """,
484
  image_path="./instructions/page2.jpg", # Replace with actual image path
485
  )
486
- next_btn1 = gr.Button("Next", variant="primary")
487
-
488
- # Page 3 - Second instruction page
489
- with gr.Column(visible=False) as page3:
490
- create_instruction_page(
491
- """
492
- <div style="text-align: center; padding: 20px;">
493
- <h1>Making Your Decision</h1>
494
- <p>Compare the edits carefully...</p>
495
- </div>
496
- """,
497
- image_path="./instructions/page3.jpg", # Replace with actual image path
498
- )
499
- next_btn2 = gr.Button("Start Evaluation", variant="primary")
500
 
501
  # Main Evaluation UI (existing code)
502
  with gr.Column(visible=False) as main_ui:
@@ -507,7 +496,7 @@ with gr.Blocks() as demo:
507
  <div style="font-size: 1.2rem; margin-bottom: 0.5rem;">Read the user instruction, look at the source image, then evaluate which edit (A or B) best satisfies the request better.</div>
508
  <div style="font-size: 1rem;">
509
  <strong>🀝 Tie</strong> &nbsp;&nbsp;|&nbsp;&nbsp;
510
- <strong>πŸ‘ˆ A is better</strong> &nbsp;&nbsp;|&nbsp;&nbsp;
511
  <strong>πŸ‘‰ B is better</strong>
512
  </div>
513
  <div style="color: #ff4444; font-size: 0.9rem; margin-top: 0.5rem;">
@@ -533,7 +522,7 @@ with gr.Blocks() as demo:
533
  with gr.Column():
534
  image_a = gr.Image(label="Image A", show_label=True, height=500)
535
  gr.HTML("<h2 style='text-align: center;'>Image A</h2>")
536
- a_better_btn = gr.Button("πŸ‘ˆ A is better", variant="secondary")
537
  with gr.Column():
538
  image_b = gr.Image(label="Image B", show_label=True, height=500)
539
  gr.HTML("<h2 style='text-align: center;'>Image B</h2>")
@@ -722,8 +711,7 @@ with gr.Blocks() as demo:
722
  return [
723
  gr.update(visible=(page_num == 1)), # page1
724
  gr.update(visible=(page_num == 2)), # page2
725
- gr.update(visible=(page_num == 3)), # page3
726
- gr.update(visible=(page_num == 4)), # main_ui
727
  ]
728
 
729
  # Connect button clicks to page navigation
@@ -739,30 +727,40 @@ with gr.Blocks() as demo:
739
  ).then(
740
  update_page_visibility,
741
  inputs=[current_page],
742
- outputs=[page1, page2, page3, main_ui],
743
- )
744
-
745
- next_btn1.click(
746
- advance_page,
747
- inputs=[current_page],
748
- outputs=current_page,
749
  ).then(
750
- update_page_visibility,
751
- inputs=[current_page],
752
- outputs=[page1, page2, page3, main_ui], # Control column visibility
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
753
  )
754
 
755
- next_btn2.click(
756
- advance_page,
757
  inputs=[current_page],
758
  outputs=current_page,
759
  ).then(
760
  update_page_visibility,
761
  inputs=[current_page],
762
- outputs=[page1, page2, page3, main_ui],
763
  ).then(
764
  initialize,
765
- inputs=[username_state], # Pass username_state to initialize
766
  outputs=[
767
  source_image,
768
  image_a,
 
422
  """Update button styles based on selection"""
423
  # Update button labels to use emojis
424
  a_better_style = gr.update(
425
+ value="☝️ A is better" if verdict == "A is better" else "☝️ A is better"
426
  )
427
  b_better_style = gr.update(
428
  value="πŸ‘‰ B is better" if verdict == "B is better" else "πŸ‘‰ B is better"
 
483
  """,
484
  image_path="./instructions/page2.jpg", # Replace with actual image path
485
  )
486
+ next_btn1 = gr.Button(
487
+ "Start Evaluation", variant="primary"
488
+ ) # Changed button text
 
 
 
 
 
 
 
 
 
 
 
489
 
490
  # Main Evaluation UI (existing code)
491
  with gr.Column(visible=False) as main_ui:
 
496
  <div style="font-size: 1.2rem; margin-bottom: 0.5rem;">Read the user instruction, look at the source image, then evaluate which edit (A or B) best satisfies the request better.</div>
497
  <div style="font-size: 1rem;">
498
  <strong>🀝 Tie</strong> &nbsp;&nbsp;|&nbsp;&nbsp;
499
+ <strong>☝️ A is better</strong> &nbsp;&nbsp;|&nbsp;&nbsp;
500
  <strong>πŸ‘‰ B is better</strong>
501
  </div>
502
  <div style="color: #ff4444; font-size: 0.9rem; margin-top: 0.5rem;">
 
522
  with gr.Column():
523
  image_a = gr.Image(label="Image A", show_label=True, height=500)
524
  gr.HTML("<h2 style='text-align: center;'>Image A</h2>")
525
+ a_better_btn = gr.Button("☝️ A is better", variant="secondary")
526
  with gr.Column():
527
  image_b = gr.Image(label="Image B", show_label=True, height=500)
528
  gr.HTML("<h2 style='text-align: center;'>Image B</h2>")
 
711
  return [
712
  gr.update(visible=(page_num == 1)), # page1
713
  gr.update(visible=(page_num == 2)), # page2
714
+ gr.update(visible=(page_num == 3)), # main_ui - changed from 4 to 3
 
715
  ]
716
 
717
  # Connect button clicks to page navigation
 
727
  ).then(
728
  update_page_visibility,
729
  inputs=[current_page],
730
+ outputs=[page1, page2, main_ui],
 
 
 
 
 
 
731
  ).then(
732
+ initialize,
733
+ inputs=[username_state],
734
+ outputs=[
735
+ source_image,
736
+ image_a,
737
+ image_b,
738
+ instruction,
739
+ simplified_instruction,
740
+ model_info,
741
+ state,
742
+ selected_verdict,
743
+ a_better_selected,
744
+ b_better_selected,
745
+ neither_selected,
746
+ tie_selected,
747
+ post_id_display,
748
+ simplified_instruction_debug,
749
+ username_debug,
750
+ ],
751
  )
752
 
753
+ next_btn1.click(
754
+ lambda x: 3, # Force page 3 instead of using advance_page
755
  inputs=[current_page],
756
  outputs=current_page,
757
  ).then(
758
  update_page_visibility,
759
  inputs=[current_page],
760
+ outputs=[page1, page2, main_ui],
761
  ).then(
762
  initialize,
763
+ inputs=[username_state],
764
  outputs=[
765
  source_image,
766
  image_a,