Delete sd3.py
Browse files
sd3.py
DELETED
@@ -1,152 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
from modules import launch_utils
|
3 |
-
import subprocess
|
4 |
-
import sys
|
5 |
-
import shutil
|
6 |
-
|
7 |
-
args = launch_utils.args
|
8 |
-
python = launch_utils.python
|
9 |
-
git = launch_utils.git
|
10 |
-
index_url = launch_utils.index_url
|
11 |
-
dir_repos = launch_utils.dir_repos
|
12 |
-
|
13 |
-
commit_hash = launch_utils.commit_hash
|
14 |
-
git_tag = launch_utils.git_tag
|
15 |
-
|
16 |
-
run = launch_utils.run
|
17 |
-
is_installed = launch_utils.is_installed
|
18 |
-
repo_dir = launch_utils.repo_dir
|
19 |
-
|
20 |
-
run_pip = launch_utils.run_pip
|
21 |
-
check_run_python = launch_utils.check_run_python
|
22 |
-
git_clone = launch_utils.git_clone
|
23 |
-
git_pull_recursive = launch_utils.git_pull_recursive
|
24 |
-
list_extensions = launch_utils.list_extensions
|
25 |
-
run_extension_installer = launch_utils.run_extension_installer
|
26 |
-
prepare_environment = launch_utils.prepare_environment
|
27 |
-
configure_for_tests = launch_utils.configure_for_tests
|
28 |
-
start = launch_utils.start
|
29 |
-
|
30 |
-
workspace_dir = "/mnt/workspace/stable-diffusion-webui"
|
31 |
-
os.chdir(workspace_dir)
|
32 |
-
def check_blacklist():
|
33 |
-
def download_blacklist():
|
34 |
-
def aria2(url, filename, d):
|
35 |
-
subprocess.run(
|
36 |
-
["aria2c", "-c", "-x", "16", "-s", "16", url, "-o", filename, "-d", d],
|
37 |
-
stdout=subprocess.DEVNULL,
|
38 |
-
stderr=subprocess.DEVNULL
|
39 |
-
)
|
40 |
-
|
41 |
-
url = "https://hf-mirror.com/dong625/su/resolve/main/blacklist.txt"
|
42 |
-
file_path = '/mnt/blacklist.txt'
|
43 |
-
if os.path.exists(file_path):
|
44 |
-
os.remove(file_path)
|
45 |
-
aria2(url, "blacklist.txt", "/mnt")
|
46 |
-
|
47 |
-
download_blacklist()
|
48 |
-
|
49 |
-
try:
|
50 |
-
with open("/mnt/userinfo.txt", "r") as user_file:
|
51 |
-
user_content = user_file.read().strip()
|
52 |
-
except FileNotFoundError:
|
53 |
-
return False
|
54 |
-
|
55 |
-
try:
|
56 |
-
with open("/mnt/blacklist.txt", "r") as blacklist_file:
|
57 |
-
blacklist_content = blacklist_file.readlines()
|
58 |
-
except FileNotFoundError:
|
59 |
-
return True
|
60 |
-
|
61 |
-
for line in blacklist_content:
|
62 |
-
if user_content == line.strip():
|
63 |
-
return False
|
64 |
-
|
65 |
-
return True
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
def delete_files_and_folders():
|
70 |
-
paths = [
|
71 |
-
"/mnt/Controlnet.py",
|
72 |
-
"/mnt/DefourmDownload.py",
|
73 |
-
"/mnt/AnimatediffDownload.py",
|
74 |
-
"/mnt/Yolo.py",
|
75 |
-
"/mnt/prompt.py",
|
76 |
-
"/mnt/InpaintAnythingDownload.py",
|
77 |
-
"/mnt/prompt_all_in_one.py",
|
78 |
-
"/mnt/PromptLanguage.py",
|
79 |
-
"/mnt/CheckpointDownload.py",
|
80 |
-
"/mnt/LoraDownload.py",
|
81 |
-
"/mnt/ModelDownload.py",
|
82 |
-
"/mnt/workspace/stable-diffusion-webui/models/Lora/Preset",
|
83 |
-
"/mnt/workspace/stable-diffusion-webui/models/VAE-approx",
|
84 |
-
"/mnt/workspace/stable-diffusion-webui/handrefinerportable-2024.2.12.0-py2.py3-none-any.whl",
|
85 |
-
"/mnt/workspace/stable-diffusion-webui/models/ESRGAN/4x-UltraSharp.pth",
|
86 |
-
"/mnt/workspace/stable-diffusion-webui/models/RealESRGAN"
|
87 |
-
]
|
88 |
-
|
89 |
-
for path in paths:
|
90 |
-
if os.path.exists(path):
|
91 |
-
if os.path.isfile(path):
|
92 |
-
os.remove(path)
|
93 |
-
elif os.path.isdir(path):
|
94 |
-
shutil.rmtree(path)
|
95 |
-
|
96 |
-
# if not check_blacklist():
|
97 |
-
# delete_files_and_folders()
|
98 |
-
# print("You have been blocked")
|
99 |
-
# sys.exit()
|
100 |
-
|
101 |
-
def main():
|
102 |
-
if args.dump_sysinfo:
|
103 |
-
filename = launch_utils.dump_sysinfo()
|
104 |
-
|
105 |
-
print(f"Sysinfo saved as {filename}. Exiting...")
|
106 |
-
|
107 |
-
exit(0)
|
108 |
-
|
109 |
-
import requests
|
110 |
-
def get_daily_sentence(types=['a']):
|
111 |
-
params = {
|
112 |
-
'c': types
|
113 |
-
}
|
114 |
-
response = requests.get("https://v1.hitokoto.cn/", params=params)
|
115 |
-
if response.status_code == 200:
|
116 |
-
data = response.json()
|
117 |
-
return "\033[36m\033[4m" + data["hitokoto"] + "\033[0m"
|
118 |
-
else:
|
119 |
-
return " \033[36m\033[4m静待花开会有时,守得云开见月明\033[0m"
|
120 |
-
daily_sentence = get_daily_sentence(['i',])
|
121 |
-
|
122 |
-
def count_execution():
|
123 |
-
if not os.path.exists("/mnt/workspace/stable-diffusion-webui/count.txt"):
|
124 |
-
with open("/mnt/workspace/stable-diffusion-webui/count.txt", "w") as f:
|
125 |
-
f.write("0")
|
126 |
-
with open("/mnt/workspace/stable-diffusion-webui/count.txt", "r") as f:
|
127 |
-
count = int(f.read())
|
128 |
-
count += 1
|
129 |
-
with open("/mnt/workspace/stable-diffusion-webui/count.txt", "w") as f:
|
130 |
-
f.write(str(count))
|
131 |
-
return count
|
132 |
-
count=count_execution()
|
133 |
-
if(count<3):
|
134 |
-
print("version SD3")
|
135 |
-
if(count>2):
|
136 |
-
print(daily_sentence)
|
137 |
-
print("version SD3")
|
138 |
-
print(f"这是您在本实例中第{count}次启动SD")
|
139 |
-
if os.path.exists("/mnt/workspace/Untitled.ipynb"):
|
140 |
-
os.remove("/mnt/workspace/Untitled.ipynb")
|
141 |
-
launch_utils.startup_timer.record("initial startup")
|
142 |
-
with launch_utils.startup_timer.subcategory("prepare environment"):
|
143 |
-
if not args.skip_prepare_environment:
|
144 |
-
prepare_environment()
|
145 |
-
|
146 |
-
if args.test_server:
|
147 |
-
configure_for_tests()
|
148 |
-
|
149 |
-
start()
|
150 |
-
|
151 |
-
if __name__ == "__main__":
|
152 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|