allknowingroger commited on
Commit
2f56986
0 Parent(s):

Duplicate from allknowingroger/Image-Models-Test43

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