Spaces:
Runtime error
Runtime error
File size: 14,550 Bytes
42a07ba |
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 |
import gradio as gr
import os
import sys
from pathlib import Path
import time
text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion",live=True, preprocess=True)
proc1=gr.Interface.load("models/nitrosocke/Arcane-Diffusion", live=True, preprocess=True, postprocess=False)
proc2=gr.Interface.load("models/naclbit/trinart_stable_diffusion_v2", live=True, preprocess=True, postprocess=False)
proc3=gr.Interface.load("models/nitrosocke/redshift-diffusion", live=True, preprocess=True, postprocess=False)
proc4=gr.Interface.load("models/runwayml/stable-diffusion-v1-5", live=True, preprocess=True, postprocess=False)
proc5=gr.Interface.load("models/claudfuen/photorealistic-fuen-v1", live=True, preprocess=True, postprocess=False)
proc6=gr.Interface.load("models/CompVis/stable-diffusion-v1-4", live=True, preprocess=True, postprocess=False)
proc7=gr.Interface.load("models/Linaqruf/anything-v3.0", live=True, preprocess=True, postprocess=False)
proc8=gr.Interface.load("models/andite/anything-v4.0", live=True, preprocess=True, postprocess=False)
proc9=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-1.0", live=True, preprocess=True, postprocess=False)
proc10=gr.Interface.load("models/prompthero/openjourney", live=True, preprocess=True, postprocess=False)
proc11=gr.Interface.load("models/prompthero/midjourney-v4-diffusion", live=True, preprocess=True, postprocess=False)
proc12=gr.Interface.load("models/wavymulder/Analog-Diffusion", live=True, preprocess=True, postprocess=False)
#proc13=gr.Interface.load("models/dreamlike-art/dreamlike-photoreal-2.0")
#proc14=gr.Interface.load("models/wavymulder/Analog-Diffusion")
#proc15=gr.Interface.load("models/nitrosocke/redshift-diffusion")
#proc16=gr.Interface.load("models/prompthero/midjourney-v4-diffusion")
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 main():
#test = 0
#batch=True, max_batch_size=30
#max_batch_size=20
with gr.Blocks(batch=True,max_batch_size=800) as myface:
with gr.Row():
with gr.Tab("Title"):
gr.HTML(""" <title>Maximum Diffusion</title><div style="text-align: center; max-width: 1500px; margin: 0 auto;">
<div
style="
display: inline-flex;
align-items: center;
gap: 0.8rem;
font-size: 1.75rem;
margin-bottom: 10px;
line-height: 1em;
"
>
<h1 style="font-weight: 1200; margin-top: 9px;">
Maximum Diffusion
</h1>
</div>
<br>
<br>
<p style="margin-bottom: 10px;font-size: 94%;font-weight: 100;line-height: 1.5em;">
Text to Image Model Comparison Space - CPU
</p><br><br>
<p style="margin-bottom: 10px;font-size: 94%;font-weight: 100;line-height: 1.5em;">
Freaky Fast, when it's fresh<br>
Try a Mirror, or DIY for Maximum Diffusion in minimum time.
</p><br>
</div>
""")
with gr.Tab("Description"):
gr.HTML("""<div style="text-align:center;">
<h4>Enter your Prompt into the "Short Prompt" box and click "Magic Prompt" to load a prettified version of your prompt<br>
When you are satisfied with the prompt that is in the "Text to Image" box, click "Launch" to load the Models.<br><br>
Images load faster with a simpler prompt.<br>
Most images should load within 2 minutes.<br>
Some models become stuck on certain prompts, and refreshing the page seems to fix it.<br><br>
Not responsible for content, use at your own risk.
</h4>
</div>""")
with gr.Tab("DIY"):
gr.HTML("""<div style="text-align:Left;">
<h4>Copy/Paste this code in your app.py file<br><br>
import gradio as gr<br>
max_d=gr.Interface.load("spaces/Omnibus/maximum_diffusion")<br>
max_d.launch()<br>
</h4>
</div>""")
with gr.Tab("Mirrors"):
gr.HTML("""<div style="text-align:center;vertical-align:center;">
<h4>Queue loading slow? Try a Mirror:<br><br>
<a href="https://huggingface.co/spaces/Omnibus/maximum-diffusion-light">Maximum Diffusion Light 1</a><br>
<p><a href="https://huggingface.co/spaces/Omnibus/maximum-diffusion-light-1">Maximum Diffusion Light 2</a><br>
<p><a href="https://huggingface.co/spaces/Omnibus/maximum-diffusion-light-2">Maximum Diffusion Light 3</a>
</h4>
</div>""")
with gr.Tab("Credits"):
with gr.Row():
gr.Column()
with gr.Column(style="text-align:left;"):
gr.HTML("""
<div style="vertical-align:center">
<br>
<p>I learned everything I know from:
<p><a href="https://huggingface.co/spaces/anzorq/finetuned_diffusion">Finetuned Diffusion</a></p>
<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>
<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>
</div>
""")
gr.Column()
with gr.Tab("Tools"):
with gr.Tab("View"):
with gr.Column(style="width=50%, height=70%"):
gr.Pil(label="Crop")
with gr.Column(style="width=50%, height=70%"):
gr.Pil(label="Crop")
with gr.Tab("Draw"):
with gr.Column(style="width=50%, height=70%"):
gr.Pil(label="Crop")
with gr.Column(style="width=50%, height=70%"):
gr.Pil(label="Draw")
gr.ImagePaint(label="Draw")
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.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.Row():
input_text=gr.Textbox(label="Short Prompt")
see_prompts=gr.Button("Magic Prompt")
with gr.Row():
prompt=gr.Textbox(label="Text to Image")
run=gr.Button("Launch")
# with gr.Row():
# gr.Column()
# with gr.Column():
# clear_btn=gr.Button("Test")
with gr.Row():
output2=gr.Image(label="naclbit/trinart_stable_diffusion_v2")
output11=gr.Image(label="prompthero/midjourney-v4-diffusion")
output3=gr.Image(label="nitrosocke/redshift-diffusion")
output4=gr.Image(label="runwayml/stable-diffusion-v1-5")
with gr.Row():
output5=gr.Image(label="claudfuen/photorealistic-fuen-v1")
output6=gr.Image(label="CompVis/stable-diffusion-v1-4")
output7=gr.Image(label="Linaqruf/anything-v3.0")
output8=gr.Image(label="andite/anything-v4.0")
with gr.Row():
output9=gr.Image(label="dreamlike-art/dreamlike-photoreal-1.0")
output10=gr.Image(label="prompthero/openjourney")
output1=gr.Image(label="nitrosocke/Arcane-Diffusion")
output12=gr.Image(label="wavymulder/Analog-Diffusion")
#with gr.Row():
# output13=gr.Image(label="dreamlike-photoreal-2.0")
# output14=gr.Image(label="Analog-Diffusion")
#
# output15=gr.Image(label="redshift-diffusion")
# output16=gr.Image(label="midjourney-v4-diffusion")
#def set_models(model_name1, model_name2, model_name3, model_name4):
#return(proc1,proc2,proc3,proc4)
#run.click(set_models, inputs=[model_name1, model_name2, model_name3, model_name4], outputs=[proc1,proc2,proc3,proc4])
#run.click(send_it, inputs=[prompt], outputs=[output1, output2, output3, output4])
def clear_queue():
myface.queue.clear()
#clear_btn.click(clear_queue, inputs=None, outputs=None)
see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt])
#timeout = time.time() + 5 #60*1 #1 minute # 5 minutes from now
run.click(send_it1, inputs=[prompt], outputs=[output1])
run.click(send_it2, inputs=[prompt], outputs=[output2])
run.click(send_it3, inputs=[prompt], outputs=[output3])
run.click(send_it4, inputs=[prompt], outputs=[output4])
run.click(send_it5, inputs=[prompt], outputs=[output5])
run.click(send_it6, inputs=[prompt], outputs=[output6])
run.click(send_it7, inputs=[prompt], outputs=[output7])
run.click(send_it8, inputs=[prompt], outputs=[output8])
run.click(send_it9, inputs=[prompt], outputs=[output9])
run.click(send_it10, inputs=[prompt], outputs=[output10])
run.click(send_it11, inputs=[prompt], outputs=[output11])
run.click(send_it12, inputs=[prompt], outputs=[output12])
#run.click(send_it13, inputs=[prompt], outputs=[output13])
#run.click(send_it14, inputs=[prompt], outputs=[output14])
#run.click(send_it15, inputs=[prompt], outputs=[output15])
#run.click(send_it16, inputs=[prompt], outputs=[output16])
#myface.queue(default_enabled=False)
#myface.queue(concurrency_count=240,status_update_rate=1)
myface.queue(concurrency_count=800,status_update_rate=1)
myface.launch(enable_queue=True,inline=True,max_threads=800)
#myface.launch(enable_queue=True, max_threads=20)
if __name__ == "__main__":
main()
|