phenomenon1981 commited on
Commit
39e9a15
1 Parent(s): 77ba53e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +85 -64
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", preprocess=True, postprocess=False)
9
- proc2=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0", preprocess=True, postprocess=False)
10
- proc3=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0", preprocess=True, postprocess=False)
11
- proc4=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0", preprocess=True, postprocess=False)
12
- proc5=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0", preprocess=True, postprocess=False)
13
- proc6=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0", preprocess=True, postprocess=False)
14
- proc7=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0", preprocess=True, postprocess=False)
15
- proc8=gr.Interface.load("models/dreamlike-art/dreamlike-diffusion-1.0", preprocess=True, postprocess=False)
16
-
17
-
18
- def send_it1(inputs, proc1=proc1):
19
- output1=proc1(inputs)
20
- return(output1)
21
- def send_it2(inputs, proc2=proc2):
22
- output2=proc2(inputs)
23
- return(output2)
24
- def send_it3(inputs, proc3=proc3):
25
- output3=proc3(inputs)
26
- return(output3)
27
- def send_it4(inputs, proc4=proc4):
28
- output4=proc4(inputs)
29
- return(output4)
30
- def send_it5(inputs, proc5=proc5):
31
- output5=proc5(inputs)
32
- return(output5)
33
- def send_it6(inputs, proc6=proc6):
34
- output6=proc6(inputs)
35
- return(output6)
36
- def send_it7(inputs, proc7=proc7):
37
- output7=proc7(inputs)
38
- return(output7)
39
- def send_it8(inputs, proc8=proc8):
40
- output8=proc8(inputs)
41
- return(output8)
 
 
 
42
 
43
  def get_prompts(prompt_text):
44
  return text_gen(prompt_text)
45
 
46
- def add_noise(prompt_text):
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
- input_text=gr.Textbox(label="Short Prompt")
53
- see_prompts=gr.Button("Magic Prompt")
54
- with gr.Row():
55
- prompt=gr.Textbox(label="Prettified Prompt")
56
- run=gr.Button("Launch")
57
-
58
- with gr.Row():
59
- output1=gr.Image(label="DreamlikeArt PhotoReal 1")
60
- output2=gr.Image(label="DreamlikeArt PhotoReal 2")
61
- output3=gr.Image(label="DreamlikeArt PhotoReal 3")
62
- output4=gr.Image(label="DreamlikeArt PhotoReal 4")
63
- with gr.Row():
64
- output5=gr.Image(label="DreamlikeArt Diffusion 1")
65
- output6=gr.Image(label="DreamlikeArt Diffusion 2")
66
- output7=gr.Image(label="DreamlikeArt Diffusion 3")
67
- output8=gr.Image(label="DreamlikeArt Diffusion 4")
68
-
69
- see_prompts.click(lambda: prompt.set_input(get_prompts(input_text.get_input())))
70
-
71
- run.click(lambda: [output1.set_input(send_it1(add_noise(prompt.get_input()))),
72
- output2.set_input(send_it2(add_noise(prompt.get_input()))),
73
- output3.set_input(send_it3(add_noise(prompt.get_input()))),
74
- output4.set_input(send_it4(add_noise(prompt.get_input()))),
75
- output5.set_input(send_it5(add_noise(prompt.get_input()))),
76
- output6.set_input(send_it6(add_noise(prompt.get_input()))),
77
- output7.set_input(send_it7(add_noise(prompt.get_input()))),
78
- output8.set_input(send_it8(add_noise(prompt.get_input())))])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)