allknowingroger commited on
Commit
6fc695d
0 Parent(s):

Duplicate from allknowingroger/Image-Models-Test46

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