Omnibus commited on
Commit
d7b584f
·
1 Parent(s): b0a694d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -228
app.py CHANGED
@@ -3,9 +3,11 @@ 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",
@@ -28,116 +30,68 @@ models =[
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
 
@@ -205,147 +159,40 @@ def emb():
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__":
 
3
  import sys
4
  from pathlib import Path
5
  import time
6
+
7
+
8
+
9
+
10
  models =[
 
11
  "CompVis/stable-diffusion-v1-4",
12
  "runwayml/stable-diffusion-v1-5",
13
  "prompthero/openjourney",
 
30
  "darkstorm2150/Protogen_x5.8_Official_Release",
31
 
32
  ]
33
+ current_model = models[5]
34
+
35
+ models2=[
36
+ gr.Interface.load(f"models/{models[0]}",live=True,preprocess=True),
37
+ gr.Interface.load(f"models/{models[1]}",live=True,preprocess=True),
38
+ gr.Interface.load(f"models/{models[2]}",live=True,preprocess=True),
39
+ gr.Interface.load(f"models/{models[3]}",live=True,preprocess=True),
40
+ gr.Interface.load(f"models/{models[4]}",live=True,preprocess=True),
41
+ gr.Interface.load(f"models/{models[5]}",live=True,preprocess=True),
42
+ gr.Interface.load(f"models/{models[6]}",live=True,preprocess=True),
43
+ gr.Interface.load(f"models/{models[7]}",live=True,preprocess=True),
44
+ gr.Interface.load(f"models/{models[8]}",live=True,preprocess=True),
45
+ gr.Interface.load(f"models/{models[9]}",live=True,preprocess=True),
46
+ gr.Interface.load(f"models/{models[10]}",live=True,preprocess=True),
47
+ gr.Interface.load(f"models/{models[11]}",live=True,preprocess=True),
48
+ gr.Interface.load(f"models/{models[12]}",live=True,preprocess=True),
49
+ gr.Interface.load(f"models/{models[13]}",live=True,preprocess=True),
50
+ gr.Interface.load(f"models/{models[14]}",live=True,preprocess=True),
51
+ gr.Interface.load(f"models/{models[15]}",live=True,preprocess=True),
52
+ gr.Interface.load(f"models/{models[16]}",live=True,preprocess=True),
53
+ gr.Interface.load(f"models/{models[17]}",live=True,preprocess=True),
54
+ gr.Interface.load(f"models/{models[18]}",live=True,preprocess=True),
55
+ gr.Interface.load(f"models/{models[19]}",live=True,preprocess=True),
56
+ gr.Interface.load(f"models/{models[20]}",live=True,preprocess=True),
57
+ gr.Interface.load(f"models/{models[21]}",live=True,preprocess=True),
58
+ gr.Interface.load(f"models/{models[22]}",live=True,preprocess=True),
59
+ gr.Interface.load(f"models/{models[23]}",live=True,preprocess=True),
60
+ gr.Interface.load(f"models/{models[24]}",live=True,preprocess=True),
61
+ gr.Interface.load(f"models/{models[25]}",live=True,preprocess=True),
62
+
63
+ ]
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link",live=True, preprocess=True)
67
 
68
+ #proc1=gr.Interface.load(f"models/{model_1}",live=False,preprocess=True, postprocess=False)
69
+ #proc2=gr.Interface.load(f"models/{model_2}",live=False,preprocess=True, postprocess=False)
70
+ #proc3=gr.Interface.load(f"models/{model_3}",live=False,preprocess=True, postprocess=False)
71
+ #proc4=gr.Interface.load(f"models/{model_4}",live=False,preprocess=True, postprocess=False)
72
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
 
75
  def emb():
76
  with gr.Blocks(css="cake.css") as myface:
77
  gr.HTML("""<head><meta http-equiv="refresh" content="180"></head>""")
78
 
79
+ def send_it1(inputs,model_choice):
80
+ output_list=[]
81
+
82
+ proc1=models2[model_choice]
83
+ output1=proc1(inputs)
84
+
85
+ output2=proc1(inputs)
86
+ output3=proc1(inputs)
87
+ output4=proc1(inputs)
88
+ output_list.append(output1)
89
+ output_list.append(output2)
90
+ output_list.append(output3)
91
+ output_list.append(output4)
92
+
93
+ return(output_list)
94
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
 
97
 
 
159
  </p>
160
  </div>
161
  """)
162
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  with gr.Row():
164
  with gr.Column():
165
  input_text=gr.Textbox(label="Short Prompt")
166
  prompt=gr.Textbox(label="Text to Image Prompt",visible=True)
167
+ model_name1 = gr.Dropdown(show_label=False, choices=[m for m in models], type="index", value=current_model, interactive=True)
168
+
169
  with gr.Column():
170
  see_prompts=gr.Button("Magic Prompt")
171
  with gr.Row():
172
  run=gr.Button("Launch")
173
  clear_btn=gr.Button("Clear")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
+ with gr.Column(visible=True) as timo:
176
+ with gr.Row():
177
+ output1=gr.Gallery()
178
+ #output111=gr.Image(label=(f"{model_1}"),visible=True)
179
+ #output2=gr.Image(label=(f"{model_2}"),visible=True)
180
+ #output3=gr.Image(label=(f"{model_3}"),visible=True)
181
+ #output4=gr.Image(label=(f"{model_4}"),visible=True)
182
  def get_prompts(prompt_text):
183
+
 
184
  gen=text_gen(prompt_text)
185
+ return gen
186
 
187
+
188
+ run1=run.click(send_it1, inputs=[prompt, model_name1], outputs=[output1])
189
+ #run2=run.click(send_it2, inputs=[prompt], outputs=[output2])
190
+ #run3=run.click(send_it3, inputs=[prompt], outputs=[output3])
191
+ #run4=run.click(send_it4, inputs=[prompt], outputs=[output4])
192
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  see_prompts.click(sesh_start,None,[start_box,end_box,tog_box])
195
+ prompt1=see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt],cancels=[run1,run2,run3,run4])
 
 
 
 
196
  myface.queue(concurrency_count=400,status_update_rate=1)
197
  myface.launch(inline=True,show_api=False)
198
  if __name__ == "__main__":