Karumoon commited on
Commit
35a2bab
·
1 Parent(s): bebfc14

Update app.py

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