rsdmu commited on
Commit
8ec9729
·
verified ·
1 Parent(s): 6f6514d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -53
app.py CHANGED
@@ -90,18 +90,14 @@ with gr.Blocks() as demo:
90
  show_button = gr.Button("Show Image Pair")
91
 
92
  with gr.Row():
93
- with gr.Column():
94
- img1 = gr.Image(
95
- label="Image 1",
96
- interactive=False,
97
- elem_id="image1"
98
- )
99
- with gr.Column():
100
- img2 = gr.Image(
101
- label="Image 2",
102
- interactive=False,
103
- elem_id="image2"
104
- )
105
 
106
  with gr.Row():
107
  prompt = gr.Textbox(
@@ -111,43 +107,41 @@ with gr.Blocks() as demo:
111
  placeholder="Select a Pair ID to view details."
112
  )
113
 
114
- with gr.Accordion("Labels", open=False):
115
- with gr.Row():
116
- label1_name = gr.Textbox(
117
- label="Label 1",
118
- interactive=False,
119
- placeholder="Label 1"
120
- )
121
- label1_score = gr.Number(
122
- label="Label 1 Score",
123
- interactive=False,
124
- precision=2
125
- # Removed placeholder
126
- )
127
- with gr.Row():
128
- label2_name = gr.Textbox(
129
- label="Label 2",
130
- interactive=False,
131
- placeholder="Label 2"
132
- )
133
- label2_score = gr.Number(
134
- label="Label 2 Score",
135
- interactive=False,
136
- precision=2
137
- # Removed placeholder
138
- )
139
- with gr.Row():
140
- label3_name = gr.Textbox(
141
- label="Label 3",
142
- interactive=False,
143
- placeholder="Label 3"
144
- )
145
- label3_score = gr.Number(
146
- label="Label 3 Score",
147
- interactive=False,
148
- precision=2
149
- # Removed placeholder
150
- )
151
 
152
  # Define the callback function for the button
153
  def update_viewer(response):
@@ -155,18 +149,18 @@ with gr.Blocks() as demo:
155
  img1: response["images"][0],
156
  img2: response["images"][1],
157
  prompt: response["prompt"],
158
- label1_name: response["labels"]["Label 1"]["name"],
159
  label1_score: response["labels"]["Label 1"]["score"],
160
- label2_name: response["labels"]["Label 2"]["name"],
161
  label2_score: response["labels"]["Label 2"]["score"],
162
- label3_name: response["labels"]["Label 3"]["name"],
163
  label3_score: response["labels"]["Label 3"]["score"],
164
  }
165
 
166
  show_button.click(
167
  show_image_pair,
168
  inputs=[pair_id_input],
169
- outputs=[img1, img2, prompt, label1_name, label1_score, label2_name, label2_score, label3_name, label3_score],
170
  postprocess=update_viewer
171
  )
172
 
 
90
  show_button = gr.Button("Show Image Pair")
91
 
92
  with gr.Row():
93
+ img1 = gr.Image(
94
+ label="Image 1",
95
+ interactive=False
96
+ )
97
+ img2 = gr.Image(
98
+ label="Image 2",
99
+ interactive=False
100
+ )
 
 
 
 
101
 
102
  with gr.Row():
103
  prompt = gr.Textbox(
 
107
  placeholder="Select a Pair ID to view details."
108
  )
109
 
110
+ with gr.Row():
111
+ label1 = gr.Textbox(
112
+ label="Label 1",
113
+ interactive=False
114
+ )
115
+ label1_score = gr.Number(
116
+ label="Label 1 Score",
117
+ interactive=False,
118
+ precision=2,
119
+ value=0.0 # ✅ Correct usage
120
+ )
121
+
122
+ with gr.Row():
123
+ label2 = gr.Textbox(
124
+ label="Label 2",
125
+ interactive=False
126
+ )
127
+ label2_score = gr.Number(
128
+ label="Label 2 Score",
129
+ interactive=False,
130
+ precision=2,
131
+ value=0.0 # ✅ Correct usage
132
+ )
133
+
134
+ with gr.Row():
135
+ label3 = gr.Textbox(
136
+ label="Label 3",
137
+ interactive=False
138
+ )
139
+ label3_score = gr.Number(
140
+ label="Label 3 Score",
141
+ interactive=False,
142
+ precision=2,
143
+ value=0.0 # ✅ Correct usage
144
+ )
 
 
145
 
146
  # Define the callback function for the button
147
  def update_viewer(response):
 
149
  img1: response["images"][0],
150
  img2: response["images"][1],
151
  prompt: response["prompt"],
152
+ label1: response["labels"]["Label 1"]["name"],
153
  label1_score: response["labels"]["Label 1"]["score"],
154
+ label2: response["labels"]["Label 2"]["name"],
155
  label2_score: response["labels"]["Label 2"]["score"],
156
+ label3: response["labels"]["Label 3"]["name"],
157
  label3_score: response["labels"]["Label 3"]["score"],
158
  }
159
 
160
  show_button.click(
161
  show_image_pair,
162
  inputs=[pair_id_input],
163
+ outputs=[img1, img2, prompt, label1, label1_score, label2, label2_score, label3, label3_score],
164
  postprocess=update_viewer
165
  )
166