tommymarto
commited on
Commit
•
6e0bc6b
1
Parent(s):
3839c42
Update demo.py
Browse files
demo.py
CHANGED
@@ -14,7 +14,7 @@ from firebase_admin import db, credentials
|
|
14 |
##################################################################
|
15 |
|
16 |
|
17 |
-
NUMBER_OF_IMAGES_PER_ROW =
|
18 |
NUMBER_OF_ROWS = 2
|
19 |
|
20 |
|
@@ -135,7 +135,7 @@ def next():
|
|
135 |
new_experiment = generate_new_experiment()
|
136 |
|
137 |
new_img_components = [
|
138 |
-
gr.Image(value=img["name"], label=f"{i}", elem_id="unsel", show_label=False, show_download_button=False, show_share_button=False, interactive=False
|
139 |
for i, img in enumerate(new_experiment["options"])
|
140 |
]
|
141 |
new_corrupted_component = gr.Image(value=new_experiment["corrupted"]["name"], label="corr", elem_id="corrupted", show_label=False, show_download_button=False, show_share_button=False, interactive=False)
|
@@ -146,11 +146,11 @@ def on_select(evt: gr.SelectData, experiment, *img_components): # SelectData is
|
|
146 |
new_selected = int(evt.target.label)
|
147 |
|
148 |
new_img_components = [
|
149 |
-
gr.Image(value=img["name"], label=f"{i}", elem_id="unsel", show_label=False, show_download_button=False, show_share_button=False, interactive=False
|
150 |
for i, img in enumerate(experiment["options"])
|
151 |
]
|
152 |
new_img_components[new_selected] = (
|
153 |
-
gr.Image(value=experiment["options"][new_selected]["name"], label=f"{new_selected}", elem_id="sel", show_label=False, show_download_button=False, show_share_button=False, interactive=False
|
154 |
)
|
155 |
|
156 |
experiment["selected_image"] = int(evt.target.label)
|
@@ -180,7 +180,7 @@ with gr.Blocks(title="Unsupervised Image Editing", css=css) as demo:
|
|
180 |
for row in range(NUMBER_OF_ROWS):
|
181 |
with gr.Row():
|
182 |
for col in range(NUMBER_OF_IMAGES_PER_ROW):
|
183 |
-
img_components.append(gr.Image(label=f"{row * NUMBER_OF_IMAGES_PER_ROW + col}", elem_id="unsel", show_label=False, show_download_button=False, show_share_button=False, interactive=False
|
184 |
|
185 |
btn_skip.click(partial(save, mode="skip"), [experiment, corrupted_component, *img_components], [experiment, corrupted_component, *img_components])
|
186 |
btn_submit.click(partial(save, mode="save"), [experiment, corrupted_component, *img_components], [experiment, corrupted_component, *img_components])
|
|
|
14 |
##################################################################
|
15 |
|
16 |
|
17 |
+
NUMBER_OF_IMAGES_PER_ROW = 7
|
18 |
NUMBER_OF_ROWS = 2
|
19 |
|
20 |
|
|
|
135 |
new_experiment = generate_new_experiment()
|
136 |
|
137 |
new_img_components = [
|
138 |
+
gr.Image(value=img["name"], label=f"{i}", elem_id="unsel", show_label=False, show_download_button=False, show_share_button=False, interactive=False)
|
139 |
for i, img in enumerate(new_experiment["options"])
|
140 |
]
|
141 |
new_corrupted_component = gr.Image(value=new_experiment["corrupted"]["name"], label="corr", elem_id="corrupted", show_label=False, show_download_button=False, show_share_button=False, interactive=False)
|
|
|
146 |
new_selected = int(evt.target.label)
|
147 |
|
148 |
new_img_components = [
|
149 |
+
gr.Image(value=img["name"], label=f"{i}", elem_id="unsel", show_label=False, show_download_button=False, show_share_button=False, interactive=False)
|
150 |
for i, img in enumerate(experiment["options"])
|
151 |
]
|
152 |
new_img_components[new_selected] = (
|
153 |
+
gr.Image(value=experiment["options"][new_selected]["name"], label=f"{new_selected}", elem_id="sel", show_label=False, show_download_button=False, show_share_button=False, interactive=False)
|
154 |
)
|
155 |
|
156 |
experiment["selected_image"] = int(evt.target.label)
|
|
|
180 |
for row in range(NUMBER_OF_ROWS):
|
181 |
with gr.Row():
|
182 |
for col in range(NUMBER_OF_IMAGES_PER_ROW):
|
183 |
+
img_components.append(gr.Image(label=f"{row * NUMBER_OF_IMAGES_PER_ROW + col}", elem_id="unsel", show_label=False, show_download_button=False, show_share_button=False, interactive=False))
|
184 |
|
185 |
btn_skip.click(partial(save, mode="skip"), [experiment, corrupted_component, *img_components], [experiment, corrupted_component, *img_components])
|
186 |
btn_submit.click(partial(save, mode="save"), [experiment, corrupted_component, *img_components], [experiment, corrupted_component, *img_components])
|