Spaces:
Runtime error
Runtime error
Create backup.app.py
Browse files- backup.app.py +141 -0
backup.app.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
import sys
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
def load_models_from_file(filename):
|
| 7 |
+
with open(filename, 'r') as f:
|
| 8 |
+
return [line.strip() for line in f]
|
| 9 |
+
|
| 10 |
+
if __name__ == "__main__":
|
| 11 |
+
models = load_models_from_file('models.txt')
|
| 12 |
+
print(models)
|
| 13 |
+
#removed to removed.txt
|
| 14 |
+
|
| 15 |
+
current_model = models[0]
|
| 16 |
+
|
| 17 |
+
text_gen1=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")
|
| 18 |
+
models2 = [gr.Interface.load(f"models/{model}", live=True, preprocess=False) for model in models]
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def text_it1(inputs,text_gen1=text_gen1):
|
| 23 |
+
go_t1=text_gen1(inputs)
|
| 24 |
+
return(go_t1)
|
| 25 |
+
|
| 26 |
+
def set_model(current_model):
|
| 27 |
+
current_model = models[current_model]
|
| 28 |
+
return gr.update(label=(f"{current_model}"))
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def send_it1(inputs, model_choice):
|
| 32 |
+
proc1=models2[model_choice]
|
| 33 |
+
output1=proc1(inputs)
|
| 34 |
+
return(output1)
|
| 35 |
+
css=""""""
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
with gr.Blocks(css=css) as myface:
|
| 39 |
+
gr.HTML("""<!DOCTYPE html>
|
| 40 |
+
<html lang="en">
|
| 41 |
+
<head>
|
| 42 |
+
<meta charset="utf-8" />
|
| 43 |
+
<meta name="twitter:card" content="player"/>
|
| 44 |
+
<meta name="twitter:site" content=""/>
|
| 45 |
+
<meta name="twitter:player" content="https://omnibus-maximum-multiplier-places.hf.space"/>
|
| 46 |
+
<meta name="twitter:player:stream" content="https://omnibus-maximum-multiplier-places.hf.space"/>
|
| 47 |
+
<meta name="twitter:player:width" content="100%"/>
|
| 48 |
+
<meta name="twitter:player:height" content="600"/>
|
| 49 |
+
<meta property="og:title" content="Embedded Live Viewer"/>
|
| 50 |
+
<meta property="og:description" content="Tweet Genie - A Huggingface Space"/>
|
| 51 |
+
<meta property="og:image" content="https://cdn.glitch.global/80dbe92e-ce75-44af-84d5-74a2e21e9e55/omnicard.png?v=1676772531627"/>
|
| 52 |
+
<!--<meta http-equiv="refresh" content="0; url=https://huggingface.co/spaces/corbt/tweet-genie">-->
|
| 53 |
+
</head>
|
| 54 |
+
</html>
|
| 55 |
+
""")
|
| 56 |
+
with gr.Row():
|
| 57 |
+
with gr.Tab("Title"):
|
| 58 |
+
gr.HTML(""" <title>Minimum Multiplier</title><div style="text-align: center; max-width: 1500px; margin: 0 auto;">
|
| 59 |
+
<h1>Fill the Textbox at the top and click Generate Image</h1>
|
| 60 |
+
<br><h4>The first time you load a model it takes 200 seconds</h4>
|
| 61 |
+
<br><h4>But after it loads each image takes 20 seconds to generate!</h4>
|
| 62 |
+
|
| 63 |
+
""")
|
| 64 |
+
|
| 65 |
+
with gr.Tab("Description"):
|
| 66 |
+
gr.HTML("""<div style="text-align:center;">
|
| 67 |
+
<h4>As many Text-to-Image Models as I can fit here</h4><br>
|
| 68 |
+
<h4>Suggest more up in the "Community" button</h4>
|
| 69 |
+
|
| 70 |
+
</div>""")
|
| 71 |
+
|
| 72 |
+
with gr.Tab("Tools"):
|
| 73 |
+
with gr.Tab("View"):
|
| 74 |
+
with gr.Row():
|
| 75 |
+
with gr.Column(style="width=50%, height=70%"):
|
| 76 |
+
gr.Pil(label="Crop")
|
| 77 |
+
with gr.Column(style="width=50%, height=70%"):
|
| 78 |
+
gr.Pil(label="Crop")
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
with gr.Tab("Draw"):
|
| 82 |
+
with gr.Column(style="width=50%, height=70%"):
|
| 83 |
+
gr.Pil(label="Crop")
|
| 84 |
+
with gr.Column(style="width=50%, height=70%"):
|
| 85 |
+
gr.Pil(label="Draw")
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
gr.ImagePaint(label="Draw")
|
| 89 |
+
|
| 90 |
+
with gr.Tab("Text"):
|
| 91 |
+
with gr.Row():
|
| 92 |
+
|
| 93 |
+
with gr.Column(scale=50):
|
| 94 |
+
gr.Textbox(label="", lines=8, interactive=True)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
with gr.Column(scale=50):
|
| 98 |
+
gr.Textbox(label="", lines=8, interactive=True)
|
| 99 |
+
|
| 100 |
+
with gr.Tab("Color Picker"):
|
| 101 |
+
with gr.Row():
|
| 102 |
+
|
| 103 |
+
with gr.Column(scale=50):
|
| 104 |
+
gr.ColorPicker(label="Color", interactive=True)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
with gr.Column(scale=50):
|
| 108 |
+
gr.ImagePaint(label="Draw", interactive=True)
|
| 109 |
+
with gr.Row():
|
| 110 |
+
with gr.Column(scale=100):
|
| 111 |
+
magic1=gr.Textbox(lines=4)
|
| 112 |
+
run=gr.Button("Generate Image")
|
| 113 |
+
with gr.Row():
|
| 114 |
+
with gr.Column(scale=100):
|
| 115 |
+
#Model selection dropdown
|
| 116 |
+
model_name1 = gr.Dropdown(label="Select Model", choices=[m for m in models], type="index", value=current_model, interactive=True)
|
| 117 |
+
with gr.Row():
|
| 118 |
+
with gr.Column(style="width=800px"):
|
| 119 |
+
output1=gr.Image(label=(f"{current_model}"))
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
with gr.Row():
|
| 123 |
+
with gr.Column(scale=50):
|
| 124 |
+
input_text=gr.Textbox(label="Prompt Idea",lines=2)
|
| 125 |
+
use_short=gr.Button("Use Short Prompt")
|
| 126 |
+
see_prompts=gr.Button("Extend Idea")
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def short_prompt(inputs):
|
| 130 |
+
return(inputs)
|
| 131 |
+
|
| 132 |
+
model_name1.change(set_model,inputs=model_name1,outputs=[output1])
|
| 133 |
+
|
| 134 |
+
run.click(send_it1, inputs=[magic1, model_name1], outputs=[output1])
|
| 135 |
+
|
| 136 |
+
use_short.click(short_prompt,inputs=[input_text],outputs=magic1)
|
| 137 |
+
|
| 138 |
+
see_prompts.click(text_it1,inputs=[input_text],outputs=magic1)
|
| 139 |
+
|
| 140 |
+
myface.queue(concurrency_count=200)
|
| 141 |
+
myface.launch(inline=True, show_api=False, max_threads=400)
|