update interface
Browse files- __pycache__/live_preview_helpers.cpython-310.pyc +0 -0
- __pycache__/optim_utils.cpython-310.pyc +0 -0
- __pycache__/utils.cpython-310.pyc +0 -0
- app.py +17 -12
- utils.py +3 -4
__pycache__/live_preview_helpers.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/live_preview_helpers.cpython-310.pyc and b/__pycache__/live_preview_helpers.cpython-310.pyc differ
|
|
|
__pycache__/optim_utils.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/optim_utils.cpython-310.pyc and b/__pycache__/optim_utils.cpython-310.pyc differ
|
|
|
__pycache__/utils.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/utils.cpython-310.pyc and b/__pycache__/utils.cpython-310.pyc differ
|
|
|
app.py
CHANGED
|
@@ -452,13 +452,11 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Inconsolata"), "
|
|
| 452 |
visible=True,
|
| 453 |
)
|
| 454 |
next_btn1 = gr.Button("Generate", variant="primary", scale=1, interactive=False, visible=False)
|
| 455 |
-
|
| 456 |
-
example1 = gr.Examples([['']], prompt1, label="Revised Prompt History", visible=False)
|
| 457 |
-
|
| 458 |
with gr.Row(elem_id="compact-row"):
|
| 459 |
with gr.Column(elem_id="col-container"):
|
| 460 |
-
images_method1 = gr.Gallery(label="Images", columns=[4], rows=[1], height=
|
| 461 |
-
|
| 462 |
with gr.Column(elem_id="col-container3"):
|
| 463 |
like_image1 = gr.Image(label="Satisfied Image", width=200, height=200, sources='upload', format="png", type="filepath")
|
| 464 |
dislike_image1 = gr.Image(label="Unsatisfied Image", width=200, height=200, sources='upload', format="png", type="filepath")
|
|
@@ -490,7 +488,11 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Inconsolata"), "
|
|
| 490 |
container=False,
|
| 491 |
value=VERBAL_MSG
|
| 492 |
)
|
| 493 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 494 |
with gr.Row(elem_id="button-container"):
|
| 495 |
redesign_btn1 = gr.Button("π¨ Redesign", variant="primary", scale=0)
|
| 496 |
submit_btn1 = gr.Button("β
Submit", variant="primary", interactive=False, scale=0)
|
|
@@ -507,13 +509,11 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Inconsolata"), "
|
|
| 507 |
visible=True,
|
| 508 |
)
|
| 509 |
next_btn2 = gr.Button("Generate", variant="primary", scale=1, interactive=False, visible=False)
|
| 510 |
-
|
| 511 |
-
example2 = gr.Examples([['']], prompt2, label="Revised Prompt History", visible=False)
|
| 512 |
-
|
| 513 |
with gr.Row(elem_id="compact-row"):
|
| 514 |
with gr.Column(elem_id="col-container"):
|
| 515 |
images_method2 = gr.Gallery(label="Images", columns=[4], rows=[1], height=200, elem_id="gallery", format="png")
|
| 516 |
-
|
| 517 |
with gr.Column(elem_id="col-container3"):
|
| 518 |
like_image2 = gr.Image(label="Satisfied Image", width=200, height=200, sources='upload', format="png", type="filepath")
|
| 519 |
dislike_image2 = gr.Image(label="Unsatisfied Image", width=200, height=200, sources='upload', format="png", type="filepath")
|
|
@@ -546,6 +546,11 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Inconsolata"), "
|
|
| 546 |
container=False,
|
| 547 |
value=VERBAL_MSG
|
| 548 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 549 |
with gr.Row(elem_id="button-container"):
|
| 550 |
redesign_btn2 = gr.Button("π¨ Redesign", variant="primary", scale=0)
|
| 551 |
submit_btn2 = gr.Button("β
Submit", variant="primary", interactive=False, scale=0)
|
|
@@ -563,8 +568,8 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Inconsolata"), "
|
|
| 563 |
|
| 564 |
# prompt1.change(fn=reset_gallery, inputs=[], outputs=[gallery_state1])
|
| 565 |
# prompt2.change(fn=reset_gallery, inputs=[], outputs=[gallery_state2])
|
| 566 |
-
next_btn1.click(fn=generate_image, inputs=[participant, scenario, prompt1, active_tab, like_image1, dislike_image1], outputs=[images_method1])
|
| 567 |
-
next_btn2.click(fn=generate_image, inputs=[participant, scenario, prompt2, active_tab, like_image2, dislike_image2], outputs=[images_method2])
|
| 568 |
sim_radio1.change(fn=check_satisfaction, inputs=[sim_radio1, active_tab], outputs=[submit_btn1])
|
| 569 |
sim_radio2.change(fn=check_satisfaction, inputs=[sim_radio2, active_tab], outputs=[submit_btn2])
|
| 570 |
dislike_radio1.select(fn=select_image, inputs=[dislike_radio1, images_method1], outputs=[dislike_image1])
|
|
|
|
| 452 |
visible=True,
|
| 453 |
)
|
| 454 |
next_btn1 = gr.Button("Generate", variant="primary", scale=1, interactive=False, visible=False)
|
| 455 |
+
|
|
|
|
|
|
|
| 456 |
with gr.Row(elem_id="compact-row"):
|
| 457 |
with gr.Column(elem_id="col-container"):
|
| 458 |
+
images_method1 = gr.Gallery(label="Images", columns=[4], rows=[1], height=400, elem_id="gallery", format="png")
|
| 459 |
+
|
| 460 |
with gr.Column(elem_id="col-container3"):
|
| 461 |
like_image1 = gr.Image(label="Satisfied Image", width=200, height=200, sources='upload', format="png", type="filepath")
|
| 462 |
dislike_image1 = gr.Image(label="Unsatisfied Image", width=200, height=200, sources='upload', format="png", type="filepath")
|
|
|
|
| 488 |
container=False,
|
| 489 |
value=VERBAL_MSG
|
| 490 |
)
|
| 491 |
+
|
| 492 |
+
with gr.Column(elem_id="col-container2"):
|
| 493 |
+
example1 = gr.Examples([['']], prompt1, label="Revised Prompt History", visible=False)
|
| 494 |
+
history_images1 = gr.Gallery(label="History Images", columns=[4], rows=[1], elem_id="gallery", format="png")
|
| 495 |
+
|
| 496 |
with gr.Row(elem_id="button-container"):
|
| 497 |
redesign_btn1 = gr.Button("π¨ Redesign", variant="primary", scale=0)
|
| 498 |
submit_btn1 = gr.Button("β
Submit", variant="primary", interactive=False, scale=0)
|
|
|
|
| 509 |
visible=True,
|
| 510 |
)
|
| 511 |
next_btn2 = gr.Button("Generate", variant="primary", scale=1, interactive=False, visible=False)
|
| 512 |
+
|
|
|
|
|
|
|
| 513 |
with gr.Row(elem_id="compact-row"):
|
| 514 |
with gr.Column(elem_id="col-container"):
|
| 515 |
images_method2 = gr.Gallery(label="Images", columns=[4], rows=[1], height=200, elem_id="gallery", format="png")
|
| 516 |
+
|
| 517 |
with gr.Column(elem_id="col-container3"):
|
| 518 |
like_image2 = gr.Image(label="Satisfied Image", width=200, height=200, sources='upload', format="png", type="filepath")
|
| 519 |
dislike_image2 = gr.Image(label="Unsatisfied Image", width=200, height=200, sources='upload', format="png", type="filepath")
|
|
|
|
| 546 |
container=False,
|
| 547 |
value=VERBAL_MSG
|
| 548 |
)
|
| 549 |
+
|
| 550 |
+
with gr.Column(elem_id="col-container2"):
|
| 551 |
+
example2 = gr.Examples([['']], prompt2, label="Revised Prompt History", visible=False)
|
| 552 |
+
history_images2 = gr.Gallery(label="History Images", columns=[4], rows=[1], elem_id="gallery", format="png")
|
| 553 |
+
|
| 554 |
with gr.Row(elem_id="button-container"):
|
| 555 |
redesign_btn2 = gr.Button("π¨ Redesign", variant="primary", scale=0)
|
| 556 |
submit_btn2 = gr.Button("β
Submit", variant="primary", interactive=False, scale=0)
|
|
|
|
| 568 |
|
| 569 |
# prompt1.change(fn=reset_gallery, inputs=[], outputs=[gallery_state1])
|
| 570 |
# prompt2.change(fn=reset_gallery, inputs=[], outputs=[gallery_state2])
|
| 571 |
+
next_btn1.click(fn=generate_image, inputs=[participant, scenario, prompt1, active_tab, like_image1, dislike_image1], outputs=[images_method1]).success(lambda: gr.update(interactive=False), outputs=[next_btn1])
|
| 572 |
+
next_btn2.click(fn=generate_image, inputs=[participant, scenario, prompt2, active_tab, like_image2, dislike_image2], outputs=[images_method2]).success(lambda: gr.update(interactive=False), outputs=[next_btn2])
|
| 573 |
sim_radio1.change(fn=check_satisfaction, inputs=[sim_radio1, active_tab], outputs=[submit_btn1])
|
| 574 |
sim_radio2.change(fn=check_satisfaction, inputs=[sim_radio2, active_tab], outputs=[submit_btn2])
|
| 575 |
dislike_radio1.select(fn=select_image, inputs=[dislike_radio1, images_method1], outputs=[dislike_image1])
|
utils.py
CHANGED
|
@@ -112,10 +112,9 @@ Can you give me {num_prompts} modified prompts for the prompt '{prompt}' please.
|
|
| 112 |
messages.append({"role": "user", "content": f"{message}"})
|
| 113 |
return messages
|
| 114 |
|
| 115 |
-
def encode_image(
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
return base64.b64encode(buffered.getvalue()).decode("utf-8")
|
| 119 |
|
| 120 |
def get_personalize_message(prompt, history_prompts, history_feedback, like_image, dislike_image):
|
| 121 |
messages = [
|
|
|
|
| 112 |
messages.append({"role": "user", "content": f"{message}"})
|
| 113 |
return messages
|
| 114 |
|
| 115 |
+
def encode_image(image_path):
|
| 116 |
+
with open(image_path, "rb") as image_file:
|
| 117 |
+
return base64.b64encode(image_file.read()).decode("utf-8")
|
|
|
|
| 118 |
|
| 119 |
def get_personalize_message(prompt, history_prompts, history_feedback, like_image, dislike_image):
|
| 120 |
messages = [
|