Spaces:
Runtime error
Runtime error
File size: 16,499 Bytes
58e3dab 94f30d7 58e3dab 94f30d7 34875cb 94f30d7 58e3dab 34875cb 58e3dab 34875cb 58e3dab 34875cb 58e3dab 34875cb 58e3dab 34875cb 58e3dab 34875cb 94f30d7 58e3dab 94f30d7 58e3dab 94f30d7 58e3dab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
import gradio as gr
import os
import sys
from pathlib import Path
import time
models =[
"",
"CompVis/stable-diffusion-v1-4",
"runwayml/stable-diffusion-v1-5",
"prompthero/openjourney",
"stabilityai/stable-diffusion-2-1",
"stabilityai/stable-diffusion-2-1-base",
"andite/anything-v4.0",
"Linaqruf/anything-v3.0",
"eimiss/EimisAnimeDiffusion_1.0v",
"nitrosocke/Nitro-Diffusion",
"wavymulder/portraitplus",
"22h/vintedois-diffusion-v0-1",
"dreamlike-art/dreamlike-photoreal-2.0",
"dreamlike-art/dreamlike-diffusion-1.0",
"wavymulder/Analog-Diffusion",
"nitrosocke/redshift-diffusion",
"claudfuen/photorealistic-fuen-v1",
"prompthero/openjourney-v2",
"johnslegers/epic-diffusion",
"nitrosocke/Arcane-Diffusion",
"darkstorm2150/Protogen_x5.8_Official_Release",
]
model_1=models[1]
model_2=models[2]
model_3=models[3]
model_4=models[4]
model_5=models[5]
model_6=models[6]
model_7=models[7]
model_8=models[8]
model_9=models[9]
model_10=models[10]
model_11=models[11]
model_12=models[12]
model_13=models[13]
model_14=models[14]
model_15=models[15]
model_16=models[16]
model_17=models[17]
model_18=models[18]
model_19=models[19]
model_20=models[20]
text_gen=gr.Interface.load("spaces/Dao3/MagicPrompt-Stable-Diffusion",live=True, preprocess=True)
proc1=gr.Interface.load(f"models/{model_1}",live=False,preprocess=True, postprocess=False)
proc2=gr.Interface.load(f"models/{model_2}",live=False,preprocess=True, postprocess=False)
proc3=gr.Interface.load(f"models/{model_3}",live=False,preprocess=True, postprocess=False)
proc4=gr.Interface.load(f"models/{model_4}",live=False,preprocess=True, postprocess=False)
proc5=gr.Interface.load(f"models/{model_5}",live=False,preprocess=True, postprocess=False)
proc6=gr.Interface.load(f"models/{model_6}",live=False,preprocess=True, postprocess=False)
proc7=gr.Interface.load(f"models/{model_7}",live=False,preprocess=True, postprocess=False)
proc8=gr.Interface.load(f"models/{model_8}",live=False,preprocess=True, postprocess=False)
proc9=gr.Interface.load(f"models/{model_9}",live=False,preprocess=True, postprocess=False)
proc10=gr.Interface.load(f"models/{model_10}",live=False,preprocess=True, postprocess=False)
proc11=gr.Interface.load(f"models/{model_11}",live=False,preprocess=True, postprocess=False)
proc12=gr.Interface.load(f"models/{model_12}",live=False,preprocess=True, postprocess=False)
proc13=gr.Interface.load(f"models/{model_13}",live=False,preprocess=True, postprocess=False)
proc14=gr.Interface.load(f"models/{model_14}",live=False,preprocess=True, postprocess=False)
proc15=gr.Interface.load(f"models/{model_15}",live=False,preprocess=True, postprocess=False)
proc16=gr.Interface.load(f"models/{model_16}",live=False,preprocess=True, postprocess=False)
proc17=gr.Interface.load(f"models/{model_17}",live=False,preprocess=True, postprocess=False)
proc18=gr.Interface.load(f"models/{model_18}",live=False,preprocess=True, postprocess=False)
proc19=gr.Interface.load(f"models/{model_19}",live=False,preprocess=True, postprocess=False)
proc20=gr.Interface.load(f"models/{model_20}",live=False,preprocess=True, postprocess=False)
def get_prompts(prompt_text):
return text_gen(prompt_text)
def send_it1(inputs,proc1=proc1):
output1=proc1(inputs)
return(output1)
def send_it2(inputs,proc2=proc2):
output2=proc2(inputs)
return(output2)
def send_it3(inputs,proc3=proc3):
output3=proc3(inputs)
return(output3)
def send_it4(inputs,proc4=proc4):
output4=proc4(inputs)
return(output4)
def send_it5(inputs,proc5=proc5):
output5=proc5(inputs)
return(output5)
def send_it6(inputs,proc6=proc6):
output6=proc6(inputs)
return(output6)
def send_it7(inputs,proc7=proc7):
output7=proc7(inputs)
return(output7)
def send_it8(inputs,proc8=proc8):
output8=proc8(inputs)
return(output8)
def send_it9(inputs,proc9=proc9):
output9=proc9(inputs)
return(output9)
def send_it10(inputs,proc10=proc10):
output10=proc10(inputs)
return(output10)
def send_it11(inputs,proc11=proc11):
output11=proc11(inputs)
return(output11)
def send_it12(inputs,proc12=proc12):
output12=proc12(inputs)
return(output12)
def send_it13(inputs,proc13=proc13):
output13=proc13(inputs)
return(output13)
def send_it14(inputs,proc14=proc14):
output14=proc14(inputs)
return(output14)
def send_it15(inputs,proc15=proc15):
output15=proc15(inputs)
return(output15)
def send_it16(inputs,proc16=proc16):
output16=proc16(inputs)
return(output16)
def send_it17(inputs,proc17=proc17):
output17=proc17(inputs)
return(output17)
def send_it18(inputs,proc18=proc18):
output18=proc18(inputs)
return(output18)
def send_it19(inputs,proc19=proc19):
output19=proc19(inputs)
return(output19)
def send_it20(inputs,proc20=proc20):
output20=proc20(inputs)
return(output20)
with gr.Blocks(css="cake.css") as myface:
gr.HTML("""<head><meta http-equiv="refresh" content="600"></head>""")
with gr.Column():
gr.HTML("""<title>SD的二十个最流行模型</title>""")
gr.Markdown("""<center><h1>20个SD流行模型</h1><center>""")
gr.Markdown("""<center><h4>爽歪歪</h4><center>""")
with gr.Accordion("使用说明",open=False):
with gr.Tab("Description"):
gr.Markdown("""<center>
<h4>在第一个输入框内填写你想画的内容,然后点击"完善"按钮,第二个输入框会自动出现经过完善后的提示词。然后点击"开始",下面的20个模型就开始为你疯狂了~<br>
<br>
部分模型的图像不出现的话,重新点击"开始"按钮即可
<br>
间隔十分钟后模型会生成新的图像
<br>
我们不对最终生成的内容负责,权责自负哦~
</h4></center>""")
with gr.Tab("DIY"):
gr.HTML("""<div style="text-align:Left;">
<h4>Easy Clone:<br><br>
Copy/Paste this code in your new app.py file<br><br>
import gradio as gr<br>
max_d=gr.Interface.load("spaces/Dao3/Top-20-Models")<br>
max_d.launch()<br>
</h4></div>""")
with gr.Tab("Credits"):
with gr.Row():
with gr.Column(style="text-align:left;"):
gr.HTML("""
<div style="vertical-align:center">
<br>
<p>Magic Prompt:
<p><a href="https://huggingface.co/spaces/Gustavosta/MagicPrompt-Stable-Diffusion">Magic Prompt Stable Diffusion</a></p>
<p><a href="https://huggingface.co/spaces/huggingface-projects/magic-diffusion">Magic Diffusion</a></p>
</div>
""")
with gr.Column(style="text-align:left;"):
gr.HTML(f"""
<div style="vertical-align:center">
<br>
<p>Models by:<br>
<a href="https://huggingface.co/{models[1]}">{models[1]}</a><br>
<a href="https://huggingface.co/{models[2]}">{models[2]}</a><br>
<a href="https://huggingface.co/{models[3]}">{models[3]}</a><br>
<a href="https://huggingface.co/{models[4]}">{models[4]}</a><br>
<a href="https://huggingface.co/{models[5]}">{models[5]}</a><br>
<a href="https://huggingface.co/{models[6]}">{models[6]}</a><br>
<a href="https://huggingface.co/{models[7]}">{models[7]}</a><br>
<a href="https://huggingface.co/{models[8]}">{models[8]}</a><br>
<a href="https://huggingface.co/{models[9]}">{models[9]}</a><br>
<a href="https://huggingface.co/{models[10]}">{models[10]}</a><br>
<a href="https://huggingface.co/{models[11]}">{models[11]}</a><br>
<a href="https://huggingface.co/{models[12]}">{models[12]}</a><br>
<a href="https://huggingface.co/{models[13]}">{models[13]}</a><br>
<a href="https://huggingface.co/{models[14]}">{models[14]}</a><br>
<a href="https://huggingface.co/{models[15]}">{models[15]}</a><br>
<a href="https://huggingface.co/{models[16]}">{models[16]}</a><br>
<a href="https://huggingface.co/{models[17]}">{models[17]}</a><br>
<a href="https://huggingface.co/{models[18]}">{models[18]}</a><br>
<a href="https://huggingface.co/{models[19]}">{models[19]}</a><br>
<a href="https://huggingface.co/{models[20]}">{models[20]}</a><br>
</p>
</div>
""")
with gr.Tab("Tools"):
with gr.Tab("Draw"):
with gr.Row():
with gr.Column(style="width=50%"):
gr.Pil(label="Crop")
with gr.Column(style="width=50%"):
gr.Pil(label="Draw")
with gr.Tab("View"):
with gr.Row():
with gr.Column():
gr.Pil(label="Crop").style(style="height=500")
with gr.Tab("Color Picker"):
with gr.Row():
with gr.Column(scale=50):
gr.ColorPicker(label="Color", interactive=True)
with gr.Column(scale=50):
gr.ImagePaint(label="Draw", interactive=True)
with gr.Tab("Text"):
with gr.Row():
with gr.Column(scale=50):
gr.Textbox(label="", lines=8, interactive=True)
with gr.Column(scale=50):
gr.Textbox(label="", lines=8, interactive=True)
with gr.Box(visible=True) as timo:
with gr.Row():
with gr.Column():
input_text=gr.Textbox(label="你想画的内容(只能是英文单词)")
prompt=gr.Textbox(label="完善后的提示词",visible=True)
with gr.Column():
see_prompts=gr.Button("完善")
with gr.Row():
run=gr.Button("开始")
clear_btn=gr.Button("清除")
with gr.Row():
output1=gr.Image(label=(f"{model_1}"),visible=True)
output2=gr.Image(label=(f"{model_2}"),visible=True)
output3=gr.Image(label=(f"{model_3}"),visible=True)
output4=gr.Image(label=(f"{model_4}"),visible=True)
with gr.Row():
output5=gr.Image(label=(f"{model_5}"),visible=True)
output6=gr.Image(label=(f"{model_6}"),visible=True)
output7=gr.Image(label=(f"{model_7}"),visible=True)
output8=gr.Image(label=(f"{model_8}"),visible=True)
with gr.Row():
output9=gr.Image(label=(f"{model_9}"),visible=True)
output10=gr.Image(label=(f"{model_10}"),visible=True)
output11=gr.Image(label=(f"{model_11}"),visible=True)
output12=gr.Image(label=(f"{model_12}"),visible=True)
with gr.Row():
output13=gr.Image(label=(f"{model_13}"),visible=True)
output14=gr.Image(label=(f"{model_14}"),visible=True)
output15=gr.Image(label=(f"{model_15}"),visible=True)
output16=gr.Image(label=(f"{model_16}"),visible=True)
with gr.Row():
output17=gr.Image(label=(f"{model_17}"),visible=True)
output18=gr.Image(label=(f"{model_18}"),visible=True)
output19=gr.Image(label=(f"{model_19}"),visible=True)
output20=gr.Image(label=(f"{model_20}"),visible=True)
with gr.Row(visible=False):
start_box=gr.Number(interactive=False)
end_box=gr.Number(interactive=False)
tog_box=gr.Textbox(value=0,interactive=False)
def clear_it(val):
if int(val) != 0:
val = 0
else:
val = 0
pass
return val
def sesh_end(cnt,t_stamp):
to = t_stamp + 60
et = time.time()
if et > to and t_stamp != 0:
d=gr.update(value=0)
tog=gr.update(value=1)
#print(f'to: {to} et: {et}')
else:
if cnt != 0:
d=gr.update(value=et)
else:
d=gr.update(value=0)
tog=gr.update(value=0)
#print (f'passing: to: {to} et: {et}')
pass
return d,tog
def sesh_start():
t = time.gmtime()
t_stamp = time.time()
current_time = time.strftime("%H:%M:%S", t)
return gr.update(value=t_stamp),gr.update(value=t_stamp),gr.update(value=0)
def clear_fn():
return None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None
start_box.change(sesh_end,[start_box,end_box],[start_box,tog_box],every=1,show_progress=False)
run.click(sesh_start,None,[start_box,end_box,tog_box])
run1=run.click(send_it1, inputs=[prompt], outputs=[output1])
run2=run.click(send_it2, inputs=[prompt], outputs=[output2])
run3=run.click(send_it3, inputs=[prompt], outputs=[output3])
run4=run.click(send_it4, inputs=[prompt], outputs=[output4])
run5=run.click(send_it5, inputs=[prompt], outputs=[output5])
run6=run.click(send_it6, inputs=[prompt], outputs=[output6])
run7=run.click(send_it7, inputs=[prompt], outputs=[output7])
run8=run.click(send_it8, inputs=[prompt], outputs=[output8])
run9=run.click(send_it9, inputs=[prompt], outputs=[output9])
run10=run.click(send_it10, inputs=[prompt], outputs=[output10])
run11=run.click(send_it11, inputs=[prompt], outputs=[output11])
run12=run.click(send_it12, inputs=[prompt], outputs=[output12])
run13=run.click(send_it13, inputs=[prompt], outputs=[output13])
run14=run.click(send_it14, inputs=[prompt], outputs=[output14])
run15=run.click(send_it15, inputs=[prompt], outputs=[output15])
run16=run.click(send_it16, inputs=[prompt], outputs=[output16])
run17=run.click(send_it17, inputs=[prompt], outputs=[output17])
run18=run.click(send_it18, inputs=[prompt], outputs=[output18])
run19=run.click(send_it19, inputs=[prompt], outputs=[output19])
run20=run.click(send_it20, inputs=[prompt], outputs=[output20])
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])
clear_btn.click(clear_fn, None,
[input_text,prompt,output1,output2,output3,output4,output5,output6,output7,output8,output9,output10,output11,output12,output13,output14,output15,output16,output17,output18,output19,output20],
cancels=[prompt1,run1,run2,run3,run4,run5,run6,run7,run8,run9,run10,run11,run12,run13,run14,run15,run16,run17,run18,run19,run20])
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])
myface.queue(concurrency_count=600,status_update_rate=1)
myface.launch(inline=True,show_api=False) |