Omnibus commited on
Commit
b582a22
·
1 Parent(s): 3a29fb0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +311 -0
app.py ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import sys
4
+ from pathlib import Path
5
+ import time
6
+
7
+ models =[
8
+ "",
9
+ "CompVis/stable-diffusion-v1-4",
10
+ "runwayml/stable-diffusion-v1-5",
11
+ "prompthero/openjourney",
12
+ "stabilityai/stable-diffusion-2-1",
13
+ "stabilityai/stable-diffusion-2-1-base",
14
+ "andite/anything-v4.0",
15
+ "Linaqruf/anything-v3.0",
16
+ "eimiss/EimisAnimeDiffusion_1.0v",
17
+ "nitrosocke/Nitro-Diffusion",
18
+ "wavymulder/portraitplus",
19
+ "22h/vintedois-diffusion-v0-1",
20
+ "dreamlike-art/dreamlike-photoreal-2.0",
21
+ "dreamlike-art/dreamlike-diffusion-1.0",
22
+ "wavymulder/Analog-Diffusion",
23
+ "nitrosocke/redshift-diffusion",
24
+ "claudfuen/photorealistic-fuen-v1",
25
+ "prompthero/openjourney-v2",
26
+ "johnslegers/epic-diffusion",
27
+ "nitrosocke/Arcane-Diffusion",
28
+ "darkstorm2150/Protogen_x5.8_Official_Release",
29
+
30
+ ]
31
+
32
+ model_1=models[1]
33
+ model_2=models[2]
34
+ model_3=models[3]
35
+ model_4=models[4]
36
+ model_5=models[5]
37
+ model_6=models[6]
38
+ model_7=models[7]
39
+ model_8=models[8]
40
+ model_9=models[9]
41
+ model_10=models[10]
42
+ model_11=models[11]
43
+ model_12=models[12]
44
+ model_13=models[13]
45
+ model_14=models[14]
46
+ model_15=models[15]
47
+ model_16=models[16]
48
+ model_17=models[17]
49
+ model_18=models[18]
50
+ model_19=models[19]
51
+ model_20=models[20]
52
+
53
+ text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link",live=True, preprocess=True)
54
+
55
+ proc1=gr.Interface.load(f"models/{model_1}",live=False,preprocess=True, postprocess=False)
56
+ proc2=gr.Interface.load(f"models/{model_2}",live=False,preprocess=True, postprocess=False)
57
+ proc3=gr.Interface.load(f"models/{model_3}",live=False,preprocess=True, postprocess=False)
58
+ proc4=gr.Interface.load(f"models/{model_4}",live=False,preprocess=True, postprocess=False)
59
+ proc5=gr.Interface.load(f"models/{model_5}",live=False,preprocess=True, postprocess=False)
60
+ proc6=gr.Interface.load(f"models/{model_6}",live=False,preprocess=True, postprocess=False)
61
+ proc7=gr.Interface.load(f"models/{model_7}",live=False,preprocess=True, postprocess=False)
62
+ proc8=gr.Interface.load(f"models/{model_8}",live=False,preprocess=True, postprocess=False)
63
+ proc9=gr.Interface.load(f"models/{model_9}",live=False,preprocess=True, postprocess=False)
64
+ proc10=gr.Interface.load(f"models/{model_10}",live=False,preprocess=True, postprocess=False)
65
+ proc11=gr.Interface.load(f"models/{model_11}",live=False,preprocess=True, postprocess=False)
66
+ proc12=gr.Interface.load(f"models/{model_12}",live=False,preprocess=True, postprocess=False)
67
+ proc13=gr.Interface.load(f"models/{model_13}",live=False,preprocess=True, postprocess=False)
68
+ proc14=gr.Interface.load(f"models/{model_14}",live=False,preprocess=True, postprocess=False)
69
+ proc15=gr.Interface.load(f"models/{model_15}",live=False,preprocess=True, postprocess=False)
70
+ proc16=gr.Interface.load(f"models/{model_16}",live=False,preprocess=True, postprocess=False)
71
+ proc17=gr.Interface.load(f"models/{model_17}",live=False,preprocess=True, postprocess=False)
72
+ proc18=gr.Interface.load(f"models/{model_18}",live=False,preprocess=True, postprocess=False)
73
+ proc19=gr.Interface.load(f"models/{model_19}",live=False,preprocess=True, postprocess=False)
74
+ proc20=gr.Interface.load(f"models/{model_20}",live=False,preprocess=True, postprocess=False)
75
+
76
+ def get_prompts(prompt_text):
77
+ return text_gen(prompt_text)
78
+ def send_it1(inputs,proc1=proc1):
79
+ output1=proc1(inputs)
80
+ return(output1)
81
+ def send_it2(inputs,proc2=proc2):
82
+ output2=proc2(inputs)
83
+ return(output2)
84
+ def send_it3(inputs,proc3=proc3):
85
+ output3=proc3(inputs)
86
+ return(output3)
87
+ def send_it4(inputs,proc4=proc4):
88
+ output4=proc4(inputs)
89
+ return(output4)
90
+ def send_it5(inputs,proc5=proc5):
91
+ output5=proc5(inputs)
92
+ return(output5)
93
+ def send_it6(inputs,proc6=proc6):
94
+ output6=proc6(inputs)
95
+ return(output6)
96
+ def send_it7(inputs,proc7=proc7):
97
+ output7=proc7(inputs)
98
+ return(output7)
99
+ def send_it8(inputs,proc8=proc8):
100
+ output8=proc8(inputs)
101
+ return(output8)
102
+ def send_it9(inputs,proc9=proc9):
103
+ output9=proc9(inputs)
104
+ return(output9)
105
+ def send_it10(inputs,proc10=proc10):
106
+ output10=proc10(inputs)
107
+ return(output10)
108
+ def send_it11(inputs,proc11=proc11):
109
+ output11=proc11(inputs)
110
+ return(output11)
111
+ def send_it12(inputs,proc12=proc12):
112
+ output12=proc12(inputs)
113
+ return(output12)
114
+ def send_it13(inputs,proc13=proc13):
115
+ output13=proc13(inputs)
116
+ return(output13)
117
+ def send_it14(inputs,proc14=proc14):
118
+ output14=proc14(inputs)
119
+ return(output14)
120
+ def send_it15(inputs,proc15=proc15):
121
+ output15=proc15(inputs)
122
+ return(output15)
123
+ def send_it16(inputs,proc16=proc16):
124
+ output16=proc16(inputs)
125
+ return(output16)
126
+ def send_it17(inputs,proc17=proc17):
127
+ output17=proc17(inputs)
128
+ return(output17)
129
+ def send_it18(inputs,proc18=proc18):
130
+ output18=proc18(inputs)
131
+ return(output18)
132
+ def send_it19(inputs,proc19=proc19):
133
+ output19=proc19(inputs)
134
+ return(output19)
135
+ def send_it20(inputs,proc20=proc20):
136
+ output20=proc20(inputs)
137
+ return(output20)
138
+
139
+ def clear_it(val):
140
+ if int(val) != 0:
141
+ val = 0
142
+ else:
143
+ val = 0
144
+ pass
145
+ return val
146
+
147
+ def sesh_end(cnt,t_stamp):
148
+ to = t_stamp + 180
149
+ et = time.time()
150
+ if et > to and t_stamp != 0:
151
+ d=gr.update(value=0)
152
+ tog=gr.update(value=1)
153
+ #print(f'to: {to} et: {et}')
154
+ else:
155
+ if cnt != 0:
156
+ d=gr.update(value=et)
157
+ else:
158
+ d=gr.update(value=0)
159
+ tog=gr.update(value=0)
160
+ #print (f'passing: to: {to} et: {et}')
161
+ pass
162
+ return d,tog
163
+
164
+ def sesh_start():
165
+ t = time.gmtime()
166
+ t_stamp = time.time()
167
+ current_time = time.strftime("%H:%M:%S", t)
168
+ return gr.update(value=t_stamp),gr.update(value=t_stamp),gr.update(value=0)
169
+
170
+ def clear_fn():
171
+ return None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None
172
+
173
+ with gr.Blocks(css="cake.css") as myface:
174
+ with gr.Column():
175
+ gr.HTML("""<title>Diffusion</title>""")
176
+ gr.Markdown("""<center><h1>Diffusion</h1><center>""")
177
+ gr.Markdown("""<center><h3>So much Diffusion</h3><center>""")
178
+ #time_s = gr.Markdown("""<center><h4>Now Featuring: Non-clogging Queue!</h4></center><br>""")
179
+ with gr.Accordion("Details",open=False):
180
+ with gr.Tab("Description"):
181
+ gr.Markdown("""<center>
182
+ <h4>Enter your Prompt into the "Short Prompt" box and click "Magic Prompt" to load a prettified version of your prompt<br>
183
+ When you are satisfied with the prompt that is in the "Text to Image" box, click "Launch" to load the Models.<br><br>
184
+ Images load faster with a simpler prompt.<br>
185
+ <br>
186
+ Images will cancelling loading at 3 minutes to preserve the quality of the queue.
187
+ <br>
188
+ <br>
189
+ Not responsible for content, use at your own risk.
190
+ </h4></center>""")
191
+ with gr.Tab("DIY"):
192
+ gr.HTML("""<div style="text-align:Left;">
193
+ <h4>Copy/Paste this code in your app.py file<br><br>
194
+ import gradio as gr<br>
195
+ max_d=gr.Interface.load("spaces/Omnibus/maximum_diffusion")<br>
196
+ max_d.launch()<br>
197
+ </h4></div>""")
198
+ with gr.Tab("Credits"):
199
+ with gr.Row():
200
+ gr.Column()
201
+ with gr.Column(style="text-align:left;"):
202
+ gr.HTML("""
203
+ <div style="vertical-align:center">
204
+ <br>
205
+ <p>I learned everything I know from:
206
+ <p><a href="https://huggingface.co/spaces/anzorq/finetuned_diffusion">Finetuned Diffusion</a></p>
207
+ <p><a href="https://huggingface.co/spaces/Gustavosta/MagicPrompt-Stable-Diffusion">Magic Prompt Stable Diffusion</a></p>
208
+ <p><a href="https://huggingface.co/spaces/huggingface-projects/magic-diffusion">Magic Diffusion</a></p>
209
+ <p>Models by <a href="https://huggingface.co/Gustavosta">@Gustavosta</a>, <a href="https://twitter.com/haruu1367">@haruu1367</a>, <a href="https://twitter.com/DGSpitzer">@Helixngc7293</a>, <a href="https://twitter.com/dal_mack">@dal_mack</a>, <a href="https://twitter.com/prompthero">@prompthero</a> and others.</p>
210
+ </div>
211
+ """)
212
+ gr.Column()
213
+ with gr.Tab("Tools"):
214
+ with gr.Tab("View"):
215
+ with gr.Row():
216
+ with gr.Column(style="width=50%"):
217
+ gr.Pil(label="Crop")
218
+ with gr.Column(style="width=50%"):
219
+ gr.Pil(label="Crop")
220
+ with gr.Tab("Draw"):
221
+ with gr.Row():
222
+ with gr.Column(style="width=50%"):
223
+ gr.Pil(label="Crop")
224
+ with gr.Column(style="width=50%"):
225
+ gr.Pil(label="Draw")
226
+ with gr.Tab("Text"):
227
+ with gr.Row():
228
+ with gr.Column(scale=50):
229
+ gr.Textbox(label="", lines=8, interactive=True)
230
+ with gr.Column(scale=50):
231
+ gr.Textbox(label="", lines=8, interactive=True)
232
+ with gr.Tab("Color Picker"):
233
+ with gr.Row():
234
+ with gr.Column(scale=50):
235
+ gr.ColorPicker(label="Color", interactive=True)
236
+ with gr.Column(scale=50):
237
+ gr.ImagePaint(label="Draw", interactive=True)
238
+ with gr.Box(visible=True) as timo:
239
+ with gr.Row():
240
+ with gr.Column():
241
+ input_text=gr.Textbox(label="Short Prompt")
242
+ prompt=gr.Textbox(label="Text to Image",visible=True)
243
+ with gr.Column():
244
+ with gr.Row():
245
+ see_prompts=gr.Button("Magic Prompt")
246
+ with gr.Row():
247
+ with gr.Column():
248
+ run=gr.Button("Launch")
249
+ with gr.Column():
250
+ clear_btn=gr.Button("Clear")
251
+ with gr.Row():
252
+ output1=gr.Image(label=(f"{model_1}"),visible=True)
253
+ output2=gr.Image(label=(f"{model_2}"),visible=True)
254
+ output3=gr.Image(label=(f"{model_3}"),visible=True)
255
+ output4=gr.Image(label=(f"{model_4}"),visible=True)
256
+ with gr.Row():
257
+ output5=gr.Image(label=(f"{model_5}"),visible=True)
258
+ output6=gr.Image(label=(f"{model_6}"),visible=True)
259
+ output7=gr.Image(label=(f"{model_7}"),visible=True)
260
+ output8=gr.Image(label=(f"{model_8}"),visible=True)
261
+ with gr.Row():
262
+ output9=gr.Image(label=(f"{model_9}"),visible=True)
263
+ output10=gr.Image(label=(f"{model_10}"),visible=True)
264
+ output11=gr.Image(label=(f"{model_11}"),visible=True)
265
+ output12=gr.Image(label=(f"{model_12}"),visible=True)
266
+ with gr.Row():
267
+ output13=gr.Image(label=(f"{model_13}"),visible=True)
268
+ output14=gr.Image(label=(f"{model_14}"),visible=True)
269
+ output15=gr.Image(label=(f"{model_15}"),visible=True)
270
+ output16=gr.Image(label=(f"{model_16}"),visible=True)
271
+ with gr.Row():
272
+ output17=gr.Image(label=(f"{model_17}"),visible=True)
273
+ output18=gr.Image(label=(f"{model_18}"),visible=True)
274
+ output19=gr.Image(label=(f"{model_19}"),visible=True)
275
+ output20=gr.Image(label=(f"{model_20}"),visible=True)
276
+ with gr.Row(visible=False):
277
+ start_box=gr.Number(interactive=False)
278
+ end_box=gr.Number(interactive=False)
279
+ tog_box=gr.Textbox(value=0,interactive=False)
280
+
281
+ start_box.change(sesh_end,[start_box,end_box],[start_box,tog_box],show_progress=False)
282
+ run.click(sesh_start,None,[start_box,end_box,tog_box])
283
+ run1=run.click(send_it1, inputs=[prompt], outputs=[output1])
284
+ run2=run.click(send_it2, inputs=[prompt], outputs=[output2])
285
+ run3=run.click(send_it3, inputs=[prompt], outputs=[output3])
286
+ run4=run.click(send_it4, inputs=[prompt], outputs=[output4])
287
+ run5=run.click(send_it5, inputs=[prompt], outputs=[output5])
288
+ run6=run.click(send_it6, inputs=[prompt], outputs=[output6])
289
+ run7=run.click(send_it7, inputs=[prompt], outputs=[output7])
290
+ run8=run.click(send_it8, inputs=[prompt], outputs=[output8])
291
+ run9=run.click(send_it9, inputs=[prompt], outputs=[output9])
292
+ run10=run.click(send_it10, inputs=[prompt], outputs=[output10])
293
+ run11=run.click(send_it11, inputs=[prompt], outputs=[output11])
294
+ run12=run.click(send_it12, inputs=[prompt], outputs=[output12])
295
+ run13=run.click(send_it13, inputs=[prompt], outputs=[output13])
296
+ run14=run.click(send_it14, inputs=[prompt], outputs=[output14])
297
+ run15=run.click(send_it15, inputs=[prompt], outputs=[output15])
298
+ run16=run.click(send_it16, inputs=[prompt], outputs=[output16])
299
+ run17=run.click(send_it17, inputs=[prompt], outputs=[output17])
300
+ run18=run.click(send_it18, inputs=[prompt], outputs=[output18])
301
+ run19=run.click(send_it19, inputs=[prompt], outputs=[output19])
302
+ run20=run.click(send_it20, inputs=[prompt], outputs=[output20])
303
+
304
+ prompt1=see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt],cancels=[run1,run2,run3,run4,run5,run6,run7,run8,run9,run10,run11,run12,run13,run14,run15,run16,run17,run18,run19,run20])
305
+ clear_btn.click(clear_fn, None,
306
+ [input_text,prompt,output1,output2,output3,output4,output5,output6,output7,output8,output9,output10,output11,output12,output13,output14,output15,output16,output17,output18,output19,output20],
307
+ cancels=[prompt1,run1,run2,run3,run4,run5,run6,run7,run8,run9,run10,run11,run12,run13,run14,run15,run16,run17,run18,run19,run20])
308
+ tog_box.change(clear_it,tog_box,tog_box,cancels=[run1,run2,run3,run4,run5,run6,run7,run8,run9,run10,run11,run12,run13,run14,run15,run16,run17,run18,run19,run20,prompt1])
309
+
310
+ myface.queue(concurrency_count=60,status_update_rate=1)
311
+ myface.launch(enable_queue=True,inline=True,max_threads=600)