Spaces:
Runtime error
Runtime error
Commit
·
6e84704
1
Parent(s):
f11abf1
Update app.py
Browse files
app.py
CHANGED
@@ -4,96 +4,42 @@ import sys
|
|
4 |
import random
|
5 |
from pathlib import Path
|
6 |
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
proc1=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
12 |
-
proc2=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
13 |
-
proc3=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
14 |
-
proc4=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
15 |
-
|
16 |
-
proc5=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
17 |
-
proc6=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
18 |
-
proc7=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
19 |
-
proc8=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
20 |
-
|
21 |
-
|
22 |
-
def send_it1(inputs,proc1=proc1):
|
23 |
-
output1=proc1(inputs)
|
24 |
-
return(output1)
|
25 |
-
def send_it2(inputs,proc2=proc2):
|
26 |
-
output2=proc2(inputs)
|
27 |
-
return(output2)
|
28 |
-
def send_it3(inputs,proc3=proc3):
|
29 |
-
output3=proc3(inputs)
|
30 |
-
return(output3)
|
31 |
-
def send_it4(inputs,proc4=proc4):
|
32 |
-
output4=proc4(inputs)
|
33 |
-
return(output4)
|
34 |
-
|
35 |
-
def send_it5(inputs,proc5=proc5):
|
36 |
-
output5=proc5(inputs)
|
37 |
-
return(output5)
|
38 |
-
def send_it6(inputs,proc6=proc6):
|
39 |
-
output6=proc6(inputs)
|
40 |
-
return(output6)
|
41 |
-
def send_it7(inputs,proc7=proc7):
|
42 |
-
output7=proc7(inputs)
|
43 |
-
return(output7)
|
44 |
-
def send_it8(inputs,proc8=proc8):
|
45 |
-
output8=proc8(inputs)
|
46 |
-
return(output8)
|
47 |
-
|
48 |
-
|
49 |
-
def get_prompts(prompt_text):
|
50 |
-
return text_gen(prompt_text)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
with gr.Blocks() as myface:
|
55 |
-
with gr.Row():
|
56 |
-
|
57 |
-
|
58 |
-
input_text=gr.Textbox(label="Short Prompt")
|
59 |
-
see_prompts=gr.Button("Magic Prompt")
|
60 |
with gr.Row():
|
|
|
|
|
61 |
|
62 |
-
prompt=gr.Textbox(label="Prettified Prompt")
|
63 |
-
run=gr.Button("Launch")
|
64 |
-
|
65 |
-
|
66 |
with gr.Row():
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
output4=gr.Image(label="DreamlikeArt PhotoReal 4")
|
71 |
with gr.Row():
|
72 |
-
|
73 |
-
|
74 |
-
output7=gr.Image(label="DreamlikeArt Diffusion 3")
|
75 |
-
output8=gr.Image(label="DreamlikeArt Diffusion 4")
|
76 |
-
|
77 |
-
|
78 |
-
#def set_models(model_name1, model_name2, model_name3, model_name4):
|
79 |
-
|
80 |
-
#return(proc1,proc2,proc3,proc4)
|
81 |
-
|
82 |
-
#run.click(set_models, inputs=[model_name1, model_name2, model_name3, model_name4], outputs=[proc1,proc2,proc3,proc4])
|
83 |
-
#run.click(send_it, inputs=[prompt], outputs=[output1, output2, output3, output4])
|
84 |
-
|
85 |
-
|
86 |
-
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt])
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
run.click(send_it3, inputs=[prompt], outputs=[output3])
|
91 |
-
run.click(send_it4, inputs=[prompt], outputs=[output4])
|
92 |
-
run.click(send_it5, inputs=[prompt], outputs=[output5])
|
93 |
-
run.click(send_it6, inputs=[prompt], outputs=[output6])
|
94 |
-
run.click(send_it7, inputs=[prompt], outputs=[output7])
|
95 |
-
run.click(send_it8, inputs=[prompt], outputs=[output8])
|
96 |
-
|
97 |
|
98 |
-
|
99 |
-
|
|
|
4 |
import random
|
5 |
from pathlib import Path
|
6 |
|
7 |
+
# Load all models at once
|
8 |
+
proc1 = gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
|
9 |
+
proc2 = gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0")
|
10 |
|
11 |
+
# Load text generation model
|
12 |
+
text_gen = gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
def generate_images(prompt_text):
|
15 |
+
# generate prompts
|
16 |
+
prompts = text_gen(prompt_text)
|
17 |
+
|
18 |
+
# run both models on all prompts
|
19 |
+
output1 = proc1(prompts)
|
20 |
+
output2 = proc2(prompts)
|
21 |
+
|
22 |
+
return output1, output2
|
23 |
|
24 |
+
with gr.Blocks(title="DreamlikeArt Generator") as myface:
|
25 |
+
with gr.Row(title="Instructions", padding=20):
|
26 |
+
gr.Label("Enter a short prompt below and click 'Magic Prompt' to generate prettified prompts.")
|
27 |
+
gr.Label("Then, select the models to run and click 'Launch' to generate images.")
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
with gr.Row():
|
30 |
+
input_text = gr.Textbox(label="Short Prompt")
|
31 |
+
see_prompts = gr.Button("Magic Prompt")
|
32 |
|
|
|
|
|
|
|
|
|
33 |
with gr.Row():
|
34 |
+
prompt = gr.Textbox(label="Prettified Prompt", output=True)
|
35 |
+
run = gr.Button("Launch")
|
36 |
+
|
|
|
37 |
with gr.Row():
|
38 |
+
output1 = gr.Image(label="DreamlikeArt PhotoReal", output=True)
|
39 |
+
output2 = gr.Image(label="DreamlikeArt Diffusion", output=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
with gr.Row():
|
42 |
+
model_select = gr.Checkbox(["DreamlikeArt PhotoReal", "DreamlikeArt Diffusion"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
+
see_prompts.click(text_gen, inputs=[input_text], outputs=[prompt])
|
45 |
+
run.click(generate_images, inputs=[prompt], outputs=[output1, output2], control_inputs=[model_select], control_outputs=[output1, output2])
|