allknowingroger commited on
Commit
8bb314d
0 Parent(s):

Duplicate from allknowingroger/Image-Models-Test60

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