jordonpeter01 commited on
Commit
51163db
·
1 Parent(s): 34a9d67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -351
app.py CHANGED
@@ -1,352 +1,3 @@
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
-
77
- def emb():
78
- with gr.Blocks(css="cake.css") as myface:
79
- gr.HTML("""<head><meta http-equiv="refresh" content="180"></head>""")
80
-
81
- def send_it1(inputs,proc1=proc1):
82
- output1=proc1(inputs)
83
- return(output1)
84
- def send_it2(inputs,proc2=proc2):
85
- output2=proc2(inputs)
86
- return(output2)
87
- def send_it3(inputs,proc3=proc3):
88
- output3=proc3(inputs)
89
- return(output3)
90
- def send_it4(inputs,proc4=proc4):
91
- output4=proc4(inputs)
92
- return(output4)
93
- def send_it5(inputs,proc5=proc5):
94
- output5=proc5(inputs)
95
- return(output5)
96
- def send_it6(inputs,proc6=proc6):
97
- output6=proc6(inputs)
98
- return(output6)
99
- def send_it7(inputs,proc7=proc7):
100
- output7=proc7(inputs)
101
- return(output7)
102
- def send_it8(inputs,proc8=proc8):
103
- output8=proc8(inputs)
104
- return(output8)
105
- def send_it9(inputs,proc9=proc9):
106
- output9=proc9(inputs)
107
- return(output9)
108
- def send_it10(inputs,proc10=proc10):
109
- output10=proc10(inputs)
110
- return(output10)
111
- def send_it11(inputs,proc11=proc11):
112
- output11=proc11(inputs)
113
- return(output11)
114
- def send_it12(inputs,proc12=proc12):
115
- output12=proc12(inputs)
116
- return(output12)
117
- def send_it13(inputs,proc13=proc13):
118
- output13=proc13(inputs)
119
- return(output13)
120
- def send_it14(inputs,proc14=proc14):
121
- output14=proc14(inputs)
122
- return(output14)
123
- def send_it15(inputs,proc15=proc15):
124
- output15=proc15(inputs)
125
- return(output15)
126
- def send_it16(inputs,proc16=proc16):
127
- output16=proc16(inputs)
128
- return(output16)
129
- def send_it17(inputs,proc17=proc17):
130
- output17=proc17(inputs)
131
- return(output17)
132
- def send_it18(inputs,proc18=proc18):
133
- output18=proc18(inputs)
134
- return(output18)
135
- def send_it19(inputs,proc19=proc19):
136
- output19=proc19(inputs)
137
- return(output19)
138
- def send_it20(inputs,proc20=proc20):
139
- output20=proc20(inputs)
140
- return(output20)
141
-
142
-
143
-
144
- gr.HTML("""<title>Top 20 Diffuion</title>""")
145
- with gr.Column():
146
- gr.Markdown("""<center><h1>Top 20 Diffusion</h1><center>""")
147
- with gr.Accordion("Details",open=False):
148
- with gr.Tab("Description"):
149
- gr.Markdown("""<center>
150
- <h6>Enter your Prompt into the "Short Prompt" box and click "Magic Prompt" to load a prettified version of your prompt<br>
151
- When you are satisfied with the prompt that is in the "Text to Image" box, click "Launch" to load the Models.<br><br>
152
- Images load faster with a simpler prompt.<br>
153
- <br>
154
- Images will cancel loading after 1 minute to preserve the quality of the queue.<br>
155
- Simply Click "Launch" again to try loading the incomplete images.<br>
156
- Page refreshes every 3 minutes for this Demo.
157
- <br>
158
- <br>
159
- Not responsible for content, use at your own risk.
160
- </h6></center>""")
161
- with gr.Tab("DIY"):
162
- gr.HTML("""<div style="text-align:Left;">
163
- <h6>Easy Clone:<br><br>
164
- Copy/Paste this code in your new app.py file<br><br>
165
- import gradio as gr<br>
166
- max_d=gr.Interface.load("spaces/Omnibus/Top-20-Diffusion")<br>
167
- max_d.launch()<br>
168
- </h6></div>""")
169
- with gr.Tab("Credits"):
170
- with gr.Row():
171
- with gr.Column(style="text-align:left;"):
172
- gr.HTML("""
173
- <div style="vertical-align:center">
174
- <br>
175
- <p>Magic Prompt:
176
- <p><a href="https://huggingface.co/spaces/Gustavosta/MagicPrompt-Stable-Diffusion">Magic Prompt Stable Diffusion</a></p>
177
- <p><a href="https://huggingface.co/spaces/huggingface-projects/magic-diffusion">Magic Diffusion</a></p>
178
- </div>
179
- """)
180
- with gr.Column(style="text-align:left;"):
181
- gr.HTML(f"""
182
- <div style="vertical-align:center">
183
- <br>
184
- <p>Models by:<br>
185
- <a href="https://huggingface.co/{models[1]}">{models[1]}</a><br>
186
- <a href="https://huggingface.co/{models[2]}">{models[2]}</a><br>
187
- <a href="https://huggingface.co/{models[3]}">{models[3]}</a><br>
188
- <a href="https://huggingface.co/{models[4]}">{models[4]}</a><br>
189
- <a href="https://huggingface.co/{models[5]}">{models[5]}</a><br>
190
- <a href="https://huggingface.co/{models[6]}">{models[6]}</a><br>
191
- <a href="https://huggingface.co/{models[7]}">{models[7]}</a><br>
192
- <a href="https://huggingface.co/{models[8]}">{models[8]}</a><br>
193
- <a href="https://huggingface.co/{models[9]}">{models[9]}</a><br>
194
- <a href="https://huggingface.co/{models[10]}">{models[10]}</a><br>
195
- <a href="https://huggingface.co/{models[11]}">{models[11]}</a><br>
196
- <a href="https://huggingface.co/{models[12]}">{models[12]}</a><br>
197
- <a href="https://huggingface.co/{models[13]}">{models[13]}</a><br>
198
- <a href="https://huggingface.co/{models[14]}">{models[14]}</a><br>
199
- <a href="https://huggingface.co/{models[15]}">{models[15]}</a><br>
200
- <a href="https://huggingface.co/{models[16]}">{models[16]}</a><br>
201
- <a href="https://huggingface.co/{models[17]}">{models[17]}</a><br>
202
- <a href="https://huggingface.co/{models[18]}">{models[18]}</a><br>
203
- <a href="https://huggingface.co/{models[19]}">{models[19]}</a><br>
204
- <a href="https://huggingface.co/{models[20]}">{models[20]}</a><br>
205
- </p>
206
- </div>
207
- """)
208
- with gr.Tab("Tools"):
209
- with gr.Tab("Draw"):
210
- with gr.Row():
211
- with gr.Column(style="width=50%"):
212
- gr.Pil(label="Crop")
213
- with gr.Column(style="width=50%"):
214
- gr.Pil(label="Draw")
215
- with gr.Tab("View"):
216
- with gr.Row():
217
- with gr.Column():
218
- gr.Pil(label="Crop").style(style="height=500")
219
- with gr.Tab("Color Picker"):
220
- with gr.Row():
221
- with gr.Column(scale=50):
222
- gr.ColorPicker(label="Color", interactive=True)
223
- with gr.Column(scale=50):
224
- gr.ImagePaint(label="Draw", interactive=True)
225
- with gr.Tab("Text"):
226
- with gr.Row():
227
- with gr.Column(scale=50):
228
- gr.Textbox(label="", lines=8, interactive=True)
229
- with gr.Column(scale=50):
230
- gr.Textbox(label="", lines=8, interactive=True)
231
-
232
- with gr.Row():
233
- with gr.Column():
234
- input_text=gr.Textbox(label="Short Prompt")
235
- prompt=gr.Textbox(label="Text to Image Prompt",visible=True)
236
- with gr.Column():
237
- see_prompts=gr.Button("Magic Prompt")
238
- with gr.Row():
239
- run=gr.Button("Launch")
240
- clear_btn=gr.Button("Clear")
241
- with gr.Column() as vald:
242
- with gr.Row():
243
- gr.Markdown("""<center><h3>Content is created by your Prompt</h3></center>""")
244
- with gr.Row():
245
- val_btn = gr.Button("""Click to View""")
246
- with gr.Column(visible=False) as timo:
247
- with gr.Row():
248
- output1=gr.Image(label=(f"{model_1}"),visible=True)
249
- output2=gr.Image(label=(f"{model_2}"),visible=True)
250
- output3=gr.Image(label=(f"{model_3}"),visible=True)
251
- output4=gr.Image(label=(f"{model_4}"),visible=True)
252
- with gr.Row():
253
- output5=gr.Image(label=(f"{model_5}"),visible=True)
254
- output6=gr.Image(label=(f"{model_6}"),visible=True)
255
- output7=gr.Image(label=(f"{model_7}"),visible=True)
256
- output8=gr.Image(label=(f"{model_8}"),visible=True)
257
- with gr.Row():
258
- output9=gr.Image(label=(f"{model_9}"),visible=True)
259
- output10=gr.Image(label=(f"{model_10}"),visible=True)
260
- output11=gr.Image(label=(f"{model_11}"),visible=True)
261
- output12=gr.Image(label=(f"{model_12}"),visible=True)
262
- with gr.Row():
263
- output13=gr.Image(label=(f"{model_13}"),visible=True)
264
- output14=gr.Image(label=(f"{model_14}"),visible=True)
265
- output15=gr.Image(label=(f"{model_15}"),visible=True)
266
- output16=gr.Image(label=(f"{model_16}"),visible=True)
267
- with gr.Row():
268
- output17=gr.Image(label=(f"{model_17}"),visible=True)
269
- output18=gr.Image(label=(f"{model_18}"),visible=True)
270
- output19=gr.Image(label=(f"{model_19}"),visible=True)
271
- output20=gr.Image(label=(f"{model_20}"),visible=True)
272
- with gr.Row(visible=False):
273
- start_box=gr.Number(interactive=False)
274
- end_box=gr.Number(interactive=False)
275
- tog_box=gr.Textbox(value=0,interactive=False)
276
-
277
-
278
- def clear_it(val):
279
- if int(val) != 0:
280
- val = 0
281
- else:
282
- val = 0
283
- pass
284
- return val
285
- def sesh_start():
286
- #t = time.gmtime()
287
- t_stamp = time.time()
288
- #current_time = time.strftime("%H:%M:%S", t)
289
- return gr.update(value=t_stamp),gr.update(value=t_stamp),gr.update(value=0)
290
-
291
- def sesh_end(cnt,t_stamp):
292
- to = t_stamp + 60
293
- et = time.time()
294
- if et > to and t_stamp != 0:
295
- d=gr.update(value=0)
296
- tog=gr.update(value=1)
297
- #print(f'to: {to} et: {et}')
298
- else:
299
- if cnt != 0:
300
- d=gr.update(value=et)
301
- else:
302
- d=gr.update(value=0)
303
- tog=gr.update(value=0)
304
- #print (f'passing: to: {to} et: {et}')
305
- pass
306
- return d,tog
307
-
308
-
309
- def get_prompts(prompt_text):
310
- t_stamp = time.time()
311
- #current_time = time.strftime("%H:%M:%S", t)
312
- gen=text_gen(prompt_text)
313
- return gen,gr.update(value=t_stamp),gr.update(value=t_stamp),gr.update(value=0)
314
-
315
- def clear_fn():
316
- return None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None
317
- def valid_pass():
318
- return gr.Box.update(visible=True),gr.Row.update(visible=False)
319
- val_btn.click(valid_pass,None,[timo,vald])
320
- start_box.change(sesh_end,[start_box,end_box],[start_box,tog_box],every=1,show_progress=False)
321
- run0=run.click(sesh_start,None,[start_box,end_box,tog_box])
322
- run1=run.click(send_it1, inputs=[prompt], outputs=[output1])
323
- run2=run.click(send_it2, inputs=[prompt], outputs=[output2])
324
- run3=run.click(send_it3, inputs=[prompt], outputs=[output3])
325
- run4=run.click(send_it4, inputs=[prompt], outputs=[output4])
326
- run5=run.click(send_it5, inputs=[prompt], outputs=[output5])
327
- run6=run.click(send_it6, inputs=[prompt], outputs=[output6])
328
- run7=run.click(send_it7, inputs=[prompt], outputs=[output7])
329
- run8=run.click(send_it8, inputs=[prompt], outputs=[output8])
330
- run9=run.click(send_it9, inputs=[prompt], outputs=[output9])
331
- run10=run.click(send_it10, inputs=[prompt], outputs=[output10])
332
- run11=run.click(send_it11, inputs=[prompt], outputs=[output11])
333
- run12=run.click(send_it12, inputs=[prompt], outputs=[output12])
334
- run13=run.click(send_it13, inputs=[prompt], outputs=[output13])
335
- run14=run.click(send_it14, inputs=[prompt], outputs=[output14])
336
- run15=run.click(send_it15, inputs=[prompt], outputs=[output15])
337
- run16=run.click(send_it16, inputs=[prompt], outputs=[output16])
338
- run17=run.click(send_it17, inputs=[prompt], outputs=[output17])
339
- run18=run.click(send_it18, inputs=[prompt], outputs=[output18])
340
- run19=run.click(send_it19, inputs=[prompt], outputs=[output19])
341
- run20=run.click(send_it20, inputs=[prompt], outputs=[output20])
342
-
343
- see_prompts.click(sesh_start,None,[start_box,end_box,tog_box])
344
- prompt1=see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt,start_box,end_box,tog_box],cancels=[run1,run2,run3,run4,run5,run6,run7,run8,run9,run10,run11,run12,run13,run14,run15,run16,run17,run18,run19,run20])
345
- clear_btn.click(clear_fn, None,
346
- [input_text,prompt,output1,output2,output3,output4,output5,output6,output7,output8,output9,output10,output11,output12,output13,output14,output15,output16,output17,output18,output19,output20],
347
- cancels=[prompt1,run1,run2,run3,run4,run5,run6,run7,run8,run9,run10,run11,run12,run13,run14,run15,run16,run17,run18,run19,run20])
348
- 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])
349
- myface.queue(concurrency_count=400,status_update_rate=1)
350
- myface.launch(inline=True,show_api=False)
351
- if __name__ == "__main__":
352
- emb()
 
1
  import gradio as gr
2
+ max_d=gr.Interface.load("spaces/Omnibus/Top-20-Diffusion")
3
+ max_d.launch()