dong625 commited on
Commit
452cbec
1 Parent(s): fed8133

Upload sd3_launch.py

Browse files
Files changed (1) hide show
  1. sd3_launch.py +85 -0
sd3_launch.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from modules import launch_utils
3
+
4
+ args = launch_utils.args
5
+ python = launch_utils.python
6
+ git = launch_utils.git
7
+ index_url = launch_utils.index_url
8
+ dir_repos = launch_utils.dir_repos
9
+
10
+ commit_hash = launch_utils.commit_hash
11
+ git_tag = launch_utils.git_tag
12
+
13
+ run = launch_utils.run
14
+ is_installed = launch_utils.is_installed
15
+ repo_dir = launch_utils.repo_dir
16
+
17
+ run_pip = launch_utils.run_pip
18
+ check_run_python = launch_utils.check_run_python
19
+ git_clone = launch_utils.git_clone
20
+ git_pull_recursive = launch_utils.git_pull_recursive
21
+ list_extensions = launch_utils.list_extensions
22
+ run_extension_installer = launch_utils.run_extension_installer
23
+ prepare_environment = launch_utils.prepare_environment
24
+ configure_for_tests = launch_utils.configure_for_tests
25
+ start = launch_utils.start
26
+
27
+
28
+ def main():
29
+ if args.dump_sysinfo:
30
+ filename = launch_utils.dump_sysinfo()
31
+
32
+ print(f"Sysinfo saved as {filename}. Exiting...")
33
+
34
+ exit(0)
35
+
36
+ import requests
37
+ def get_daily_sentence(types=['a']):
38
+ params = {
39
+ 'c': types
40
+ }
41
+ response = requests.get("https://v1.hitokoto.cn/", params=params)
42
+ if response.status_code == 200:
43
+ data = response.json()
44
+ return "\033[36m\033[4m" + data["hitokoto"] + "\033[0m"
45
+ else:
46
+ return " \033[36m\033[4m静待花开会有时,守得云开见月明\033[0m"
47
+ daily_sentence = get_daily_sentence(['i',])
48
+
49
+ def count_execution():
50
+ if not os.path.exists("/mnt/workspace/stable-diffusion-webui/count.txt"):
51
+ with open("/mnt/workspace/stable-diffusion-webui/count.txt", "w") as f:
52
+ f.write("0")
53
+ with open("/mnt/workspace/stable-diffusion-webui/count.txt", "r") as f:
54
+ count = int(f.read())
55
+ count += 1
56
+ with open("/mnt/workspace/stable-diffusion-webui/count.txt", "w") as f:
57
+ f.write(str(count))
58
+ return count
59
+ count=count_execution()
60
+ if(count<3):
61
+ print("version SD3")
62
+ print(f"这是您在本实例中第{count}次启动SD")
63
+ print("👇请往下滑点击蓝色的\033[34m http:\\\\0.0.0.0:6666\033[0m 打开SD界面👇")
64
+ if(count>2):
65
+ print(daily_sentence)
66
+ print("version SD3")
67
+ print(f"这是您在本实例中第{count}次启动SD")
68
+ print("SD服务启动中,如在使用过程中有任何问题,请联系VX:H917724495")
69
+ if os.path.exists("/mnt/workspace/Untitled.ipynb"):
70
+ os.remove("/mnt/workspace/Untitled.ipynb")
71
+ if os.path.exists("/mnt/workspace/不会用点我.jpg"):
72
+ os.remove("/mnt/workspace/不会用点我.jpg")
73
+ launch_utils.startup_timer.record("initial startup")
74
+
75
+ with launch_utils.startup_timer.subcategory("prepare environment"):
76
+ if not args.skip_prepare_environment:
77
+ prepare_environment()
78
+
79
+ if args.test_server:
80
+ configure_for_tests()
81
+
82
+ start()
83
+
84
+ if __name__ == "__main__":
85
+ main()