rsdmu commited on
Commit
d4c9123
·
verified ·
1 Parent(s): f348bc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -20
app.py CHANGED
@@ -8,7 +8,7 @@ import sys
8
  current_dir = os.path.dirname(os.path.abspath(__file__))
9
  csv_path = os.path.join(current_dir, 'preferences.csv')
10
 
11
-
12
  if not os.path.isfile(csv_path):
13
  print(f"Error: 'preferences.csv' not found at {csv_path}")
14
  sys.exit(1)
@@ -29,8 +29,6 @@ def show_image_pair(pair_id):
29
 
30
  img1_path = os.path.join(current_dir, record['image1'])
31
  img2_path = os.path.join(current_dir, record['image2'])
32
-
33
-
34
 
35
  # Check if images exist
36
  if not os.path.isfile(img1_path):
@@ -59,33 +57,39 @@ pair_ids = df['pair_id'].tolist()
59
  with gr.Blocks() as demo:
60
  gr.Markdown("# MID-Space Dataset Viewer")
61
 
 
62
  with gr.Row():
63
- with gr.Column():
64
  pair_id_input = gr.Dropdown(label="Select Pair ID", choices=pair_ids, value=pair_ids[0])
 
65
  show_button = gr.Button("Show Image Pair")
66
-
67
- # New Row for side-by-side images
68
- with gr.Row():
69
- img1 = gr.Image(label="Image 1")
70
- img2 = gr.Image(label="Image 2")
71
- img1 = gr.Image(label="Image 1", elem_id="img1", width=400)
72
- img2 = gr.Image(label="Image 2", elem_id="img2", width=400)
73
 
 
74
  with gr.Row():
75
- prompt = gr.Textbox(label="Prompt", interactive=False)
76
-
77
- with gr.Row():
78
- label1 = gr.Textbox(label="Label 1", interactive=False)
79
- label1_score = gr.Number(label="Label 1 Score", interactive=False)
80
 
 
81
  with gr.Row():
82
- label2 = gr.Textbox(label="Label 2", interactive=False)
83
- label2_score = gr.Number(label="Label 2 Score", interactive=False)
 
 
 
 
 
 
 
 
 
84
 
 
85
  with gr.Row():
86
- label3 = gr.Textbox(label="Label 3", interactive=False)
87
- label3_score = gr.Number(label="Label 3 Score", interactive=False)
88
 
 
89
  show_button.click(
90
  show_image_pair,
91
  inputs=[pair_id_input],
 
8
  current_dir = os.path.dirname(os.path.abspath(__file__))
9
  csv_path = os.path.join(current_dir, 'preferences.csv')
10
 
11
+ # Check if preferences.csv exists
12
  if not os.path.isfile(csv_path):
13
  print(f"Error: 'preferences.csv' not found at {csv_path}")
14
  sys.exit(1)
 
29
 
30
  img1_path = os.path.join(current_dir, record['image1'])
31
  img2_path = os.path.join(current_dir, record['image2'])
 
 
32
 
33
  # Check if images exist
34
  if not os.path.isfile(img1_path):
 
57
  with gr.Blocks() as demo:
58
  gr.Markdown("# MID-Space Dataset Viewer")
59
 
60
+ # Pair Selection Row
61
  with gr.Row():
62
+ with gr.Column(scale=1):
63
  pair_id_input = gr.Dropdown(label="Select Pair ID", choices=pair_ids, value=pair_ids[0])
64
+ with gr.Column(scale=1):
65
  show_button = gr.Button("Show Image Pair")
 
 
 
 
 
 
 
66
 
67
+ # Images Row
68
  with gr.Row():
69
+ with gr.Column(scale=1):
70
+ img1 = gr.Image(label="Image 1")
71
+ with gr.Column(scale=1):
72
+ img2 = gr.Image(label="Image 2")
 
73
 
74
+ # Scores Row
75
  with gr.Row():
76
+ # Left Scores
77
+ with gr.Column(scale=1):
78
+ label1 = gr.Textbox(label="Label 1", interactive=False)
79
+ label1_score = gr.Number(label="Label 1 Score", interactive=False)
80
+ label2 = gr.Textbox(label="Label 2", interactive=False)
81
+ label2_score = gr.Number(label="Label 2 Score", interactive=False)
82
+
83
+ # Right Scores
84
+ with gr.Column(scale=1):
85
+ label3 = gr.Textbox(label="Label 3", interactive=False)
86
+ label3_score = gr.Number(label="Label 3 Score", interactive=False)
87
 
88
+ # Prompt Row
89
  with gr.Row():
90
+ prompt = gr.Textbox(label="Prompt", interactive=False)
 
91
 
92
+ # Define Button Click Action
93
  show_button.click(
94
  show_image_pair,
95
  inputs=[pair_id_input],