Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
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.
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
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 |
-
|
159 |
label1_score: response["labels"]["Label 1"]["score"],
|
160 |
-
|
161 |
label2_score: response["labels"]["Label 2"]["score"],
|
162 |
-
|
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,
|
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 |
|