Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from pathlib import Path
|
3 |
|
4 |
def load_models_from_file(filename):
|
@@ -8,60 +10,106 @@ def load_models_from_file(filename):
|
|
8 |
if __name__ == "__main__":
|
9 |
models = load_models_from_file('models.txt')
|
10 |
print(models)
|
11 |
-
|
|
|
12 |
current_model = models[0]
|
13 |
-
|
|
|
14 |
models2 = [gr.Interface.load(f"models/{model}", live=True, preprocess=False) for model in models]
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
|
20 |
def set_model(current_model):
|
21 |
current_model = models[current_model]
|
22 |
return gr.update(label=(f"{current_model}"))
|
23 |
|
|
|
24 |
def send_it1(inputs, model_choice):
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
|
29 |
-
css = ""
|
30 |
|
31 |
with gr.Blocks(css=css) as myface:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
with gr.Row():
|
33 |
-
with gr.Tab("
|
34 |
-
|
35 |
-
|
36 |
-
gr.Pil(label="Crop")
|
37 |
-
gr.Pil(label="Crop")
|
38 |
-
|
39 |
-
with gr.Tab("Draw"):
|
40 |
-
with gr.Row():
|
41 |
-
gr.Pil(label="Crop")
|
42 |
-
gr.ImagePaint(label="Draw")
|
43 |
-
gr.Textbox(label="", lines=8)
|
44 |
-
gr.Textbox(label="", lines=8)
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
with gr.Row():
|
52 |
-
gr.
|
53 |
-
|
54 |
-
|
55 |
with gr.Row():
|
56 |
-
gr.
|
57 |
-
|
58 |
with gr.Row():
|
59 |
-
gr.
|
60 |
-
|
|
|
61 |
with gr.Row():
|
62 |
-
gr.
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
+
import sys
|
4 |
from pathlib import Path
|
5 |
|
6 |
def load_models_from_file(filename):
|
|
|
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>Prompt to Generate Image</title><div style="text-align: center; max-width: 1500px; margin: 0 auto;">
|
59 |
+
<h1>Enter a Prompt in Textbox then click Generate Image</h1>""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
+
with gr.Tab("Tools"):
|
62 |
+
with gr.Tab("View"):
|
63 |
+
with gr.Row():
|
64 |
+
with gr.Column(style="width=50%, height=70%"):
|
65 |
+
gr.Pil(label="Crop")
|
66 |
+
with gr.Column(style="width=50%, height=70%"):
|
67 |
+
gr.Pil(label="Crop")
|
68 |
+
|
69 |
+
with gr.Tab("Draw"):
|
70 |
+
with gr.Column(style="width=50%, height=70%"):
|
71 |
+
gr.Pil(label="Crop")
|
72 |
+
with gr.Column(style="width=50%, height=70%"):
|
73 |
+
gr.Pil(label="Draw")
|
74 |
+
gr.ImagePaint(label="Draw")
|
75 |
+
|
76 |
+
with gr.Tab("Text"):
|
77 |
+
with gr.Row():
|
78 |
+
with gr.Column(scale=50):
|
79 |
+
gr.Textbox(label="", lines=8, interactive=True)
|
80 |
+
with gr.Column(scale=50):
|
81 |
+
gr.Textbox(label="", lines=8, interactive=True)
|
82 |
|
83 |
+
with gr.Tab("Color Picker"):
|
84 |
+
with gr.Row():
|
85 |
+
with gr.Column(scale=50):
|
86 |
+
gr.ColorPicker(label="Color", interactive=True)
|
87 |
+
with gr.Column(scale=50):
|
88 |
+
gr.ImagePaint(label="Draw", interactive=True)
|
89 |
with gr.Row():
|
90 |
+
with gr.Column(scale=100):
|
91 |
+
magic1=gr.Textbox(lines=4)
|
92 |
+
run=gr.Button("Generate Image")
|
93 |
with gr.Row():
|
94 |
+
with gr.Column(scale=100):
|
95 |
+
model_name1 = gr.Dropdown(label="Select Model", choices=[m for m in models], type="index", value=current_model, interactive=True)
|
96 |
with gr.Row():
|
97 |
+
with gr.Column(style="width=800px"):
|
98 |
+
output1=gr.Image(label=(f"{current_model}"))
|
99 |
+
|
100 |
with gr.Row():
|
101 |
+
with gr.Column(scale=50):
|
102 |
+
input_text=gr.Textbox(label="Prompt Idea",lines=2)
|
103 |
+
use_short=gr.Button("Use Short Prompt")
|
104 |
+
see_prompts=gr.Button("Extend Idea")
|
105 |
+
|
106 |
+
def short_prompt(inputs):
|
107 |
+
return(inputs)
|
108 |
+
|
109 |
+
model_name1.change(set_model,inputs=model_name1,outputs=[output1])
|
110 |
+
run.click(send_it1, inputs=[magic1, model_name1], outputs=[output1])
|
111 |
+
use_short.click(short_prompt,inputs=[input_text],outputs=magic1)
|
112 |
+
see_prompts.click(text_it1,inputs=[input_text],outputs=magic1)
|
113 |
+
|
114 |
+
myface.queue(concurrency_count=200)
|
115 |
+
myface.launch(inline=True, show_api=False, max_threads=400)
|