Spaces:
Runtime error
Runtime error
| 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", | |
| "SG161222/Realistic_Vision_V1.4", | |
| "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", | |
| ] | |
| current_model = models[5] | |
| models2=[ | |
| gr.Interface.load(f"models/{models[1]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[2]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[3]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[4]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[5]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[6]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[7]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[8]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[9]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[10]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[11]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[12]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[13]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[14]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[15]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[16]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[17]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[18]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[19]}",live=True,preprocess=True), | |
| gr.Interface.load(f"models/{models[20]}",live=True,preprocess=True), | |
| ] | |
| text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link",live=True, preprocess=True) | |
| def send_it1(inputs,model_choice=5, count = 1): | |
| if model_choice==None: | |
| model_choice=5 | |
| t=0 | |
| output_list=[] | |
| while t<int(count): | |
| proc1=models2[int(model_choice)] | |
| output1=proc1(inputs) | |
| output_list.append(output1) | |
| inputs=f"{inputs} " | |
| t+=1 | |
| return(output_list) | |
| with gr.Blocks(css="cake.css") as myface: | |
| gr.HTML("""<head><meta http-equiv="refresh" content="180"></head>""") | |
| gr.HTML("""<title>Top 20 Diffuion</title>""") | |
| with gr.Column(): | |
| gr.Markdown("""<center><h1>Top 20 Diffusion</h1><center>""") | |
| with gr.Accordion("Details",open=False): | |
| with gr.Tab("Description"): | |
| gr.Markdown("""<center> | |
| <h6>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> | |
| <br> | |
| Images will cancel loading after 1 minute to preserve the quality of the queue.<br> | |
| Simply Click "Launch" again to try loading the incomplete images.<br> | |
| Page refreshes every 3 minutes for this Demo. | |
| <br> | |
| <br> | |
| Not responsible for content, use at your own risk. | |
| </h6></center>""") | |
| with gr.Tab("DIY"): | |
| gr.HTML("""<div style="text-align:Left;"> | |
| <h6>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/Omnibus/Top-20-Diffusion")<br> | |
| max_d.launch()<br> | |
| </h6></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.Row(): | |
| with gr.Column(): | |
| input_text=gr.Textbox(label="Short Prompt") | |
| prompt=gr.Textbox(label="Text to Image Prompt",visible=True) | |
| model_name1 = gr.Dropdown(show_label=False, choices=[m for m in models], type="index", value=current_model, interactive=True) | |
| count = gr.Number(value=1) | |
| with gr.Column(): | |
| see_prompts=gr.Button("Magic Prompt") | |
| with gr.Row(): | |
| run=gr.Button("Launch") | |
| clear_btn=gr.Button("Clear") | |
| with gr.Column(visible=True) as timo: | |
| with gr.Row(): | |
| output1=gr.Gallery(columns=2) | |
| def get_prompts(prompt_text): | |
| gen=text_gen(prompt_text) | |
| return gen | |
| run1=run.click(send_it1, inputs=[prompt, model_name1,count], outputs=[output1]) | |
| myface.queue(concurrency_count=400,status_update_rate=1) | |
| myface.launch(inline=True,show_api=True) | |