Spaces:
Runtime error
Runtime error
allknowingroger
commited on
Commit
•
d255a20
0
Parent(s):
Duplicate from allknowingroger/Image-Models-Test104
Browse files- .gitattributes +34 -0
- README.md +12 -0
- app.py +144 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: More Image Models
|
3 |
+
emoji: 😻
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: gray
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.23.0
|
8 |
+
app_file: app.py
|
9 |
+
duplicated_from: allknowingroger/Image-Models-Test104
|
10 |
+
---
|
11 |
+
|
12 |
+
<!--Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference-->
|
app.py
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
# import os
|
3 |
+
# import sys
|
4 |
+
# from pathlib import Path
|
5 |
+
import time
|
6 |
+
|
7 |
+
models =[
|
8 |
+
"kingrabbit911/lora-trained-xl",
|
9 |
+
"digiplay/VoidnoiseCore_R0829",
|
10 |
+
"artificialguybr/StorybookRedmondUnbound",
|
11 |
+
"jagonzalr/stable-diffusion-v1-5",
|
12 |
+
"digiplay/NextPhoto_v3",
|
13 |
+
"aigrils2/beautifulv6-32fp-with-ema",
|
14 |
+
"mahendra0203/lora-trained-xl-colab-5k-steps",
|
15 |
+
"plasmo/woolitize",
|
16 |
+
"digiplay/NextGenMix_R2.8VAE",
|
17 |
+
]
|
18 |
+
|
19 |
+
|
20 |
+
model_functions = {}
|
21 |
+
model_idx = 1
|
22 |
+
for model_path in models:
|
23 |
+
try:
|
24 |
+
model_functions[model_idx] = gr.Interface.load(f"models/{model_path}", live=False, preprocess=True, postprocess=False)
|
25 |
+
except Exception as error:
|
26 |
+
def the_fn(txt):
|
27 |
+
return None
|
28 |
+
model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image"])
|
29 |
+
model_idx+=1
|
30 |
+
|
31 |
+
|
32 |
+
def send_it_idx(idx):
|
33 |
+
def send_it_fn(prompt):
|
34 |
+
output = (model_functions.get(str(idx)) or model_functions.get(str(1)))(prompt)
|
35 |
+
return output
|
36 |
+
return send_it_fn
|
37 |
+
|
38 |
+
def get_prompts(prompt_text):
|
39 |
+
return prompt_text
|
40 |
+
|
41 |
+
def clear_it(val):
|
42 |
+
if int(val) != 0:
|
43 |
+
val = 0
|
44 |
+
else:
|
45 |
+
val = 0
|
46 |
+
pass
|
47 |
+
return val
|
48 |
+
|
49 |
+
def all_task_end(cnt,t_stamp):
|
50 |
+
to = t_stamp + 60
|
51 |
+
et = time.time()
|
52 |
+
if et > to and t_stamp != 0:
|
53 |
+
d = gr.update(value=0)
|
54 |
+
tog = gr.update(value=1)
|
55 |
+
#print(f'to: {to} et: {et}')
|
56 |
+
else:
|
57 |
+
if cnt != 0:
|
58 |
+
d = gr.update(value=et)
|
59 |
+
else:
|
60 |
+
d = gr.update(value=0)
|
61 |
+
tog = gr.update(value=0)
|
62 |
+
#print (f'passing: to: {to} et: {et}')
|
63 |
+
pass
|
64 |
+
return d, tog
|
65 |
+
|
66 |
+
def all_task_start():
|
67 |
+
print("\n\n\n\n\n\n\n")
|
68 |
+
t = time.gmtime()
|
69 |
+
t_stamp = time.time()
|
70 |
+
current_time = time.strftime("%H:%M:%S", t)
|
71 |
+
return gr.update(value=t_stamp), gr.update(value=t_stamp), gr.update(value=0)
|
72 |
+
|
73 |
+
def clear_fn():
|
74 |
+
nn = len(models)
|
75 |
+
return tuple([None, *[None for _ in range(nn)]])
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
with gr.Blocks(title="SD Models") as my_interface:
|
80 |
+
with gr.Column(scale=12):
|
81 |
+
# with gr.Row():
|
82 |
+
# gr.Markdown("""- Primary prompt: 你想画的内容(英文单词,如 a cat, 加英文逗号效果更好;点 Improve 按钮进行完善)\n- Real prompt: 完善后的提示词,出现后再点右边的 Run 按钮开始运行""")
|
83 |
+
with gr.Row():
|
84 |
+
with gr.Row(scale=6):
|
85 |
+
primary_prompt=gr.Textbox(label="Prompt", value="")
|
86 |
+
# real_prompt=gr.Textbox(label="Real prompt")
|
87 |
+
with gr.Row(scale=6):
|
88 |
+
# improve_prompts_btn=gr.Button("Improve")
|
89 |
+
with gr.Row():
|
90 |
+
run=gr.Button("Run",variant="primary")
|
91 |
+
clear_btn=gr.Button("Clear")
|
92 |
+
with gr.Row():
|
93 |
+
sd_outputs = {}
|
94 |
+
model_idx = 1
|
95 |
+
for model_path in models:
|
96 |
+
with gr.Column(scale=3, min_width=320):
|
97 |
+
with gr.Box():
|
98 |
+
sd_outputs[model_idx] = gr.Image(label=model_path)
|
99 |
+
pass
|
100 |
+
model_idx += 1
|
101 |
+
pass
|
102 |
+
pass
|
103 |
+
|
104 |
+
with gr.Row(visible=False):
|
105 |
+
start_box=gr.Number(interactive=False)
|
106 |
+
end_box=gr.Number(interactive=False)
|
107 |
+
tog_box=gr.Textbox(value=0,interactive=False)
|
108 |
+
|
109 |
+
start_box.change(
|
110 |
+
all_task_end,
|
111 |
+
[start_box, end_box],
|
112 |
+
[start_box, tog_box],
|
113 |
+
every=1,
|
114 |
+
show_progress=False)
|
115 |
+
|
116 |
+
primary_prompt.submit(all_task_start, None, [start_box, end_box, tog_box])
|
117 |
+
run.click(all_task_start, None, [start_box, end_box, tog_box])
|
118 |
+
runs_dict = {}
|
119 |
+
model_idx = 1
|
120 |
+
for model_path in models:
|
121 |
+
runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=[sd_outputs[model_idx]])
|
122 |
+
model_idx += 1
|
123 |
+
pass
|
124 |
+
pass
|
125 |
+
|
126 |
+
# improve_prompts_btn_clicked=improve_prompts_btn.click(
|
127 |
+
# get_prompts,
|
128 |
+
# inputs=[primary_prompt],
|
129 |
+
# outputs=[primary_prompt],
|
130 |
+
# cancels=list(runs_dict.values()))
|
131 |
+
clear_btn.click(
|
132 |
+
clear_fn,
|
133 |
+
None,
|
134 |
+
[primary_prompt, *list(sd_outputs.values())],
|
135 |
+
cancels=[*list(runs_dict.values())])
|
136 |
+
tog_box.change(
|
137 |
+
clear_it,
|
138 |
+
tog_box,
|
139 |
+
tog_box,
|
140 |
+
cancels=[*list(runs_dict.values())])
|
141 |
+
|
142 |
+
my_interface.queue(concurrency_count=600, status_update_rate=1)
|
143 |
+
my_interface.launch(inline=True, show_api=False)
|
144 |
+
|