Upload 14 files
Browse files- .gitattributes +1 -0
- Controlnet.py +24 -0
- ImgManage.py +238 -0
- MergeTools.ipynb +259 -0
- MergeTools.py +193 -0
- PreHandel.py +68 -0
- description.txt +14 -0
- frpc_linux_amd64_v0.2 +3 -0
- hf_mirror.ipynb +54 -0
- modelscope.ipynb +48 -0
- search_files.ipynb +82 -0
- speedtest.ipynb +53 -0
- start.py +11 -0
- su._prompt.txt +10 -0
- zipTool.ipynb +49 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
frpc_linux_amd64_v0.2 filter=lfs diff=lfs merge=lfs -text
|
Controlnet.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
def ControlnetDownloads():
|
4 |
+
def aria2(url, filename, directory):
|
5 |
+
os.system(f'aria2c --console-log-level=error -c -x 16 -s 16 {url} -o {filename} -d {directory}')
|
6 |
+
|
7 |
+
print("\n\n\n\033[35m正在下载controlnet模型\033[0m")
|
8 |
+
url = '"https://hf-mirror.com/dong625/ControlNet/resolve/main/ControlNet.zip"'
|
9 |
+
aria2(url, "ControlNet.zip", "/mnt/workspace/stable-diffusion-webui/models")
|
10 |
+
os.system('7z x -pQQ917724495 /mnt/workspace/stable-diffusion-webui/models/ControlNet.zip -o/mnt/workspace/stable-diffusion-webui/models -y')
|
11 |
+
os.system('rm -rf /mnt/workspace/stable-diffusion-webui/models/ControlNet.zip')
|
12 |
+
|
13 |
+
print("\n\n\n\033[35m正在下载controlnet预处理器\033[0m")
|
14 |
+
url = '"https://hf-mirror.com/dong625/downloads/resolve/main/downloads.zip"'
|
15 |
+
aria2(url, "downloads.zip", "/mnt/workspace/stable-diffusion-webui/extensions")
|
16 |
+
os.system('7z x -pQQ917724495 /mnt/workspace/stable-diffusion-webui/extensions/downloads.zip -o/mnt/workspace/stable-diffusion-webui/extensions/sd-webui-controlnet/annotator -y')
|
17 |
+
os.system('rm -rf /mnt/workspace/stable-diffusion-webui/extensions/downloads.zip')
|
18 |
+
|
19 |
+
def main():
|
20 |
+
ControlnetDownloads()
|
21 |
+
print("success")
|
22 |
+
|
23 |
+
if __name__ == "__main__":
|
24 |
+
main()
|
ImgManage.py
ADDED
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import shutil
|
3 |
+
import time
|
4 |
+
import argparse
|
5 |
+
import requests
|
6 |
+
|
7 |
+
def get_daily_sentence(types=['a']):
|
8 |
+
params = {
|
9 |
+
'c': types
|
10 |
+
}
|
11 |
+
response = requests.get("https://v1.hitokoto.cn/", params=params)
|
12 |
+
if response.status_code == 200:
|
13 |
+
data = response.json()
|
14 |
+
return "\033[36m\033[4m" + data["hitokoto"] + "\033[0m"
|
15 |
+
else:
|
16 |
+
return " \033[36m\033[4m静待花开会有时,守得云开见月明\033[0m"
|
17 |
+
|
18 |
+
def ClearLike():
|
19 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
20 |
+
print(daily_sentence)
|
21 |
+
path = "/mnt/workspace/Photo/Like"
|
22 |
+
if os.path.exists(path):
|
23 |
+
shutil.rmtree(path)
|
24 |
+
print(f"{path} 已删除")
|
25 |
+
else:
|
26 |
+
print(f"{path} 不存在")
|
27 |
+
|
28 |
+
def PackLike():
|
29 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
30 |
+
print(daily_sentence)
|
31 |
+
path = "/mnt/workspace/Photo/Like"
|
32 |
+
zip_path = "/mnt/workspace/Like.zip"
|
33 |
+
if os.path.exists(path):
|
34 |
+
if os.path.exists(zip_path):
|
35 |
+
os.system(f"7z a {zip_path} {path} -y")
|
36 |
+
print("检测到旧的Like包存在,已经覆盖,已保存在根目录")
|
37 |
+
else:
|
38 |
+
os.system(f"7z a {zip_path} {path}")
|
39 |
+
print("打包完成,已保存在根目录,文件名为Like.zip")
|
40 |
+
else:
|
41 |
+
print(f"{path} 文件夹不存在")
|
42 |
+
|
43 |
+
def ClearUpscale():
|
44 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
45 |
+
print(daily_sentence)
|
46 |
+
path = "/mnt/workspace/Photo/Upscale"
|
47 |
+
if os.path.exists(path):
|
48 |
+
shutil.rmtree(path)
|
49 |
+
print(f"{path} 已删除")
|
50 |
+
else:
|
51 |
+
print(f"{path} 不存在")
|
52 |
+
|
53 |
+
def PackUpscale():
|
54 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
55 |
+
print(daily_sentence)
|
56 |
+
path = "/mnt/workspace/Photo/Upscale"
|
57 |
+
zip_path = "/mnt/workspace/Upscale.zip"
|
58 |
+
if os.path.exists(path):
|
59 |
+
if os.path.exists(zip_path):
|
60 |
+
os.system(f"7z a {zip_path} {path} -y")
|
61 |
+
print("检测到旧的Upscale包存在,已经覆盖,已保存在根目录")
|
62 |
+
else:
|
63 |
+
os.system(f"7z a {zip_path} {path}")
|
64 |
+
print("打包完成,已保存在根目录,文件名为Upscale.zip")
|
65 |
+
else:
|
66 |
+
print(f"{path} 文件夹不存在")
|
67 |
+
|
68 |
+
def ClearAll():
|
69 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l'])
|
70 |
+
print(daily_sentence)
|
71 |
+
path = "/mnt/workspace/Photo/"
|
72 |
+
if os.path.exists(path):
|
73 |
+
for item in os.listdir(path):
|
74 |
+
item_path = os.path.join(path, item)
|
75 |
+
if os.path.isdir(item_path):
|
76 |
+
shutil.rmtree(item_path)
|
77 |
+
print(f"{path} 已清空")
|
78 |
+
else:
|
79 |
+
print(f"{path} 文件夹不存在")
|
80 |
+
|
81 |
+
|
82 |
+
def PackAll():
|
83 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
84 |
+
print(daily_sentence)
|
85 |
+
path = "/mnt/workspace/Photo"
|
86 |
+
zip_path = "/mnt/workspace/Photo.zip"
|
87 |
+
if os.path.exists(path):
|
88 |
+
if os.path.exists(zip_path):
|
89 |
+
os.system(f"7z a {zip_path} {path} -y")
|
90 |
+
print("检测到旧的Photo包存在,已经覆盖,已保存在根目录")
|
91 |
+
else:
|
92 |
+
os.system(f"7z a {zip_path} {path}")
|
93 |
+
print("打包完成,已保存在根目录,文件名为Photo.zip")
|
94 |
+
else:
|
95 |
+
print(f"{path} 文件夹不存在")
|
96 |
+
|
97 |
+
def ClearLikeUpscale():
|
98 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
99 |
+
print(daily_sentence)
|
100 |
+
path = "/mnt/workspace/Photo/Like_Upscale"
|
101 |
+
if os.path.exists(path):
|
102 |
+
shutil.rmtree(path)
|
103 |
+
print(f"{path} 已删除")
|
104 |
+
else:
|
105 |
+
print(f"{path} 不存在")
|
106 |
+
|
107 |
+
def PackLikeUpscale():
|
108 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
109 |
+
print(daily_sentence)
|
110 |
+
path = "/mnt/workspace/Photo/Like_Upscale"
|
111 |
+
zip_path = "/mnt/workspace/Like_Upscale.zip"
|
112 |
+
if os.path.exists(path):
|
113 |
+
if os.path.exists(zip_path):
|
114 |
+
os.system(f"7z a {zip_path} {path} -y")
|
115 |
+
print("检测到旧的Like_Upscale包存在,已经覆盖,已保存在根目录")
|
116 |
+
else:
|
117 |
+
os.system(f"7z a {zip_path} {path}")
|
118 |
+
print("打包完成,已保存在根目录,文件名为Like_Upscale.zip")
|
119 |
+
else:
|
120 |
+
print(f"{path} 文件夹不存在\n")
|
121 |
+
print("请在SD界面-后期处理-批量处理文件夹中设置\n")
|
122 |
+
print("输入目录")
|
123 |
+
print("/mnt/workspace/Photo/Like\n")
|
124 |
+
print("输出目录")
|
125 |
+
print("/mnt/workspace/Photo/Like_Upscale\n")
|
126 |
+
|
127 |
+
def Cleartodaytxt2img():
|
128 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
129 |
+
print(daily_sentence)
|
130 |
+
current_time = time.localtime()
|
131 |
+
formatted_time = time.strftime("%Y-%m-%d", current_time)
|
132 |
+
todaypath = f"/mnt/workspace/Photo/txt2img/{formatted_time}"
|
133 |
+
if os.path.exists(todaypath):
|
134 |
+
shutil.rmtree(todaypath)
|
135 |
+
print(f"{todaypath} 已删除")
|
136 |
+
else:
|
137 |
+
print(f"{todaypath} 不存在")
|
138 |
+
|
139 |
+
def Packtodaytxt2img():
|
140 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
141 |
+
print(daily_sentence)
|
142 |
+
current_time = time.localtime()
|
143 |
+
formatted_time = time.strftime("%Y-%m-%d", current_time)
|
144 |
+
todaypath = f"/mnt/workspace/Photo/txt2img/{formatted_time}"
|
145 |
+
zip_path = f"/mnt/workspace/【文生图】{formatted_time}.zip"
|
146 |
+
if os.path.exists(todaypath):
|
147 |
+
if os.path.exists(zip_path):
|
148 |
+
os.system(f"7z a {zip_path} {todaypath} -y")
|
149 |
+
print(f"检测到旧的【文生图】{formatted_time}包存在,已经覆盖,已保存在根目录")
|
150 |
+
else:
|
151 |
+
os.system(f"7z a {zip_path} {todaypath}")
|
152 |
+
print(f"打包完成,已保存在根目录,文件名为【文生图】{formatted_time}.zip")
|
153 |
+
else:
|
154 |
+
print(f"{todaypath} 文件夹不存在")
|
155 |
+
|
156 |
+
def cleartodayimg2img():
|
157 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
158 |
+
print(daily_sentence)
|
159 |
+
current_time = time.localtime()
|
160 |
+
formatted_time = time.strftime("%Y-%m-%d", current_time)
|
161 |
+
todaypath = f"/mnt/workspace/Photo/txt2img/{formatted_time}"
|
162 |
+
if os.path.exists(todaypath):
|
163 |
+
shutil.rmtree(todaypath)
|
164 |
+
print(f"{todaypath} 已删除")
|
165 |
+
else:
|
166 |
+
print(f"{todaypath} 不存在")
|
167 |
+
|
168 |
+
def Packtodayimg2img():
|
169 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
170 |
+
print(daily_sentence)
|
171 |
+
current_time = time.localtime()
|
172 |
+
formatted_time = time.strftime("%Y-%m-%d", current_time)
|
173 |
+
todaypath = f"/mnt/workspace/Photo/img2img/{formatted_time}"
|
174 |
+
zip_path = f"/mnt/workspace/【图生图】{formatted_time}.zip"
|
175 |
+
if os.path.exists(todaypath):
|
176 |
+
if os.path.exists(zip_path):
|
177 |
+
os.system(f"7z a {zip_path} {todaypath} -y")
|
178 |
+
print(f"检测到旧的【图生图】{formatted_time}包存在,已经覆盖,已保存在根目录")
|
179 |
+
else:
|
180 |
+
os.system(f"7z a {zip_path} {todaypath}")
|
181 |
+
print(f"打包完成,已保存在根目录,文件名为【图生图】{formatted_time}.zip")
|
182 |
+
else:
|
183 |
+
print(f"{todaypath} 文件夹不存在")
|
184 |
+
|
185 |
+
def Clearoriginalimg2img():
|
186 |
+
daily_sentence = get_daily_sentence(['a','b','c','d','e','f','g','h','j','k','l',])
|
187 |
+
print(daily_sentence)
|
188 |
+
path = f"/mnt/workspace/Photo/img2img/original"
|
189 |
+
if os.path.exists(path):
|
190 |
+
shutil.rmtree(path)
|
191 |
+
print(f"{path} 已删除")
|
192 |
+
else:
|
193 |
+
print(f"{path} 不存在")
|
194 |
+
|
195 |
+
if __name__ == "__main__":
|
196 |
+
parser = argparse.ArgumentParser(description="Process some integers.")
|
197 |
+
parser.add_argument("-ClearLike", action="store_true", help="Clear Like folder")
|
198 |
+
parser.add_argument("-PackLike", action="store_true", help="Pack Like folder")
|
199 |
+
parser.add_argument("-ClearUpscale", action="store_true", help="Clear Upscale folder")
|
200 |
+
parser.add_argument("-PackUpscale", action="store_true", help="Pack Upscale folder")
|
201 |
+
parser.add_argument("-ClearAll", action="store_true", help="Clear All folder")
|
202 |
+
parser.add_argument("-PackAll", action="store_true", help="Pack All folder")
|
203 |
+
parser.add_argument("-ClearLikeUpscale", action="store_true", help="Clear Like_Upscale folder")
|
204 |
+
parser.add_argument("-PackLikeUpscale", action="store_true", help="Pack Like_Upscale folder")
|
205 |
+
parser.add_argument("-Cleartodaytxt2img", action="store_true", help="Clear todaytxt2img folder")
|
206 |
+
parser.add_argument("-Packtodaytxt2img", action="store_true", help="Pack todaytxt2img folder")
|
207 |
+
parser.add_argument("-Packtodayimg2img", action="store_true", help="Pack todayimg2img folder")
|
208 |
+
parser.add_argument("-Cleartodayimg2img", action="store_true", help="Clear todayimg2img folder")
|
209 |
+
parser.add_argument("-Clearoriginalimg2img", action="store_true", help="Pack Clearoriginalimg2img folder")
|
210 |
+
|
211 |
+
args = parser.parse_args()
|
212 |
+
|
213 |
+
if args.ClearLike:
|
214 |
+
ClearLike()
|
215 |
+
elif args.PackLike:
|
216 |
+
PackLike()
|
217 |
+
elif args.ClearUpscale:
|
218 |
+
ClearUpscale()
|
219 |
+
elif args.PackUpscale:
|
220 |
+
PackUpscale()
|
221 |
+
elif args.ClearAll:
|
222 |
+
ClearAll()
|
223 |
+
elif args.PackAll:
|
224 |
+
PackAll()
|
225 |
+
elif args.ClearLikeUpscale:
|
226 |
+
ClearLikeUpscale()
|
227 |
+
elif args.PackLikeUpscale:
|
228 |
+
PackLikeUpscale()
|
229 |
+
elif args.Cleartodaytxt2img:
|
230 |
+
Cleartodaytxt2img()
|
231 |
+
elif args.Packtodaytxt2img:
|
232 |
+
Packtodaytxt2img()
|
233 |
+
elif args.Packtodayimg2img:
|
234 |
+
Packtodayimg2img()
|
235 |
+
elif args.Cleartodayimg2img:
|
236 |
+
Cleartodayimg2img()
|
237 |
+
elif args.Clearoriginalimg2img:
|
238 |
+
Clearoriginalimg2img()
|
MergeTools.ipynb
ADDED
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"id": "c52c6845-9709-40da-af44-204b5e6028ff",
|
6 |
+
"metadata": {
|
7 |
+
"tags": []
|
8 |
+
},
|
9 |
+
"source": [
|
10 |
+
"# LoraMerge主服务"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "markdown",
|
15 |
+
"id": "183b9ffc-a9a4-4e10-9db7-71c6043e5726",
|
16 |
+
"metadata": {},
|
17 |
+
"source": [
|
18 |
+
"/mnt/workspace/Photo/Like "
|
19 |
+
]
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"cell_type": "markdown",
|
23 |
+
"id": "f479dfa4-a83d-482a-a997-33d0d9e60e8d",
|
24 |
+
"metadata": {},
|
25 |
+
"source": [
|
26 |
+
"/mnt/workspace/Photo/Like_Upscale"
|
27 |
+
]
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"cell_type": "markdown",
|
31 |
+
"id": "43484b49-ea69-4b53-a427-1e3b8d161924",
|
32 |
+
"metadata": {
|
33 |
+
"tags": []
|
34 |
+
},
|
35 |
+
"source": [
|
36 |
+
"## 移动放大的图片"
|
37 |
+
]
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"cell_type": "code",
|
41 |
+
"execution_count": null,
|
42 |
+
"id": "5dabdee9-80f9-486e-bfa2-4fbb98720e77",
|
43 |
+
"metadata": {
|
44 |
+
"tags": []
|
45 |
+
},
|
46 |
+
"outputs": [],
|
47 |
+
"source": [
|
48 |
+
"!python /mnt/workspace/MergeTools.py --ClearLike --move_upscale"
|
49 |
+
]
|
50 |
+
},
|
51 |
+
{
|
52 |
+
"cell_type": "markdown",
|
53 |
+
"id": "dd5b1b73-5af4-4de9-a1cd-304ee544d29a",
|
54 |
+
"metadata": {
|
55 |
+
"tags": []
|
56 |
+
},
|
57 |
+
"source": [
|
58 |
+
"## 移动模型+打包模型+上传模型"
|
59 |
+
]
|
60 |
+
},
|
61 |
+
{
|
62 |
+
"cell_type": "code",
|
63 |
+
"execution_count": null,
|
64 |
+
"id": "0f65a107-16f1-4a1b-b4f4-4724d63d799e",
|
65 |
+
"metadata": {
|
66 |
+
"ExecutionIndicator": {
|
67 |
+
"show": true
|
68 |
+
},
|
69 |
+
"tags": []
|
70 |
+
},
|
71 |
+
"outputs": [],
|
72 |
+
"source": [
|
73 |
+
"!python /mnt/workspace/MergeTools.py --move_and_delete_like_upscale --move_files_by_date --packup\n",
|
74 |
+
"#--upload_to_modelscope \n",
|
75 |
+
"#--clear_LoraUpload_model "
|
76 |
+
]
|
77 |
+
},
|
78 |
+
{
|
79 |
+
"cell_type": "markdown",
|
80 |
+
"id": "18183c3d-ba6c-4bcd-ba32-256b1ac3c247",
|
81 |
+
"metadata": {
|
82 |
+
"jp-MarkdownHeadingCollapsed": true,
|
83 |
+
"tags": []
|
84 |
+
},
|
85 |
+
"source": [
|
86 |
+
"# LoraMerge子服务"
|
87 |
+
]
|
88 |
+
},
|
89 |
+
{
|
90 |
+
"cell_type": "markdown",
|
91 |
+
"id": "4217efe3-35c3-4daf-a1d6-eb84534074c3",
|
92 |
+
"metadata": {},
|
93 |
+
"source": [
|
94 |
+
"## 按日期创建文件夹"
|
95 |
+
]
|
96 |
+
},
|
97 |
+
{
|
98 |
+
"cell_type": "code",
|
99 |
+
"execution_count": null,
|
100 |
+
"id": "b92d72eb-42ce-403f-96e1-0eac43fa08d6",
|
101 |
+
"metadata": {},
|
102 |
+
"outputs": [],
|
103 |
+
"source": [
|
104 |
+
"!python /mnt/workspace/stable-diffusion-webui/MergeTools.py --create_directories"
|
105 |
+
]
|
106 |
+
},
|
107 |
+
{
|
108 |
+
"cell_type": "markdown",
|
109 |
+
"id": "7c27ec5f-0209-4d1a-a3b7-05ae1a7dd063",
|
110 |
+
"metadata": {},
|
111 |
+
"source": [
|
112 |
+
"## 删除喜欢的图"
|
113 |
+
]
|
114 |
+
},
|
115 |
+
{
|
116 |
+
"cell_type": "code",
|
117 |
+
"execution_count": null,
|
118 |
+
"id": "c7b1231e-f0c2-466e-b109-9ba5db58bb73",
|
119 |
+
"metadata": {
|
120 |
+
"tags": []
|
121 |
+
},
|
122 |
+
"outputs": [],
|
123 |
+
"source": [
|
124 |
+
"!python /mnt/workspace/stable-diffusion-webui/MergeTools.py --ClearLike"
|
125 |
+
]
|
126 |
+
},
|
127 |
+
{
|
128 |
+
"cell_type": "markdown",
|
129 |
+
"id": "c9776f88-118f-4c35-a054-d63081ce4d19",
|
130 |
+
"metadata": {},
|
131 |
+
"source": [
|
132 |
+
"## 移动放大的图"
|
133 |
+
]
|
134 |
+
},
|
135 |
+
{
|
136 |
+
"cell_type": "code",
|
137 |
+
"execution_count": null,
|
138 |
+
"id": "ecfa7c64-ea3a-4189-a74e-3434f9ae72d5",
|
139 |
+
"metadata": {},
|
140 |
+
"outputs": [],
|
141 |
+
"source": [
|
142 |
+
"!python /mnt/workspace/stable-diffusion-webui/MergeTools.py --move_upscale"
|
143 |
+
]
|
144 |
+
},
|
145 |
+
{
|
146 |
+
"cell_type": "markdown",
|
147 |
+
"id": "6f885ffe-3963-48b3-836c-cf713a929c23",
|
148 |
+
"metadata": {},
|
149 |
+
"source": [
|
150 |
+
"## 将放大的图移动至父级目录"
|
151 |
+
]
|
152 |
+
},
|
153 |
+
{
|
154 |
+
"cell_type": "code",
|
155 |
+
"execution_count": null,
|
156 |
+
"id": "12c524b8-7538-4daf-89fa-6794bfc06fdb",
|
157 |
+
"metadata": {},
|
158 |
+
"outputs": [],
|
159 |
+
"source": [
|
160 |
+
"!python /mnt/workspace/stable-diffusion-webui/MergeTools.py --move_and_delete_like_upscale"
|
161 |
+
]
|
162 |
+
},
|
163 |
+
{
|
164 |
+
"cell_type": "markdown",
|
165 |
+
"id": "9e26008f-7ed7-4f67-87e1-b46f42490429",
|
166 |
+
"metadata": {},
|
167 |
+
"source": [
|
168 |
+
"## 移动模型至日期文件夹"
|
169 |
+
]
|
170 |
+
},
|
171 |
+
{
|
172 |
+
"cell_type": "code",
|
173 |
+
"execution_count": null,
|
174 |
+
"id": "0965d6f7-1bc7-4d6d-9c60-6837db657b99",
|
175 |
+
"metadata": {},
|
176 |
+
"outputs": [],
|
177 |
+
"source": [
|
178 |
+
"!python /mnt/workspace/stable-diffusion-webui/MergeTools.py --move_files_by_date"
|
179 |
+
]
|
180 |
+
},
|
181 |
+
{
|
182 |
+
"cell_type": "markdown",
|
183 |
+
"id": "28118280-6c99-4609-84c5-13e17ecb5e2b",
|
184 |
+
"metadata": {},
|
185 |
+
"source": [
|
186 |
+
"## 删除Upload文件夹的模型"
|
187 |
+
]
|
188 |
+
},
|
189 |
+
{
|
190 |
+
"cell_type": "code",
|
191 |
+
"execution_count": null,
|
192 |
+
"id": "d85fbb24-f2dc-48c2-ad95-408e7a4bbbd6",
|
193 |
+
"metadata": {},
|
194 |
+
"outputs": [],
|
195 |
+
"source": [
|
196 |
+
"!python /mnt/workspace/stable-diffusion-webui/MergeTools.py --clear_LoraUpload_model"
|
197 |
+
]
|
198 |
+
},
|
199 |
+
{
|
200 |
+
"cell_type": "markdown",
|
201 |
+
"id": "d6709532-dbfd-4040-adb5-c4a744eea2bc",
|
202 |
+
"metadata": {},
|
203 |
+
"source": [
|
204 |
+
"## 打包文件夹模型"
|
205 |
+
]
|
206 |
+
},
|
207 |
+
{
|
208 |
+
"cell_type": "code",
|
209 |
+
"execution_count": null,
|
210 |
+
"id": "2db503bb-d8fa-492d-91f4-a3cb7438f03d",
|
211 |
+
"metadata": {},
|
212 |
+
"outputs": [],
|
213 |
+
"source": [
|
214 |
+
"!python /mnt/workspace/stable-diffusion-webui/MergeTools.py --packup"
|
215 |
+
]
|
216 |
+
},
|
217 |
+
{
|
218 |
+
"cell_type": "markdown",
|
219 |
+
"id": "4ce04e9d-960b-455e-9907-6cf58c0b3bea",
|
220 |
+
"metadata": {},
|
221 |
+
"source": [
|
222 |
+
"## 上传模型"
|
223 |
+
]
|
224 |
+
},
|
225 |
+
{
|
226 |
+
"cell_type": "code",
|
227 |
+
"execution_count": null,
|
228 |
+
"id": "7d231066-6938-4faf-b30b-d4475a98f048",
|
229 |
+
"metadata": {
|
230 |
+
"tags": []
|
231 |
+
},
|
232 |
+
"outputs": [],
|
233 |
+
"source": [
|
234 |
+
"!python /mnt/workspace/stable-diffusion-webui/MergeTools.py --upload_to_modelscope"
|
235 |
+
]
|
236 |
+
}
|
237 |
+
],
|
238 |
+
"metadata": {
|
239 |
+
"kernelspec": {
|
240 |
+
"display_name": "Python 3 (ipykernel)",
|
241 |
+
"language": "python",
|
242 |
+
"name": "python3"
|
243 |
+
},
|
244 |
+
"language_info": {
|
245 |
+
"codemirror_mode": {
|
246 |
+
"name": "ipython",
|
247 |
+
"version": 3
|
248 |
+
},
|
249 |
+
"file_extension": ".py",
|
250 |
+
"mimetype": "text/x-python",
|
251 |
+
"name": "python",
|
252 |
+
"nbconvert_exporter": "python",
|
253 |
+
"pygments_lexer": "ipython3",
|
254 |
+
"version": "3.10.12"
|
255 |
+
}
|
256 |
+
},
|
257 |
+
"nbformat": 4,
|
258 |
+
"nbformat_minor": 5
|
259 |
+
}
|
MergeTools.py
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import shutil
|
3 |
+
from datetime import datetime
|
4 |
+
import pytz
|
5 |
+
import subprocess
|
6 |
+
import argparse
|
7 |
+
|
8 |
+
# 设置时区
|
9 |
+
beijing_tz = pytz.timezone('Asia/Shanghai')
|
10 |
+
# 获取当前北京时间
|
11 |
+
beijing_time = datetime.now(beijing_tz)
|
12 |
+
# 当前日期字符串
|
13 |
+
date_str = beijing_time.strftime('%m%d')
|
14 |
+
# date_str =('0818')
|
15 |
+
# 目标基目录
|
16 |
+
target_base_dir = f'/mnt/workspace/{date_str}/'
|
17 |
+
|
18 |
+
def create_directories():
|
19 |
+
# 创建目标基目录
|
20 |
+
os.makedirs(target_base_dir, exist_ok=True)
|
21 |
+
# 生成十个子文件夹
|
22 |
+
for i in range(1, 11):
|
23 |
+
subdir = f'{i:02d}'
|
24 |
+
target_dir = os.path.join(target_base_dir, subdir)
|
25 |
+
# 创建子文件夹(如果已经存在则跳过)
|
26 |
+
if not os.path.exists(target_dir):
|
27 |
+
os.makedirs(target_dir)
|
28 |
+
print(f'创建文件夹: {target_dir}')
|
29 |
+
else:
|
30 |
+
print(f'文件夹已存在: {target_dir}')
|
31 |
+
|
32 |
+
# 检查并将 /mnt/workspace/description.txt 复制到 target_dir
|
33 |
+
description_src = '/mnt/workspace/description.txt'
|
34 |
+
description_dest = os.path.join(target_base_dir, 'description.txt')
|
35 |
+
if os.path.exists(description_src):
|
36 |
+
shutil.copy(description_src, description_dest)
|
37 |
+
print(f'复制文件: {description_src} 到 {description_dest}')
|
38 |
+
else:
|
39 |
+
print(f'文件不存在: {description_src}')
|
40 |
+
|
41 |
+
def move_files_by_date():
|
42 |
+
# 第一步先检查 target_base_dir 是否存在,如果不存在则 print("WRONG")
|
43 |
+
if not os.path.exists(target_base_dir):
|
44 |
+
print("WRONG")
|
45 |
+
return
|
46 |
+
|
47 |
+
source_dir = '/mnt/workspace/stable-diffusion-webui/models/Lora/'
|
48 |
+
|
49 |
+
# 循环处理序号 01 到 10
|
50 |
+
for i in range(1, 11):
|
51 |
+
seq_num = f'{i:02d}' # 将序号格式化为两位数
|
52 |
+
source_file = os.path.join(source_dir, f'{date_str}_{seq_num}.safetensors')
|
53 |
+
target_dir = os.path.join(target_base_dir, seq_num)
|
54 |
+
|
55 |
+
# 如果源文件存在,则移动到目标目录
|
56 |
+
if os.path.exists(source_file):
|
57 |
+
os.makedirs(target_dir, exist_ok=True)
|
58 |
+
shutil.move(source_file, target_dir)
|
59 |
+
print(f'{source_file} 移动到 {target_dir}')
|
60 |
+
else:
|
61 |
+
print(f'{source_file} 不存在')
|
62 |
+
|
63 |
+
def packup():
|
64 |
+
zip_command = ['7z', 'a', f'/mnt/workspace/LoraUpload/{date_str}.zip', f'/mnt/workspace/{date_str}']
|
65 |
+
subprocess.run(zip_command)
|
66 |
+
|
67 |
+
def move_upscale():
|
68 |
+
# 第一步先检查 target_base_dir 是否存在,如不存在则 create_directories()
|
69 |
+
if not os.path.exists(target_base_dir):
|
70 |
+
create_directories()
|
71 |
+
|
72 |
+
target_to_move = None
|
73 |
+
|
74 |
+
# 第二步依次按顺序检查 target_base_dir 下的 01 到 10 这十个文件夹
|
75 |
+
for i in range(1, 11):
|
76 |
+
subdir = f'{i:02d}'
|
77 |
+
check_dir = os.path.join(target_base_dir, subdir)
|
78 |
+
upscale_dir = os.path.join(check_dir, 'Like_Upscale')
|
79 |
+
if not os.path.exists(upscale_dir):
|
80 |
+
target_to_move = check_dir
|
81 |
+
break
|
82 |
+
|
83 |
+
# 如果所有文件夹都包含 Upscale 文件夹,target_to_move 为 FULL
|
84 |
+
if target_to_move is None:
|
85 |
+
print("FULL")
|
86 |
+
else:
|
87 |
+
# 第三步,将 /mnt/workspace/Photo/Like_Upscale 移动到 target_to_move 文件夹里
|
88 |
+
source_upscale = '/mnt/workspace/Photo/Like_Upscale'
|
89 |
+
if os.path.exists(source_upscale):
|
90 |
+
shutil.move(source_upscale, target_to_move)
|
91 |
+
print(f'{source_upscale} 移动到 {target_to_move}')
|
92 |
+
else:
|
93 |
+
print(f'{source_upscale} 不存在')
|
94 |
+
|
95 |
+
def clear_LoraUpload_model():
|
96 |
+
lora_upload_dir = '/mnt/workspace/LoraUpload'
|
97 |
+
# 获取当前日期
|
98 |
+
today_str = datetime.now(beijing_tz).strftime('%m%d')
|
99 |
+
|
100 |
+
if os.path.exists(lora_upload_dir):
|
101 |
+
# 列出所有.zip文件,并按日期排序
|
102 |
+
zip_files = sorted(
|
103 |
+
[f for f in os.listdir(lora_upload_dir) if f.endswith('.zip')],
|
104 |
+
reverse=True
|
105 |
+
)
|
106 |
+
|
107 |
+
# 保留最新的一个.zip文件
|
108 |
+
for zip_file in zip_files[1:]: # 跳过最新的
|
109 |
+
zip_path = os.path.join(lora_upload_dir, zip_file)
|
110 |
+
os.remove(zip_path)
|
111 |
+
print(f'已删除: {zip_path}')
|
112 |
+
else:
|
113 |
+
print(f'{lora_upload_dir} 不存在')
|
114 |
+
|
115 |
+
def upload_to_modelscope():
|
116 |
+
from modelscope.hub.api import HubApi
|
117 |
+
YOUR_ACCESS_TOKEN = '4654205d-1369-44e3-b3ca-d12678e2950d'
|
118 |
+
api = HubApi()
|
119 |
+
api.login(YOUR_ACCESS_TOKEN)
|
120 |
+
api.push_model(
|
121 |
+
model_id="LIBLIBAI/LoraMerge",
|
122 |
+
model_dir="/mnt/workspace/LoraUpload"
|
123 |
+
)
|
124 |
+
|
125 |
+
def ClearLike():
|
126 |
+
path = "/mnt/workspace/Photo/Like"
|
127 |
+
if os.path.exists(path):
|
128 |
+
shutil.rmtree(path)
|
129 |
+
print(f"{path} 已删除")
|
130 |
+
else:
|
131 |
+
print(f"{path} 不存在")
|
132 |
+
|
133 |
+
def move_and_delete_like_upscale():
|
134 |
+
base_dir = target_base_dir
|
135 |
+
|
136 |
+
# 遍历 01 到 10 子文件夹
|
137 |
+
for i in range(1, 11):
|
138 |
+
subdir = f'{i:02d}'
|
139 |
+
like_upscale_dir = os.path.join(base_dir, subdir, 'Like_Upscale')
|
140 |
+
|
141 |
+
# 检查 Like_Upscale 文件夹是否存在
|
142 |
+
if os.path.exists(like_upscale_dir) and os.path.isdir(like_upscale_dir):
|
143 |
+
# 遍历 Like_Upscale 文件夹中的所有文件
|
144 |
+
for file_name in os.listdir(like_upscale_dir):
|
145 |
+
file_path = os.path.join(like_upscale_dir, file_name)
|
146 |
+
|
147 |
+
# 检查是否为文件(而非子目录)
|
148 |
+
if os.path.isfile(file_path):
|
149 |
+
# 移动文件到父级目录
|
150 |
+
shutil.move(file_path, os.path.join(base_dir, subdir))
|
151 |
+
print(f'已移动: {file_path} 到 {os.path.join(base_dir, subdir)}')
|
152 |
+
|
153 |
+
# 删除 Like_Upscale 文件夹
|
154 |
+
os.rmdir(like_upscale_dir)
|
155 |
+
print(f'已删除文件夹: {like_upscale_dir}')
|
156 |
+
else:
|
157 |
+
print(f'{like_upscale_dir} 不存在或不是文件夹')
|
158 |
+
|
159 |
+
# 主程序入口
|
160 |
+
if __name__ == "__main__":
|
161 |
+
# 创建 ArgumentParser 对象
|
162 |
+
parser = argparse.ArgumentParser(description='执行特定函数的脚本')
|
163 |
+
|
164 |
+
# 添加命令行参数
|
165 |
+
parser.add_argument('--create_directories', action='store_true', help='执行 create_directories 函数')
|
166 |
+
parser.add_argument('--move_and_delete_like_upscale', action='store_true', help='执行 move_and_delete_like_upscale 函数')
|
167 |
+
parser.add_argument('--ClearLike', action='store_true', help='执行 ClearLike 函数')
|
168 |
+
parser.add_argument('--move_files_by_date', action='store_true', help='执行 move_files_by_date 函数')
|
169 |
+
parser.add_argument('--packup', action='store_true', help='执行 packup 函数')
|
170 |
+
parser.add_argument('--move_upscale', action='store_true', help='执行 move_upscale 函数')
|
171 |
+
parser.add_argument('--clear_LoraUpload_model', action='store_true', help='执行 clear_LoraUpload_model 函数')
|
172 |
+
parser.add_argument('--upload_to_modelscope', action='store_true', help='执行 upload_to_modelscope 函数')
|
173 |
+
|
174 |
+
# 解析参数
|
175 |
+
args = parser.parse_args()
|
176 |
+
|
177 |
+
# 根据传入的参数执行对应的函数
|
178 |
+
if args.create_directories:
|
179 |
+
create_directories()
|
180 |
+
if args.ClearLike:
|
181 |
+
ClearLike()
|
182 |
+
if args.move_files_by_date:
|
183 |
+
move_files_by_date()
|
184 |
+
if args.packup:
|
185 |
+
packup()
|
186 |
+
if args.move_upscale:
|
187 |
+
move_upscale()
|
188 |
+
if args.move_and_delete_like_upscale:
|
189 |
+
move_and_delete_like_upscale()
|
190 |
+
if args.clear_LoraUpload_model:
|
191 |
+
clear_LoraUpload_model()
|
192 |
+
if args.upload_to_modelscope:
|
193 |
+
upload_to_modelscope()
|
PreHandel.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import re
|
3 |
+
import sys
|
4 |
+
import subprocess
|
5 |
+
import shutil
|
6 |
+
|
7 |
+
def huggingface():
|
8 |
+
os.rename("/mnt/workspace/stable-diffusion-webui/LoraDownload.py","/mnt/workspace/stable-diffusion-webui/LoraDownload.py1")
|
9 |
+
os.rename("/mnt/workspace/stable-diffusion-webui/CheckpointDownload.py","/mnt/workspace/stable-diffusion-webui/CheckpointDownload.py1")
|
10 |
+
directory = '/'
|
11 |
+
for dirpath, _, filenames in os.walk(directory):
|
12 |
+
for filename in filenames:
|
13 |
+
filepath = os.path.join(dirpath, filename)
|
14 |
+
if filename.endswith(('.py', '.txt', '.md', '.sh', '.json', '.yaml')):
|
15 |
+
try:
|
16 |
+
with open(filepath, 'r', encoding='utf-8', errors='replace') as file:
|
17 |
+
content = file.read()
|
18 |
+
new_content = re.sub(r'https://huggingface\.co', 'https://hf-mirror.com', content)
|
19 |
+
with open(filepath, 'w', encoding='utf-8', errors='replace') as file:
|
20 |
+
file.write(new_content)
|
21 |
+
except Exception as e:
|
22 |
+
print(f"Failed to process file {filepath}: {e}")
|
23 |
+
os.rename("/mnt/workspace/stable-diffusion-webui/LoraDownload.py1","/mnt/workspace/stable-diffusion-webui/LoraDownload.py")
|
24 |
+
os.rename("/mnt/workspace/stable-diffusion-webui/CheckpointDownload.py1","/mnt/workspace/stable-diffusion-webui/CheckpointDownload.py")
|
25 |
+
|
26 |
+
def API():
|
27 |
+
source = "/mnt/workspace/stable-diffusion-webui/frpc_linux_amd64_v0.2"
|
28 |
+
destination = "/usr/local/lib/python3.10/dist-packages/gradio"
|
29 |
+
if os.path.exists(source):
|
30 |
+
subprocess.run(["cp", "-f", source, destination], check=True)
|
31 |
+
subprocess.run(['sudo', 'chmod', '+x', '/usr/local/lib/python3.10/dist-packages/gradio/frpc_linux_amd64_v0.2',])
|
32 |
+
print("API success")
|
33 |
+
else:
|
34 |
+
pass
|
35 |
+
|
36 |
+
def move():
|
37 |
+
source_files = [
|
38 |
+
"/mnt/workspace/stable-diffusion-webui/SD!启动!.ipynb",
|
39 |
+
"/mnt/workspace/stable-diffusion-webui/Photo",
|
40 |
+
]
|
41 |
+
destination_dir = "/mnt/workspace"
|
42 |
+
for file_path in source_files:
|
43 |
+
if os.path.exists(file_path):
|
44 |
+
try:
|
45 |
+
shutil.move(file_path, destination_dir)
|
46 |
+
pass
|
47 |
+
except Exception as e:
|
48 |
+
pass
|
49 |
+
else:
|
50 |
+
pass
|
51 |
+
|
52 |
+
def sd_requirements():
|
53 |
+
os.chdir("/mnt/workspace/stable-diffusion-webui")
|
54 |
+
subprocess.run(["pip", "install", "-r", "requirements_versions.txt","--extra-index-url","https://download.pytorch.org/whl/cu117"])
|
55 |
+
|
56 |
+
def controlnet_requirement():
|
57 |
+
os.chdir('/mnt/workspace/stable-diffusion-webui')
|
58 |
+
os.system('pip install handrefinerportable-2024.2.12.0-py2.py3-none-any.whl')
|
59 |
+
|
60 |
+
def main():
|
61 |
+
sd_requirements()
|
62 |
+
controlnet_requirement()
|
63 |
+
huggingface()
|
64 |
+
API()
|
65 |
+
move()
|
66 |
+
|
67 |
+
if __name__ == "__main__":
|
68 |
+
main()
|
description.txt
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
类型:人脸Lora,
|
2 |
+
触发词:1girl,
|
3 |
+
提示词:参考例图,
|
4 |
+
底模:麦橘写实V7,
|
5 |
+
CFG:5~7,
|
6 |
+
分辨率:512*768,
|
7 |
+
放大算法:4x-UltraSharp,
|
8 |
+
放大倍数:2x,
|
9 |
+
Lora权重:0.6~0.8,
|
10 |
+
采样步数:20,
|
11 |
+
面部修复:Adetailer,
|
12 |
+
采样方法:Restart,
|
13 |
+
参数可按需动态调整,
|
14 |
+
欢迎大家多多返图
|
frpc_linux_amd64_v0.2
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fb74b665633589410540c49dfcef5b6f0fd4a9bd7c9558bcdee2f0e43da0774d
|
3 |
+
size 11374592
|
hf_mirror.ipynb
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"id": "649bf369-362e-416b-8a98-019981a9eff4",
|
7 |
+
"metadata": {
|
8 |
+
"tags": []
|
9 |
+
},
|
10 |
+
"outputs": [],
|
11 |
+
"source": [
|
12 |
+
"import os\n",
|
13 |
+
"import re\n",
|
14 |
+
"import sys\n",
|
15 |
+
"def hf_mirror():\n",
|
16 |
+
" directory = '/'\n",
|
17 |
+
" for dirpath, _, filenames in os.walk(directory):\n",
|
18 |
+
" for filename in filenames:\n",
|
19 |
+
" filepath = os.path.join(dirpath, filename)\n",
|
20 |
+
" if filename.endswith(('.py', '.txt', '.md', '.sh', '.json', '.yaml')):\n",
|
21 |
+
" try:\n",
|
22 |
+
" with open(filepath, 'r', encoding='utf-8', errors='replace') as file:\n",
|
23 |
+
" content = file.read()\n",
|
24 |
+
" new_content = re.sub(r'https://huggingface\\.co', 'https://hf-mirror.com', content)\n",
|
25 |
+
" with open(filepath, 'w', encoding='utf-8', errors='replace') as file:\n",
|
26 |
+
" file.write(new_content)\n",
|
27 |
+
" except Exception as e:\n",
|
28 |
+
" print(\"success\")\n",
|
29 |
+
"hf_mirror()"
|
30 |
+
]
|
31 |
+
}
|
32 |
+
],
|
33 |
+
"metadata": {
|
34 |
+
"kernelspec": {
|
35 |
+
"display_name": "Python 3 (ipykernel)",
|
36 |
+
"language": "python",
|
37 |
+
"name": "python3"
|
38 |
+
},
|
39 |
+
"language_info": {
|
40 |
+
"codemirror_mode": {
|
41 |
+
"name": "ipython",
|
42 |
+
"version": 3
|
43 |
+
},
|
44 |
+
"file_extension": ".py",
|
45 |
+
"mimetype": "text/x-python",
|
46 |
+
"name": "python",
|
47 |
+
"nbconvert_exporter": "python",
|
48 |
+
"pygments_lexer": "ipython3",
|
49 |
+
"version": "3.10.12"
|
50 |
+
}
|
51 |
+
},
|
52 |
+
"nbformat": 4,
|
53 |
+
"nbformat_minor": 5
|
54 |
+
}
|
modelscope.ipynb
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"id": "1452577f-fe12-4ebd-9624-51725719357b",
|
7 |
+
"metadata": {
|
8 |
+
"ExecutionIndicator": {
|
9 |
+
"show": true
|
10 |
+
},
|
11 |
+
"scrolled": true,
|
12 |
+
"tags": []
|
13 |
+
},
|
14 |
+
"outputs": [],
|
15 |
+
"source": [
|
16 |
+
"from modelscope.hub.api import HubApi\n",
|
17 |
+
"YOUR_ACCESS_TOKEN = ''\n",
|
18 |
+
"api = HubApi()\n",
|
19 |
+
"api.login(YOUR_ACCESS_TOKEN)\n",
|
20 |
+
"api.push_model(\n",
|
21 |
+
" model_id=\"\",\n",
|
22 |
+
" model_dir=\"/mnt/workspace/\"\n",
|
23 |
+
")"
|
24 |
+
]
|
25 |
+
}
|
26 |
+
],
|
27 |
+
"metadata": {
|
28 |
+
"kernelspec": {
|
29 |
+
"display_name": "Python 3 (ipykernel)",
|
30 |
+
"language": "python",
|
31 |
+
"name": "python3"
|
32 |
+
},
|
33 |
+
"language_info": {
|
34 |
+
"codemirror_mode": {
|
35 |
+
"name": "ipython",
|
36 |
+
"version": 3
|
37 |
+
},
|
38 |
+
"file_extension": ".py",
|
39 |
+
"mimetype": "text/x-python",
|
40 |
+
"name": "python",
|
41 |
+
"nbconvert_exporter": "python",
|
42 |
+
"pygments_lexer": "ipython3",
|
43 |
+
"version": "3.10.12"
|
44 |
+
}
|
45 |
+
},
|
46 |
+
"nbformat": 4,
|
47 |
+
"nbformat_minor": 5
|
48 |
+
}
|
search_files.ipynb
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
+
"id": "e3d91216-d411-4039-a914-3d5e23cb5335",
|
7 |
+
"metadata": {
|
8 |
+
"ExecutionIndicator": {
|
9 |
+
"show": true
|
10 |
+
},
|
11 |
+
"execution": {
|
12 |
+
"iopub.execute_input": "2024-08-16T09:45:06.206727Z",
|
13 |
+
"iopub.status.busy": "2024-08-16T09:45:06.206308Z",
|
14 |
+
"iopub.status.idle": "2024-08-16T09:45:06.266958Z",
|
15 |
+
"shell.execute_reply": "2024-08-16T09:45:06.266529Z",
|
16 |
+
"shell.execute_reply.started": "2024-08-16T09:45:06.206705Z"
|
17 |
+
},
|
18 |
+
"tags": []
|
19 |
+
},
|
20 |
+
"outputs": [
|
21 |
+
{
|
22 |
+
"name": "stdout",
|
23 |
+
"output_type": "stream",
|
24 |
+
"text": [
|
25 |
+
"['/mnt/workspace/stable-diffusion-webui/modules/ui_postprocessing.py', '/mnt/workspace/stable-diffusion-webui/modules/.ipynb_checkpoints/ui_postprocessing-checkpoint.py']\n"
|
26 |
+
]
|
27 |
+
}
|
28 |
+
],
|
29 |
+
"source": [
|
30 |
+
"import os\n",
|
31 |
+
"\n",
|
32 |
+
"def find_files_with_string(directory, search_string, file_extension=None):\n",
|
33 |
+
" matching_files = []\n",
|
34 |
+
" # 遍历目录下的所有文件和子目录\n",
|
35 |
+
" for root, dirs, files in os.walk(directory):\n",
|
36 |
+
" for file in files:\n",
|
37 |
+
" # 如果指定了文件格式,检查文件是否匹配\n",
|
38 |
+
" if file_extension and not file.endswith(file_extension):\n",
|
39 |
+
" continue\n",
|
40 |
+
" \n",
|
41 |
+
" file_path = os.path.join(root, file)\n",
|
42 |
+
" # 逐个文件打开并检查是否包含特定字符\n",
|
43 |
+
" try:\n",
|
44 |
+
" with open(file_path, 'r', encoding='utf-8') as f:\n",
|
45 |
+
" if search_string in f.read():\n",
|
46 |
+
" matching_files.append(file_path)\n",
|
47 |
+
" except (UnicodeDecodeError, FileNotFoundError):\n",
|
48 |
+
" # 如果文件不能被读取或者文件不存在,跳过\n",
|
49 |
+
" continue\n",
|
50 |
+
" return matching_files\n",
|
51 |
+
"\n",
|
52 |
+
"# 示例用法\n",
|
53 |
+
"directory = '/mnt/workspace/stable-diffusion-webui'\n",
|
54 |
+
"search_string = 'Batch from Directory'\n",
|
55 |
+
"file_extension = '.py' # 仅搜索特定格式的文件\n",
|
56 |
+
"matching_files = find_files_with_string(directory, search_string, file_extension)\n",
|
57 |
+
"print(matching_files)"
|
58 |
+
]
|
59 |
+
}
|
60 |
+
],
|
61 |
+
"metadata": {
|
62 |
+
"kernelspec": {
|
63 |
+
"display_name": "Python 3 (ipykernel)",
|
64 |
+
"language": "python",
|
65 |
+
"name": "python3"
|
66 |
+
},
|
67 |
+
"language_info": {
|
68 |
+
"codemirror_mode": {
|
69 |
+
"name": "ipython",
|
70 |
+
"version": 3
|
71 |
+
},
|
72 |
+
"file_extension": ".py",
|
73 |
+
"mimetype": "text/x-python",
|
74 |
+
"name": "python",
|
75 |
+
"nbconvert_exporter": "python",
|
76 |
+
"pygments_lexer": "ipython3",
|
77 |
+
"version": "3.10.12"
|
78 |
+
}
|
79 |
+
},
|
80 |
+
"nbformat": 4,
|
81 |
+
"nbformat_minor": 5
|
82 |
+
}
|
speedtest.ipynb
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"id": "e57f3bad-f9fc-4587-ae81-4783a7009610",
|
7 |
+
"metadata": {
|
8 |
+
"ExecutionIndicator": {
|
9 |
+
"show": true
|
10 |
+
},
|
11 |
+
"tags": []
|
12 |
+
},
|
13 |
+
"outputs": [],
|
14 |
+
"source": [
|
15 |
+
"import psutil\n",
|
16 |
+
"import time\n",
|
17 |
+
"def get_network_speed(interval=1):\n",
|
18 |
+
" net_io_1 = psutil.net_io_counters()\n",
|
19 |
+
" time.sleep(interval)\n",
|
20 |
+
" net_io_2 = psutil.net_io_counters()\n",
|
21 |
+
" bytes_sent = net_io_2.bytes_sent - net_io_1.bytes_sent\n",
|
22 |
+
" bytes_recv = net_io_2.bytes_recv - net_io_1.bytes_recv\n",
|
23 |
+
" upload_speed = (bytes_sent) / (interval * 1024 * 1024)\n",
|
24 |
+
" download_speed = (bytes_recv) / (interval * 1024 * 1024)\n",
|
25 |
+
" return upload_speed, download_speed\n",
|
26 |
+
"upload_speed, download_speed = get_network_speed()\n",
|
27 |
+
"print(f\"upload: {upload_speed:.2f} MB/S\")\n",
|
28 |
+
"print(f\"download: {download_speed:.2f} MB/S\")"
|
29 |
+
]
|
30 |
+
}
|
31 |
+
],
|
32 |
+
"metadata": {
|
33 |
+
"kernelspec": {
|
34 |
+
"display_name": "Python 3 (ipykernel)",
|
35 |
+
"language": "python",
|
36 |
+
"name": "python3"
|
37 |
+
},
|
38 |
+
"language_info": {
|
39 |
+
"codemirror_mode": {
|
40 |
+
"name": "ipython",
|
41 |
+
"version": 3
|
42 |
+
},
|
43 |
+
"file_extension": ".py",
|
44 |
+
"mimetype": "text/x-python",
|
45 |
+
"name": "python",
|
46 |
+
"nbconvert_exporter": "python",
|
47 |
+
"pygments_lexer": "ipython3",
|
48 |
+
"version": "3.10.12"
|
49 |
+
}
|
50 |
+
},
|
51 |
+
"nbformat": 4,
|
52 |
+
"nbformat_minor": 5
|
53 |
+
}
|
start.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
workspace_dir = "/mnt/workspace/stable-diffusion-webui"
|
5 |
+
os.chdir(workspace_dir)
|
6 |
+
|
7 |
+
def start():
|
8 |
+
file_name = "launch.py"
|
9 |
+
run_command = f"python {file_name} --no-download-sd-model --xformers --listen --skip-version-check --enable-insecure-extension-access --port 6666 --api --share"
|
10 |
+
subprocess.run(run_command, shell=True)
|
11 |
+
start()
|
su._prompt.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
a girl with a dreamy expression, surrounded by floating cherry blossom petals in a soft breeze, springtime magic, gentle radiance.korean girl,black hair
|
2 |
+
a girl with a sun hat, sitting in a field of sunflowers, bathed in the golden glow of sunset, warm hues, peaceful ambiance, natural beauty.korean girl,black hair,
|
3 |
+
araffe girl with long hair wearing a straw hat and blue dress, 1girl, solo, hat, straw hat, long hair, looking at viewer, necklace, jewelry, heart necklace, smile, heart, brown hair, bangs, day, beach, outdoors, upper body, black hair, sunlight, closed mouth, swimsuit, selfie, sky, ocean,
|
4 |
+
Frontal photography,Look front,evening,dark clouds,the setting sun,On the city rooftop,A 20 year old female,Black top,Black Leggings,black hair,long hair, dark theme, muted tones, pastel colors, high contrast, (natural skin texture, A dim light, high clarity) ((sky background))((Facial highlights)),
|
5 |
+
simple background,white_shirt,
|
6 |
+
simple background,china_dress,
|
7 |
+
simple background,hoodie,
|
8 |
+
simple background,nightgown,
|
9 |
+
simple background,tank_top,
|
10 |
+
simple background,sportswear,
|
zipTool.ipynb
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"id": "d70ace7c-5613-455d-8483-11b7d337ab0d",
|
7 |
+
"metadata": {
|
8 |
+
"tags": []
|
9 |
+
},
|
10 |
+
"outputs": [],
|
11 |
+
"source": [
|
12 |
+
"#zip\n",
|
13 |
+
"!7z a /mnt/workspace/*.zip /mnt/workspace/ -p"
|
14 |
+
]
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"cell_type": "code",
|
18 |
+
"execution_count": null,
|
19 |
+
"id": "162c865e-6ae5-4d71-8ef4-526656cd6052",
|
20 |
+
"metadata": {},
|
21 |
+
"outputs": [],
|
22 |
+
"source": [
|
23 |
+
"#unzip\n",
|
24 |
+
"!7z x /mnt/workspace/*.zip -o/mnt/workspace -p"
|
25 |
+
]
|
26 |
+
}
|
27 |
+
],
|
28 |
+
"metadata": {
|
29 |
+
"kernelspec": {
|
30 |
+
"display_name": "Python 3 (ipykernel)",
|
31 |
+
"language": "python",
|
32 |
+
"name": "python3"
|
33 |
+
},
|
34 |
+
"language_info": {
|
35 |
+
"codemirror_mode": {
|
36 |
+
"name": "ipython",
|
37 |
+
"version": 3
|
38 |
+
},
|
39 |
+
"file_extension": ".py",
|
40 |
+
"mimetype": "text/x-python",
|
41 |
+
"name": "python",
|
42 |
+
"nbconvert_exporter": "python",
|
43 |
+
"pygments_lexer": "ipython3",
|
44 |
+
"version": "3.10.12"
|
45 |
+
}
|
46 |
+
},
|
47 |
+
"nbformat": 4,
|
48 |
+
"nbformat_minor": 5
|
49 |
+
}
|