Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -139,8 +139,98 @@ comment_images = [
|
|
139 |
"comment_images/55.png"
|
140 |
]
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
comments = {'test.png': "Not sure about the concept, it's too straightforward. Though the boy looks kinda creepy which makes it exciting. the art style is pretty to look at. I like that the colors are muted, but wish they were a bit darker to make it more eerie and add depth.", 'comment_images/0.png': "Hate this with a passion. The colors are too vibrant and don't match at all. I hate these colors in general. The patterns are too abstract and contemporary. a 5-year-old could draw this. pass.", 'comment_images/1.png': "Woah I love the art style. The texture feels like old paper which is oh so beautiful. There are so many details to focus on. I love the expressive lines and how busy the composition is. Even though orange isn't my favorite, the greenish blue color of the water is so gorgeous.", 'comment_images/2.png': "I don't like how monochromatic and muted this one is. but the paperish texture is nice and the details are so intricate.", 'comment_images/3.png': "Oh super pretty! Looks so smooth and wet. Love the details and loose lines too. Feels mystical and magical and eerie. Also dark purples and blues? deep indigo? My fav ever. I'm here for it.", 'comment_images/4.png': "Love the art style. The uncanny vibe and nightmarish horror is so cool. Like its horror but if you squint you can't tell? Love the strange. wish it had more colors though. not a fan of greyscale.", 'comment_images/5.png': 'omg I hate this haha. what the hell. everything about it disgusts me so boring and childish ew.', 'comment_images/6.png': 'yessss. give it to the texture give it to the brushstrokes give it to the style. perfect. just wish the colors were less beige and more bold. I want an active nightmare. but kisses to the surrealism.'}
|
143 |
-
|
144 |
|
145 |
image_index = 0
|
146 |
|
@@ -371,7 +461,7 @@ def api_fn(api):
|
|
371 |
|
372 |
|
373 |
@spaces.GPU(duration=45)
|
374 |
-
def generate(prompt, vp_pos, vp_neg, slider):
|
375 |
if vp_pos == "" and vp_neg == "":
|
376 |
slider = 0
|
377 |
|
@@ -383,7 +473,30 @@ def generate(prompt, vp_pos, vp_neg, slider):
|
|
383 |
vp_degree_pos=slider,
|
384 |
vp_degree_neg=slider
|
385 |
).images[0]
|
386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
|
388 |
def change_vp(extract_vp):
|
389 |
return
|
@@ -396,6 +509,42 @@ def upload_file(files):
|
|
396 |
next_comment = ""
|
397 |
return gr.Image(value=comment_images[0], label=f"image {image_index+1}/{len(comment_images)}", show_label=True), gr.Text(label="Comment", show_label=False, lines=2, max_lines=3, placeholder="Enter your comment", value=next_comment, container=False)
|
398 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
400 |
with gr.Row(elem_id="title-container"):
|
401 |
gr.Markdown(f"""
|
@@ -490,12 +639,10 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
490 |
|
491 |
with gr.Row():
|
492 |
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
placeholder="Enter your prompt",
|
498 |
-
container=False,
|
499 |
)
|
500 |
|
501 |
run_button = gr.Button("Run", scale=0, interactive=True)
|
@@ -503,27 +650,22 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
503 |
result = gr.Image(label="Result", show_label=False, interactive=False)
|
504 |
|
505 |
with gr.Row(elem_id="main-container"):
|
506 |
-
with gr.Accordion("images generated from the same prompt but different extracted preferences
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
"examples/(2).png",
|
511 |
-
"examples/(12).png",
|
512 |
-
"examples/(13).png",
|
513 |
-
"examples/(14).png",
|
514 |
-
"examples/(15).png",
|
515 |
-
"examples/(17).png",
|
516 |
-
"examples/(11).png",
|
517 |
-
"examples/(18).png",
|
518 |
-
]
|
519 |
gallery = gr.Gallery(
|
520 |
-
value=examples,
|
521 |
label="",
|
522 |
show_label=False,
|
523 |
columns=[5],
|
524 |
rows=[2],
|
525 |
object_fit="contain",
|
526 |
height=500)
|
|
|
|
|
|
|
|
|
527 |
|
528 |
|
529 |
submit_comment_button.click(
|
@@ -558,8 +700,8 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
558 |
|
559 |
run_button.click(
|
560 |
fn = generate,
|
561 |
-
inputs = [prompt, positive_extracted_vp, negative_extracted_vp, slider],
|
562 |
-
outputs = [result],
|
563 |
)
|
564 |
|
565 |
positive_extracted_vp.change(
|
@@ -586,4 +728,16 @@ with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
|
586 |
[comment_image, comment]
|
587 |
)
|
588 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
demo.launch(share=True)
|
|
|
139 |
"comment_images/55.png"
|
140 |
]
|
141 |
|
142 |
+
example_prompts = [
|
143 |
+
"Painting of a lady",
|
144 |
+
"Cityscape during a thunderstorm",
|
145 |
+
"Inside an abondoned train, window view",
|
146 |
+
"A person reaching for stars",
|
147 |
+
"Abandoned robot at the depth of the sea",
|
148 |
+
"Lonely astronaut in abyss",
|
149 |
+
"Human in a frame"
|
150 |
+
]
|
151 |
+
|
152 |
+
examples = {
|
153 |
+
"A person reaching for stars":[
|
154 |
+
"examples/A person reaching fo_1.png",
|
155 |
+
"examples/A person reaching fo_2.png",
|
156 |
+
"examples/A person reaching fo_3.png",
|
157 |
+
"examples/A person reaching fo_4.png",
|
158 |
+
"examples/A person reaching fo_5.png",
|
159 |
+
"examples/A person reaching fo_6.png",
|
160 |
+
"examples/A person reaching fo_8.png",
|
161 |
+
"examples/A person reaching fo_9.png",
|
162 |
+
"examples/A person reaching fo_10.png",
|
163 |
+
],
|
164 |
+
"Abandoned robot at the depth of the sea":[
|
165 |
+
"examples/Abandoned robot at t_1.png",
|
166 |
+
"examples/Abandoned robot at t_2.png",
|
167 |
+
"examples/Abandoned robot at t_3.png",
|
168 |
+
"examples/Abandoned robot at t_4.png",
|
169 |
+
"examples/Abandoned robot at t_5.png",
|
170 |
+
"examples/Abandoned robot at t_6.png",
|
171 |
+
"examples/Abandoned robot at t_8.png",
|
172 |
+
"examples/Abandoned robot at t_9.png",
|
173 |
+
"examples/Abandoned robot at t_10.png",
|
174 |
+
],
|
175 |
+
"Cityscape during a thunderstorm":[
|
176 |
+
"examples/Cityscape during a t_1.png",
|
177 |
+
"examples/Cityscape during a t_2.png",
|
178 |
+
"examples/Cityscape during a t_3.png",
|
179 |
+
"examples/Cityscape during a t_4.png",
|
180 |
+
"examples/Cityscape during a t_5.png",
|
181 |
+
"examples/Cityscape during a t_6.png",
|
182 |
+
"examples/Cityscape during a t_8.png",
|
183 |
+
"examples/Cityscape during a t_9.png",
|
184 |
+
"examples/Cityscape during a t_10.png",
|
185 |
+
],
|
186 |
+
"Human in a frame":[
|
187 |
+
"examples/Human in a frame_1.png",
|
188 |
+
"examples/Human in a frame_2.png",
|
189 |
+
"examples/Human in a frame_3.png",
|
190 |
+
"examples/Human in a frame_4.png",
|
191 |
+
"examples/Human in a frame_5.png",
|
192 |
+
"examples/Human in a frame_6.png",
|
193 |
+
"examples/Human in a frame_8.png",
|
194 |
+
"examples/Human in a frame_9.png",
|
195 |
+
"examples/Human in a frame_10.png",
|
196 |
+
],
|
197 |
+
"Inside an abondoned train, window view":[
|
198 |
+
"examples/Inside an abondoned _1.png",
|
199 |
+
"examples/Inside an abondoned _2.png",
|
200 |
+
"examples/Inside an abondoned _3.png",
|
201 |
+
"examples/Inside an abondoned _4.png",
|
202 |
+
"examples/Inside an abondoned _5.png",
|
203 |
+
"examples/Inside an abondoned _6.png",
|
204 |
+
"examples/Inside an abondoned _8.png",
|
205 |
+
"examples/Inside an abondoned _9.png",
|
206 |
+
"examples/Inside an abondoned _10.png",
|
207 |
+
],
|
208 |
+
"Lonely astronaut in abyss":[
|
209 |
+
"examples/Lonely astronaut in _1.png",
|
210 |
+
"examples/Lonely astronaut in _2.png",
|
211 |
+
"examples/Lonely astronaut in _3.png",
|
212 |
+
"examples/Lonely astronaut in _4.png",
|
213 |
+
"examples/Lonely astronaut in _5.png",
|
214 |
+
"examples/Lonely astronaut in _6.png",
|
215 |
+
"examples/Lonely astronaut in _8.png",
|
216 |
+
"examples/Lonely astronaut in _9.png",
|
217 |
+
"examples/Lonely astronaut in _10.png",
|
218 |
+
],
|
219 |
+
"Painting of a lady":[
|
220 |
+
"examples/Painting of a lady_1.png",
|
221 |
+
"examples/Painting of a lady_2.png",
|
222 |
+
"examples/Painting of a lady_3.png",
|
223 |
+
"examples/Painting of a lady_4.png",
|
224 |
+
"examples/Painting of a lady_5.png",
|
225 |
+
"examples/Painting of a lady_6.png",
|
226 |
+
"examples/Painting of a lady_8.png",
|
227 |
+
"examples/Painting of a lady_9.png",
|
228 |
+
"examples/Painting of a lady_10.png",
|
229 |
+
]
|
230 |
+
}
|
231 |
+
|
232 |
comments = {'test.png': "Not sure about the concept, it's too straightforward. Though the boy looks kinda creepy which makes it exciting. the art style is pretty to look at. I like that the colors are muted, but wish they were a bit darker to make it more eerie and add depth.", 'comment_images/0.png': "Hate this with a passion. The colors are too vibrant and don't match at all. I hate these colors in general. The patterns are too abstract and contemporary. a 5-year-old could draw this. pass.", 'comment_images/1.png': "Woah I love the art style. The texture feels like old paper which is oh so beautiful. There are so many details to focus on. I love the expressive lines and how busy the composition is. Even though orange isn't my favorite, the greenish blue color of the water is so gorgeous.", 'comment_images/2.png': "I don't like how monochromatic and muted this one is. but the paperish texture is nice and the details are so intricate.", 'comment_images/3.png': "Oh super pretty! Looks so smooth and wet. Love the details and loose lines too. Feels mystical and magical and eerie. Also dark purples and blues? deep indigo? My fav ever. I'm here for it.", 'comment_images/4.png': "Love the art style. The uncanny vibe and nightmarish horror is so cool. Like its horror but if you squint you can't tell? Love the strange. wish it had more colors though. not a fan of greyscale.", 'comment_images/5.png': 'omg I hate this haha. what the hell. everything about it disgusts me so boring and childish ew.', 'comment_images/6.png': 'yessss. give it to the texture give it to the brushstrokes give it to the style. perfect. just wish the colors were less beige and more bold. I want an active nightmare. but kisses to the surrealism.'}
|
233 |
+
comments = dict()
|
234 |
|
235 |
image_index = 0
|
236 |
|
|
|
461 |
|
462 |
|
463 |
@spaces.GPU(duration=45)
|
464 |
+
def generate(prompt, vp_pos, vp_neg, slider, example_prompt, gallery):
|
465 |
if vp_pos == "" and vp_neg == "":
|
466 |
slider = 0
|
467 |
|
|
|
473 |
vp_degree_pos=slider,
|
474 |
vp_degree_neg=slider
|
475 |
).images[0]
|
476 |
+
|
477 |
+
global example_prompts, examples
|
478 |
+
if prompt in example_prompts:
|
479 |
+
while example_prompts[0] != prompt:
|
480 |
+
example_prompts.append(example_prompts[0])
|
481 |
+
example_prompts = example_prompts[1:]
|
482 |
+
|
483 |
+
example_prompt = gr.Markdown(f"prompt: {example_prompts[0]}")
|
484 |
+
if len(examples[example_prompts[0]]) == 10:
|
485 |
+
examples[example_prompts[0]] = examples[example_prompts[0]][:-1]
|
486 |
+
|
487 |
+
examples[example_prompts[0]].append(image)
|
488 |
+
gallery = gr.Gallery(
|
489 |
+
value=examples[example_prompts[0]],
|
490 |
+
label="",
|
491 |
+
show_label=False,
|
492 |
+
columns=[5],
|
493 |
+
rows=[2],
|
494 |
+
object_fit="contain",
|
495 |
+
height=500)
|
496 |
+
|
497 |
+
|
498 |
+
|
499 |
+
return image, example_prompt, gallery
|
500 |
|
501 |
def change_vp(extract_vp):
|
502 |
return
|
|
|
509 |
next_comment = ""
|
510 |
return gr.Image(value=comment_images[0], label=f"image {image_index+1}/{len(comment_images)}", show_label=True), gr.Text(label="Comment", show_label=False, lines=2, max_lines=3, placeholder="Enter your comment", value=next_comment, container=False)
|
511 |
|
512 |
+
def next_prompt():
|
513 |
+
global example_prompts, examples
|
514 |
+
example_prompts.append(example_prompts[0])
|
515 |
+
example_prompts = example_prompts[1:]
|
516 |
+
|
517 |
+
example_prompt = gr.Markdown(f"prompt: {example_prompts[0]}")
|
518 |
+
gallery = gr.Gallery(
|
519 |
+
value=examples[example_prompts[0]],
|
520 |
+
label="",
|
521 |
+
show_label=False,
|
522 |
+
columns=[5],
|
523 |
+
rows=[2],
|
524 |
+
object_fit="contain",
|
525 |
+
height=500)
|
526 |
+
|
527 |
+
return example_prompt, gallery
|
528 |
+
|
529 |
+
def previous_prompt():
|
530 |
+
global example_prompts, examples
|
531 |
+
example_prompts = example_prompts[::-1]
|
532 |
+
example_prompts.append(example_prompts[0])
|
533 |
+
example_prompts = example_prompts[1:]
|
534 |
+
example_prompts = example_prompts[::-1]
|
535 |
+
|
536 |
+
example_prompt = gr.Markdown(f"prompt: {example_prompts[0]}")
|
537 |
+
gallery = gr.Gallery(
|
538 |
+
value=examples[example_prompts[0]],
|
539 |
+
label="",
|
540 |
+
show_label=False,
|
541 |
+
columns=[5],
|
542 |
+
rows=[2],
|
543 |
+
object_fit="contain",
|
544 |
+
height=500)
|
545 |
+
|
546 |
+
return example_prompt, gallery
|
547 |
+
|
548 |
with gr.Blocks(css=css, title="ViPer Demo", theme=gr.themes.Base()) as demo:
|
549 |
with gr.Row(elem_id="title-container"):
|
550 |
gr.Markdown(f"""
|
|
|
639 |
|
640 |
with gr.Row():
|
641 |
|
642 |
+
|
643 |
+
|
644 |
+
prompt = gr.Dropdown(
|
645 |
+
example_prompts, label="Prompt", info="Enter your prompt", allow_custom_value=True, multiselect=False, show_label=False
|
|
|
|
|
646 |
)
|
647 |
|
648 |
run_button = gr.Button("Run", scale=0, interactive=True)
|
|
|
650 |
result = gr.Image(label="Result", show_label=False, interactive=False)
|
651 |
|
652 |
with gr.Row(elem_id="main-container"):
|
653 |
+
with gr.Accordion("images generated from the same prompt but different extracted preferences", open=False):
|
654 |
+
|
655 |
+
|
656 |
+
example_prompt = gr.Markdown(f"prompt: {example_prompts[0]}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
657 |
gallery = gr.Gallery(
|
658 |
+
value=examples[example_prompts[0]],
|
659 |
label="",
|
660 |
show_label=False,
|
661 |
columns=[5],
|
662 |
rows=[2],
|
663 |
object_fit="contain",
|
664 |
height=500)
|
665 |
+
|
666 |
+
with gr.Row():
|
667 |
+
pre_prompt_button = gr.Button("Previous prompt", scale=1, interactive=True)
|
668 |
+
next_prompt_button = gr.Button("Next prompt", scale=1, interactive=True)
|
669 |
|
670 |
|
671 |
submit_comment_button.click(
|
|
|
700 |
|
701 |
run_button.click(
|
702 |
fn = generate,
|
703 |
+
inputs = [prompt, positive_extracted_vp, negative_extracted_vp, slider, example_prompt, gallery],
|
704 |
+
outputs = [result, example_prompt, gallery],
|
705 |
)
|
706 |
|
707 |
positive_extracted_vp.change(
|
|
|
728 |
[comment_image, comment]
|
729 |
)
|
730 |
|
731 |
+
next_prompt_button.click(
|
732 |
+
fn = next_prompt,
|
733 |
+
inputs = [],
|
734 |
+
outputs = [example_prompt, gallery]
|
735 |
+
)
|
736 |
+
|
737 |
+
pre_prompt_button.click(
|
738 |
+
fn = previous_prompt,
|
739 |
+
inputs = [],
|
740 |
+
outputs = [example_prompt, gallery]
|
741 |
+
)
|
742 |
+
|
743 |
demo.launch(share=True)
|