Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -245,7 +245,6 @@ def submit_comment(comment):
|
|
245 |
elif comment_images[0] in comments:
|
246 |
comments.pop(comment_images[0], None)
|
247 |
|
248 |
-
print(comments)
|
249 |
next_comment = ""
|
250 |
if comment_images[0] in comments:
|
251 |
next_comment = comments[comment_images[0]]
|
@@ -263,7 +262,6 @@ def next_image():
|
|
263 |
comment_images.append(comment_images[0])
|
264 |
comment_images = comment_images[1:]
|
265 |
|
266 |
-
print(comments)
|
267 |
next_comment = ""
|
268 |
if comment_images[0] in comments:
|
269 |
next_comment = comments[comment_images[0]]
|
@@ -279,7 +277,6 @@ def previous_image():
|
|
279 |
comment_images = comment_images[1:]
|
280 |
comment_images = comment_images[::-1]
|
281 |
|
282 |
-
print(comments)
|
283 |
next_comment = ""
|
284 |
if comment_images[0] in comments:
|
285 |
next_comment = comments[comment_images[0]]
|
@@ -341,6 +338,20 @@ Here are the images and their corresponding comments:
|
|
341 |
|
342 |
if re.match(r"(.|\n)*Assistant: Liked Art Features: (.|\n)*Disliked Art Features: (.|\n)*", generated_texts):
|
343 |
positive_vp, negative_vp = re.search('.* \nAssistant: Liked Art Features: (.*)\nDisliked Art Features: (.*)', generated_texts).groups()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
gr.Info("Visual preference successfully extracted.")
|
345 |
else:
|
346 |
positive_vp = ""
|
@@ -456,7 +467,6 @@ def api_fn(api):
|
|
456 |
]
|
457 |
)
|
458 |
gr.Info("Valid API")
|
459 |
-
print("correct")
|
460 |
valid_api = api
|
461 |
|
462 |
except anthropic.AuthenticationError:
|
@@ -498,7 +508,6 @@ def generate(prompt, vp_pos, vp_neg, slider, example_prompt, gallery, num_infere
|
|
498 |
|
499 |
generator = torch.Generator().manual_seed(seed)
|
500 |
|
501 |
-
print(f"Prompt: {prompt}")
|
502 |
image = pipe(prompt=prompt,
|
503 |
num_inference_steps=num_inference_steps,
|
504 |
vp_pos=vp_pos,
|
@@ -606,8 +615,8 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
606 |
with gr.Accordion("Examples of Effective Comments", open=False):
|
607 |
example_comment_1 = gr.Textbox(
|
608 |
label="Example 1",
|
609 |
-
lines=
|
610 |
-
value="
|
611 |
)
|
612 |
|
613 |
example_comment_2 = gr.Textbox(
|
@@ -674,7 +683,7 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
674 |
Generate personalized images using the visual preference extracted from your comments by entering a prompt below! You can adjust the personalization degree to generate results that are more or less personalized and diverse.
|
675 |
""")
|
676 |
|
677 |
-
slider = gr.Slider(value=0.85, minimum=0, maximum=1
|
678 |
|
679 |
with gr.Row():
|
680 |
prompt = gr.Dropdown(
|
@@ -707,7 +716,7 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
707 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
708 |
|
709 |
with gr.Row(elem_id="main-container"):
|
710 |
-
with gr.Accordion("Images generated from the example prompts, but with different extracted preferences. The first image shows the non-personalized baseline generation.", open=
|
711 |
example_prompt = gr.Markdown(f"Prompt: {example_prompts[0]}")
|
712 |
gallery = gr.Gallery(
|
713 |
value=examples[example_prompts[0]],
|
|
|
245 |
elif comment_images[0] in comments:
|
246 |
comments.pop(comment_images[0], None)
|
247 |
|
|
|
248 |
next_comment = ""
|
249 |
if comment_images[0] in comments:
|
250 |
next_comment = comments[comment_images[0]]
|
|
|
262 |
comment_images.append(comment_images[0])
|
263 |
comment_images = comment_images[1:]
|
264 |
|
|
|
265 |
next_comment = ""
|
266 |
if comment_images[0] in comments:
|
267 |
next_comment = comments[comment_images[0]]
|
|
|
277 |
comment_images = comment_images[1:]
|
278 |
comment_images = comment_images[::-1]
|
279 |
|
|
|
280 |
next_comment = ""
|
281 |
if comment_images[0] in comments:
|
282 |
next_comment = comments[comment_images[0]]
|
|
|
338 |
|
339 |
if re.match(r"(.|\n)*Assistant: Liked Art Features: (.|\n)*Disliked Art Features: (.|\n)*", generated_texts):
|
340 |
positive_vp, negative_vp = re.search('.* \nAssistant: Liked Art Features: (.*)\nDisliked Art Features: (.*)', generated_texts).groups()
|
341 |
+
positive_vp = positive_vp.split(", ")
|
342 |
+
negative_vp = negative_vp.split(", ")
|
343 |
+
common = list(set(positive_vp).intersection(negative_vp))
|
344 |
+
|
345 |
+
for vp in positive_vp:
|
346 |
+
if vp in common:
|
347 |
+
positive_vp.remove(vp)
|
348 |
+
|
349 |
+
for vp in negative_vp:
|
350 |
+
if vp in common:
|
351 |
+
negative_vp.remove(vp)
|
352 |
+
|
353 |
+
positive_vp = ", ".join(positive_vp)
|
354 |
+
negative_vp = ", ".join(negative_vp)
|
355 |
gr.Info("Visual preference successfully extracted.")
|
356 |
else:
|
357 |
positive_vp = ""
|
|
|
467 |
]
|
468 |
)
|
469 |
gr.Info("Valid API")
|
|
|
470 |
valid_api = api
|
471 |
|
472 |
except anthropic.AuthenticationError:
|
|
|
508 |
|
509 |
generator = torch.Generator().manual_seed(seed)
|
510 |
|
|
|
511 |
image = pipe(prompt=prompt,
|
512 |
num_inference_steps=num_inference_steps,
|
513 |
vp_pos=vp_pos,
|
|
|
615 |
with gr.Accordion("Examples of Effective Comments", open=False):
|
616 |
example_comment_1 = gr.Textbox(
|
617 |
label="Example 1",
|
618 |
+
lines=2,
|
619 |
+
value="I don't like this at all. The beige colors bother me. It's so minimal and boring. The texture feels too shallow.",
|
620 |
)
|
621 |
|
622 |
example_comment_2 = gr.Textbox(
|
|
|
683 |
Generate personalized images using the visual preference extracted from your comments by entering a prompt below! You can adjust the personalization degree to generate results that are more or less personalized and diverse.
|
684 |
""")
|
685 |
|
686 |
+
slider = gr.Slider(value=0.85, minimum=0, maximum=1, label="Personalization degree", interactive=True)
|
687 |
|
688 |
with gr.Row():
|
689 |
prompt = gr.Dropdown(
|
|
|
716 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
717 |
|
718 |
with gr.Row(elem_id="main-container"):
|
719 |
+
with gr.Accordion("Images generated from the example prompts, but with different extracted preferences. The first image shows the non-personalized baseline generation.", open=True):
|
720 |
example_prompt = gr.Markdown(f"Prompt: {example_prompts[0]}")
|
721 |
gallery = gr.Gallery(
|
722 |
value=examples[example_prompts[0]],
|