allknowingroger commited on
Commit
1685eab
0 Parent(s):

Duplicate from allknowingroger/Image-Models-Test114

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