allknowingroger commited on
Commit
c7ed3d1
0 Parent(s):

Duplicate from allknowingroger/Image-Models-Test50

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