Spaces:
Runtime error
Runtime error
| 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() | |