patrickvonplaten
commited on
Commit
·
9f7a953
1
Parent(s):
03643d5
finish
Browse files- __pycache__/app.cpython-310.pyc +0 -0
- app.py +22 -15
__pycache__/app.cpython-310.pyc
CHANGED
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
|
|
app.py
CHANGED
@@ -29,13 +29,14 @@ LINKS = {
|
|
29 |
NUM_QUESTIONS = 10
|
30 |
MODEL_KEYS = "-".join(SUBMISSIONS.keys())
|
31 |
SUBMISSION_ORG = f"results-{MODEL_KEYS}"
|
32 |
-
PROMPT_FORMAT = "Pick the picture that best matches the prompt:
|
33 |
|
34 |
submission_names = list(SUBMISSIONS.keys())
|
35 |
num_images = len(SUBMISSIONS[submission_names[0]])
|
36 |
|
37 |
|
38 |
def load_submissions():
|
|
|
39 |
all_datasets = list_datasets(author=SUBMISSION_ORG)
|
40 |
relevant_ids = [d.id for d in all_datasets]
|
41 |
|
@@ -125,7 +126,7 @@ def start():
|
|
125 |
|
126 |
def process(dataframe, row_number=0):
|
127 |
if row_number == NUM_QUESTIONS:
|
128 |
-
return None, "", ""
|
129 |
|
130 |
image_id = dataframe.iloc[row_number]["id"]
|
131 |
choices = [
|
@@ -135,8 +136,8 @@ def process(dataframe, row_number=0):
|
|
135 |
images = (SUBMISSIONS[c][int(image_id)]["images"] for c in choices)
|
136 |
|
137 |
prompt = SUBMISSIONS[choices[0]][int(image_id)]["Prompt"]
|
138 |
-
prompt =
|
139 |
-
counter = f"{row_number + 1}/{NUM_QUESTIONS}"
|
140 |
|
141 |
return *images, prompt, counter
|
142 |
|
@@ -199,10 +200,9 @@ EXPLANATION = """\n\n
|
|
199 |
GALLERY_COLUMN_NUM = len(SUBMISSIONS)
|
200 |
|
201 |
with gr.Blocks() as demo:
|
202 |
-
gr.Markdown(TITLE)
|
203 |
-
gr.Markdown(DESCRIPTION)
|
204 |
-
|
205 |
with gr.Column(visible=True) as intro_view:
|
|
|
|
|
206 |
gr.Markdown(EXPLANATION)
|
207 |
start_button = gr.Button("Start").style(full_width=False)
|
208 |
|
@@ -237,20 +237,22 @@ with gr.Blocks() as demo:
|
|
237 |
selected_image = gr.Number(label="Selected index", value=-1, precision=0)
|
238 |
|
239 |
with gr.Column(visible=False) as gallery_view:
|
240 |
-
|
241 |
-
|
|
|
|
|
242 |
with gr.Blocks():
|
243 |
with gr.Row():
|
244 |
-
with gr.Column():
|
245 |
image_1 = gr.Image(interactive=False)
|
246 |
image_1_button = gr.Button("Select 1").style(full_width=True)
|
247 |
-
with gr.Column():
|
248 |
image_2 = gr.Image(interactive=False)
|
249 |
image_2_button = gr.Button("Select 2").style(full_width=True)
|
250 |
-
with gr.Column():
|
251 |
image_3 = gr.Image(interactive=False)
|
252 |
image_3_button = gr.Button("Select 3").style(full_width=True)
|
253 |
-
with gr.Column():
|
254 |
image_4 = gr.Image(interactive=False)
|
255 |
image_4_button = gr.Button("Select 4").style(full_width=True)
|
256 |
|
@@ -271,10 +273,15 @@ with gr.Blocks() as demo:
|
|
271 |
fn=process, inputs=[dataframe], outputs=[image_1, image_2, image_3, image_4, prompt, counter]
|
272 |
)
|
273 |
|
274 |
-
|
|
|
275 |
button.click(
|
|
|
|
|
|
|
|
|
276 |
fn=write_result,
|
277 |
-
inputs=[
|
278 |
outputs=[row_number, dataframe],
|
279 |
).then(
|
280 |
fn=change_view,
|
|
|
29 |
NUM_QUESTIONS = 10
|
30 |
MODEL_KEYS = "-".join(SUBMISSIONS.keys())
|
31 |
SUBMISSION_ORG = f"results-{MODEL_KEYS}"
|
32 |
+
PROMPT_FORMAT = " Pick the picture that best matches the prompt:"
|
33 |
|
34 |
submission_names = list(SUBMISSIONS.keys())
|
35 |
num_images = len(SUBMISSIONS[submission_names[0]])
|
36 |
|
37 |
|
38 |
def load_submissions():
|
39 |
+
return {}
|
40 |
all_datasets = list_datasets(author=SUBMISSION_ORG)
|
41 |
relevant_ids = [d.id for d in all_datasets]
|
42 |
|
|
|
126 |
|
127 |
def process(dataframe, row_number=0):
|
128 |
if row_number == NUM_QUESTIONS:
|
129 |
+
return None, None, None, None, "", ""
|
130 |
|
131 |
image_id = dataframe.iloc[row_number]["id"]
|
132 |
choices = [
|
|
|
136 |
images = (SUBMISSIONS[c][int(image_id)]["images"] for c in choices)
|
137 |
|
138 |
prompt = SUBMISSIONS[choices[0]][int(image_id)]["Prompt"]
|
139 |
+
prompt = f'# "{prompt}"'
|
140 |
+
counter = f"***{row_number + 1}/{NUM_QUESTIONS} {PROMPT_FORMAT}***"
|
141 |
|
142 |
return *images, prompt, counter
|
143 |
|
|
|
200 |
GALLERY_COLUMN_NUM = len(SUBMISSIONS)
|
201 |
|
202 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
203 |
with gr.Column(visible=True) as intro_view:
|
204 |
+
gr.Markdown(TITLE)
|
205 |
+
gr.Markdown(DESCRIPTION)
|
206 |
gr.Markdown(EXPLANATION)
|
207 |
start_button = gr.Button("Start").style(full_width=False)
|
208 |
|
|
|
237 |
selected_image = gr.Number(label="Selected index", value=-1, precision=0)
|
238 |
|
239 |
with gr.Column(visible=False) as gallery_view:
|
240 |
+
with gr.Row():
|
241 |
+
counter = gr.Markdown(f"***1/{NUM_QUESTIONS} {PROMPT_FORMAT}***")
|
242 |
+
with gr.Row():
|
243 |
+
prompt = gr.Markdown("")
|
244 |
with gr.Blocks():
|
245 |
with gr.Row():
|
246 |
+
with gr.Column() as c1:
|
247 |
image_1 = gr.Image(interactive=False)
|
248 |
image_1_button = gr.Button("Select 1").style(full_width=True)
|
249 |
+
with gr.Column() as c2:
|
250 |
image_2 = gr.Image(interactive=False)
|
251 |
image_2_button = gr.Button("Select 2").style(full_width=True)
|
252 |
+
with gr.Column() as c3:
|
253 |
image_3 = gr.Image(interactive=False)
|
254 |
image_3_button = gr.Button("Select 3").style(full_width=True)
|
255 |
+
with gr.Column() as c4:
|
256 |
image_4 = gr.Image(interactive=False)
|
257 |
image_4_button = gr.Button("Select 4").style(full_width=True)
|
258 |
|
|
|
273 |
fn=process, inputs=[dataframe], outputs=[image_1, image_2, image_3, image_4, prompt, counter]
|
274 |
)
|
275 |
|
276 |
+
images = [image_1_button, image_2_button, image_3_button, image_4_button]
|
277 |
+
for i, button in enumerate(images):
|
278 |
button.click(
|
279 |
+
fn=lambda: i,
|
280 |
+
inputs=[],
|
281 |
+
outputs=[selected_image],
|
282 |
+
).then(
|
283 |
fn=write_result,
|
284 |
+
inputs=[selected_image, row_number, dataframe],
|
285 |
outputs=[row_number, dataframe],
|
286 |
).then(
|
287 |
fn=change_view,
|