allknowingroger commited on
Commit
7e3b2e8
0 Parent(s):

Duplicate from allknowingroger/Image-Models-Test55

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