allknowingroger
commited on
Commit
•
8c4ce77
0
Parent(s):
Duplicate from allknowingroger/Image-Models-Test66
Browse files- .gitattributes +34 -0
- README.md +13 -0
- app.py +147 -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,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: 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 |
+
pinned: true
|
10 |
+
duplicated_from: allknowingroger/Image-Models-Test66
|
11 |
+
---
|
12 |
+
|
13 |
+
<!--Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference-->
|
app.py
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
# import os
|
3 |
+
# import sys
|
4 |
+
# from pathlib import Path
|
5 |
+
import time
|
6 |
+
|
7 |
+
models =[
|
8 |
+
"stablediffusionapi/calicomix",
|
9 |
+
"Aswitha/pet-dogs-amb",
|
10 |
+
"Yntec/samdoesartsUlt",
|
11 |
+
"stablediffusionapi/beautiful-realistic",
|
12 |
+
"Yntec/photoMovieX",
|
13 |
+
"mfrashad/hassakuv13",
|
14 |
+
"Yntec/samaritan3dCartoon2MVAE",
|
15 |
+
"inu-ai/niji-diffusion-xl-base-1.0",
|
16 |
+
"mfrashad/rev-animatedv122",
|
17 |
+
"FrknAI/dreambooth_inf",
|
18 |
+
"sotiiii/senn-test",
|
19 |
+
"Falah/sdxl2033",
|
20 |
+
]
|
21 |
+
|
22 |
+
|
23 |
+
model_functions = {}
|
24 |
+
model_idx = 1
|
25 |
+
for model_path in models:
|
26 |
+
try:
|
27 |
+
model_functions[model_idx] = gr.Interface.load(f"models/{model_path}", live=False, preprocess=True, postprocess=False)
|
28 |
+
except Exception as error:
|
29 |
+
def the_fn(txt):
|
30 |
+
return None
|
31 |
+
model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image"])
|
32 |
+
model_idx+=1
|
33 |
+
|
34 |
+
|
35 |
+
def send_it_idx(idx):
|
36 |
+
def send_it_fn(prompt):
|
37 |
+
output = (model_functions.get(str(idx)) or model_functions.get(str(1)))(prompt)
|
38 |
+
return output
|
39 |
+
return send_it_fn
|
40 |
+
|
41 |
+
def get_prompts(prompt_text):
|
42 |
+
return prompt_text
|
43 |
+
|
44 |
+
def clear_it(val):
|
45 |
+
if int(val) != 0:
|
46 |
+
val = 0
|
47 |
+
else:
|
48 |
+
val = 0
|
49 |
+
pass
|
50 |
+
return val
|
51 |
+
|
52 |
+
def all_task_end(cnt,t_stamp):
|
53 |
+
to = t_stamp + 60
|
54 |
+
et = time.time()
|
55 |
+
if et > to and t_stamp != 0:
|
56 |
+
d = gr.update(value=0)
|
57 |
+
tog = gr.update(value=1)
|
58 |
+
#print(f'to: {to} et: {et}')
|
59 |
+
else:
|
60 |
+
if cnt != 0:
|
61 |
+
d = gr.update(value=et)
|
62 |
+
else:
|
63 |
+
d = gr.update(value=0)
|
64 |
+
tog = gr.update(value=0)
|
65 |
+
#print (f'passing: to: {to} et: {et}')
|
66 |
+
pass
|
67 |
+
return d, tog
|
68 |
+
|
69 |
+
def all_task_start():
|
70 |
+
print("\n\n\n\n\n\n\n")
|
71 |
+
t = time.gmtime()
|
72 |
+
t_stamp = time.time()
|
73 |
+
current_time = time.strftime("%H:%M:%S", t)
|
74 |
+
return gr.update(value=t_stamp), gr.update(value=t_stamp), gr.update(value=0)
|
75 |
+
|
76 |
+
def clear_fn():
|
77 |
+
nn = len(models)
|
78 |
+
return tuple([None, *[None for _ in range(nn)]])
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
with gr.Blocks(title="SD Models") as my_interface:
|
83 |
+
with gr.Column(scale=12):
|
84 |
+
# with gr.Row():
|
85 |
+
# gr.Markdown("""- Primary prompt: 你想画的内容(英文单词,如 a cat, 加英文逗号效果更好;点 Improve 按钮进行完善)\n- Real prompt: 完善后的提示词,出现后再点右边的 Run 按钮开始运行""")
|
86 |
+
with gr.Row():
|
87 |
+
with gr.Row(scale=6):
|
88 |
+
primary_prompt=gr.Textbox(label="Prompt", value="")
|
89 |
+
# real_prompt=gr.Textbox(label="Real prompt")
|
90 |
+
with gr.Row(scale=6):
|
91 |
+
# improve_prompts_btn=gr.Button("Improve")
|
92 |
+
with gr.Row():
|
93 |
+
run=gr.Button("Run",variant="primary")
|
94 |
+
clear_btn=gr.Button("Clear")
|
95 |
+
with gr.Row():
|
96 |
+
sd_outputs = {}
|
97 |
+
model_idx = 1
|
98 |
+
for model_path in models:
|
99 |
+
with gr.Column(scale=3, min_width=320):
|
100 |
+
with gr.Box():
|
101 |
+
sd_outputs[model_idx] = gr.Image(label=model_path)
|
102 |
+
pass
|
103 |
+
model_idx += 1
|
104 |
+
pass
|
105 |
+
pass
|
106 |
+
|
107 |
+
with gr.Row(visible=False):
|
108 |
+
start_box=gr.Number(interactive=False)
|
109 |
+
end_box=gr.Number(interactive=False)
|
110 |
+
tog_box=gr.Textbox(value=0,interactive=False)
|
111 |
+
|
112 |
+
start_box.change(
|
113 |
+
all_task_end,
|
114 |
+
[start_box, end_box],
|
115 |
+
[start_box, tog_box],
|
116 |
+
every=1,
|
117 |
+
show_progress=False)
|
118 |
+
|
119 |
+
primary_prompt.submit(all_task_start, None, [start_box, end_box, tog_box])
|
120 |
+
run.click(all_task_start, None, [start_box, end_box, tog_box])
|
121 |
+
runs_dict = {}
|
122 |
+
model_idx = 1
|
123 |
+
for model_path in models:
|
124 |
+
runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=[sd_outputs[model_idx]])
|
125 |
+
model_idx += 1
|
126 |
+
pass
|
127 |
+
pass
|
128 |
+
|
129 |
+
# improve_prompts_btn_clicked=improve_prompts_btn.click(
|
130 |
+
# get_prompts,
|
131 |
+
# inputs=[primary_prompt],
|
132 |
+
# outputs=[primary_prompt],
|
133 |
+
# cancels=list(runs_dict.values()))
|
134 |
+
clear_btn.click(
|
135 |
+
clear_fn,
|
136 |
+
None,
|
137 |
+
[primary_prompt, *list(sd_outputs.values())],
|
138 |
+
cancels=[*list(runs_dict.values())])
|
139 |
+
tog_box.change(
|
140 |
+
clear_it,
|
141 |
+
tog_box,
|
142 |
+
tog_box,
|
143 |
+
cancels=[*list(runs_dict.values())])
|
144 |
+
|
145 |
+
my_interface.queue(concurrency_count=600, status_update_rate=1)
|
146 |
+
my_interface.launch(inline=True, show_api=False)
|
147 |
+
|