Spaces:
Runtime error
Runtime error
phenomenon1981
commited on
Commit
•
39e9a15
1
Parent(s):
77ba53e
Update app.py
Browse files
app.py
CHANGED
@@ -1,78 +1,99 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
import random
|
3 |
import string
|
4 |
|
|
|
5 |
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
|
6 |
|
7 |
|
8 |
-
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0"
|
9 |
-
proc2=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0"
|
10 |
-
proc3=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0"
|
11 |
-
proc4=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0"
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
42 |
|
43 |
def get_prompts(prompt_text):
|
44 |
return text_gen(prompt_text)
|
45 |
|
46 |
-
|
47 |
-
noise = ''.join(random.choice(string.ascii_letters) for i in range(random.randint(1,5)))
|
48 |
-
return prompt_text + noise
|
49 |
|
50 |
with gr.Blocks() as myface:
|
51 |
with gr.Row():
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
+
import sys
|
4 |
+
from pathlib import Path
|
5 |
import random
|
6 |
import string
|
7 |
|
8 |
+
|
9 |
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
|
10 |
|
11 |
|
12 |
+
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
13 |
+
proc2=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
14 |
+
proc3=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
15 |
+
proc4=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
16 |
+
|
17 |
+
proc5=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
18 |
+
proc6=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
19 |
+
proc7=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
20 |
+
proc8=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
21 |
+
|
22 |
+
|
23 |
+
def send_it1(inputs,proc1=proc1):
|
24 |
+
output1=proc1(inputs)
|
25 |
+
return(output1)
|
26 |
+
def send_it2(inputs,proc2=proc2):
|
27 |
+
output2=proc2(inputs)
|
28 |
+
return(output2)
|
29 |
+
def send_it3(inputs,proc3=proc3):
|
30 |
+
output3=proc3(inputs)
|
31 |
+
return(output3)
|
32 |
+
def send_it4(inputs,proc4=proc4):
|
33 |
+
output4=proc4(inputs)
|
34 |
+
return(output4)
|
35 |
+
|
36 |
+
def send_it5(inputs,proc5=proc5):
|
37 |
+
output5=proc5(inputs)
|
38 |
+
return(output5)
|
39 |
+
def send_it6(inputs,proc6=proc6):
|
40 |
+
output6=proc6(inputs)
|
41 |
+
return(output6)
|
42 |
+
def send_it7(inputs,proc7=proc7):
|
43 |
+
output7=proc7(inputs)
|
44 |
+
return(output7)
|
45 |
+
def send_it8(inputs,proc8=proc8):
|
46 |
+
output8=proc8(inputs)
|
47 |
+
return(output8)
|
48 |
+
|
49 |
|
50 |
def get_prompts(prompt_text):
|
51 |
return text_gen(prompt_text)
|
52 |
|
53 |
+
|
|
|
|
|
54 |
|
55 |
with gr.Blocks() as myface:
|
56 |
with gr.Row():
|
57 |
+
|
58 |
+
|
59 |
+
input_text=gr.Textbox(label="Short Prompt")
|
60 |
+
see_prompts=gr.Button("Magic Prompt")
|
61 |
+
with gr.Row():
|
62 |
+
|
63 |
+
prompt=gr.Textbox(label="Prettified Prompt")
|
64 |
+
run=gr.Button("Launch")
|
65 |
+
|
66 |
+
|
67 |
+
with gr.Row():
|
68 |
+
output1=gr.Image(label="DreamlikeArt PhotoReal 1")
|
69 |
+
output2=gr.Image(label="DreamlikeArt PhotoReal 2")
|
70 |
+
output3=gr.Image(label="DreamlikeArt PhotoReal 3")
|
71 |
+
output4=gr.Image(label="DreamlikeArt PhotoReal 4")
|
72 |
+
with gr.Row():
|
73 |
+
output5=gr.Image(label="DreamlikeArt Diffusion 1")
|
74 |
+
output6=gr.Image(label="DreamlikeArt Diffusion 2")
|
75 |
+
output7=gr.Image(label="DreamlikeArt Diffusion 3")
|
76 |
+
output8=gr.Image(label="DreamlikeArt Diffusion 4")
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt])
|
83 |
+
|
84 |
+
def add_noise(input_text):
|
85 |
+
noise = ''.join(random.choice(string.ascii_letters) for i in range(5))
|
86 |
+
return input_text + noise
|
87 |
+
|
88 |
+
run.click(lambda: send_it1(add_noise(prompt.value)), outputs=[output1])
|
89 |
+
run.click(lambda: send_it2(add_noise(prompt.value)), outputs=[output2])
|
90 |
+
run.click(lambda: send_it3(add_noise(prompt.value)), outputs=[output3])
|
91 |
+
run.click(lambda: send_it4(add_noise(prompt.value)), outputs=[output4])
|
92 |
+
run.click(lambda: send_it5(add_noise(prompt.value)), outputs=[output5])
|
93 |
+
run.click(lambda: send_it6(add_noise(prompt.value)), outputs=[output6])
|
94 |
+
run.click(lambda: send_it7(add_noise(prompt.value)), outputs=[output7])
|
95 |
+
run.click(lambda: send_it8(add_noise(prompt.value)), outputs=[output8])
|
96 |
+
|
97 |
+
|
98 |
+
myface.queue(concurrency_count=8)
|
99 |
+
myface.launch(enable_queue=True, inline=True)
|