NagisaNao commited on
Commit
5642a74
·
verified ·
1 Parent(s): d6a8800

♻️ What's changed?

Browse files
files_cells/notebooks/en/launch_en.ipynb CHANGED
@@ -33,7 +33,6 @@
33
  "from datetime import timedelta\n",
34
  "from IPython.display import clear_output\n",
35
  "\n",
36
- "\n",
37
  "# ================= DETECT ENV =================\n",
38
  "def detect_environment():\n",
39
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
@@ -45,24 +44,23 @@
45
  " for env_var, (environment, path) in environments.items():\n",
46
  " if env_var in os.environ:\n",
47
  " return environment, path, free_plan\n",
 
48
  "\n",
49
  "env, root_path, free_plan = detect_environment()\n",
50
  "webui_path = f\"{root_path}/sdw\"\n",
51
- "# ----------------------------------------------\n",
52
  "\n",
53
  "def load_settings():\n",
54
  " SETTINGS_FILE = f'{root_path}/settings.json'\n",
55
  " if os.path.exists(SETTINGS_FILE):\n",
56
  " with open(SETTINGS_FILE, 'r') as f:\n",
57
- " settings = json.load(f)\n",
58
- " return settings\n",
59
  "\n",
60
  "settings = load_settings()\n",
61
- "ngrok_token = settings['ngrok_token']\n",
62
- "zrok_token = settings['zrok_token']\n",
63
- "commandline_arguments = settings['commandline_arguments']\n",
64
- "change_webui = settings['change_webui']\n",
65
- "\n",
66
  "\n",
67
  "# ======================== TUNNEL V2 ========================\n",
68
  "print('Please Wait...')\n",
@@ -71,60 +69,55 @@
71
  " try:\n",
72
  " url = f'https://api64.ipify.org?format=json&{version}=true'\n",
73
  " response = requests.get(url)\n",
74
- " data = response.json()\n",
75
- " public_ip = data['ip']\n",
76
- " return public_ip\n",
77
  " except Exception as e:\n",
78
  " print(f\"Error getting public {version} address:\", e)\n",
79
  "\n",
80
  "# Check if public IP is already saved, if not then get it\n",
81
- "try:\n",
82
- " with open(f\"{root_path}/public_ip.txt\", \"r\") as file:\n",
 
83
  " public_ipv4 = file.read().strip()\n",
84
- "except FileNotFoundError:\n",
85
  " public_ipv4 = get_public_ip(version='ipv4')\n",
86
- " with open(f\"{root_path}/public_ip.txt\", \"w\") as file:\n",
87
  " file.write(public_ipv4)\n",
88
  "\n",
89
  "tunnel_class = pickle.load(open(f\"{root_path}/new_tunnel\", \"rb\"), encoding=\"utf-8\")\n",
90
- "tunnel_port = 1734\n",
91
  "tunnel = tunnel_class(tunnel_port)\n",
92
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
93
  "tunnel.add_tunnel(command=\"lt --port {port}\", name=\"lt\", pattern=re.compile(r\"[\\w-]+\\.loca\\.lt\"), note=\"Password : \" + \"\\033[32m\" + public_ipv4 + \"\\033[0m\" + \" rerun cell if 404 error.\")\n",
94
  "\n",
95
- "''' add zrok tunnel '''\n",
96
  "if zrok_token:\n",
97
- " get_ipython().system('zrok enable {zrok_token} &> /dev/null')\n",
98
  " tunnel.add_tunnel(command=\"zrok share public http://localhost:{port}/ --headless\", name=\"zrok\", pattern=re.compile(r\"[\\w-]+\\.share\\.zrok\\.io\"))\n",
99
  "\n",
100
  "clear_output()\n",
101
  "\n",
102
- "\n",
103
  "# =============== Automatic Fixing Path V3 ===============\n",
104
- "paths_to_check = [\n",
105
- " (\"tagger_hf_cache_dir\", f\"{webui_path}/models/interrogators/\"),\n",
106
- " (\"additional_networks_extra_lora_path\", f\"{webui_path}/models/Lora/\"),\n",
107
- " (\"ad_extra_models_dir\", f\"{webui_path}/models/adetailer/\"),\n",
108
- " (\"sd_checkpoint_hash\", \"\"),\n",
109
- " (\"sd_model_checkpoint\", \"\"),\n",
110
- " (\"sd_vae\", \"None\")\n",
111
- "]\n",
112
  "\n",
113
  "config_path = f'{webui_path}/ui-config.json'\n",
114
  "\n",
115
- "with open(config_path, 'r') as file:\n",
116
- " config_data = json.load(file)\n",
 
117
  "\n",
118
- "for key, value in paths_to_check:\n",
119
- " if key in config_data and config_data[key] != value:\n",
120
- " sed_command = f\"sed -i 's|\\\"{key}\\\": \\\".*\\\"|\\\"{key}\\\": \\\"{value}\\\"|' {config_path}\"\n",
121
- " os.system(sed_command)\n",
122
- "\n",
123
- "# Additional check for Kaggle\n",
124
- "if env == 'Kaggle':\n",
125
- " get_ipython().system('sed -i \\'s/\"civitai_interface\\\\/NSFW content\\\\/value\":.*/\"civitai_interface\\\\/NSFW content\\\\/value\": false/g\\' {webui_path}/ui-config.json')\n",
126
- "# -------------------------------------------------------\n",
127
  "\n",
 
 
128
  "\n",
129
  "with tunnel:\n",
130
  " %cd {webui_path}\n",
@@ -135,19 +128,15 @@
135
  " if env != \"Google Colab\":\n",
136
  " commandline_arguments += f' --encrypt-pass={tunnel_port} --api'\n",
137
  "\n",
138
- " # -- FORGE --\n",
139
  " if change_webui == 'Forge':\n",
140
  " commandline_arguments += ' --cuda-stream --pin-shared-memory'\n",
141
  "\n",
142
  " !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
143
  "\n",
144
- "\n",
145
- "# after runnig\n",
146
  "start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
147
  "time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
148
  "print(f\"\\n⌚️ \\033[0mYou have been conducting this session for - \\033[33m{time_since_start}\\033[0m\\n\\n\")\n",
149
  "\n",
150
- "''' del zrok tunnel '''\n",
151
  "if zrok_token:\n",
152
  " !zrok disable &> /dev/null"
153
  ]
 
33
  "from datetime import timedelta\n",
34
  "from IPython.display import clear_output\n",
35
  "\n",
 
36
  "# ================= DETECT ENV =================\n",
37
  "def detect_environment():\n",
38
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
 
44
  " for env_var, (environment, path) in environments.items():\n",
45
  " if env_var in os.environ:\n",
46
  " return environment, path, free_plan\n",
47
+ " return 'Unknown', '/unknown/path', free_plan\n",
48
  "\n",
49
  "env, root_path, free_plan = detect_environment()\n",
50
  "webui_path = f\"{root_path}/sdw\"\n",
 
51
  "\n",
52
  "def load_settings():\n",
53
  " SETTINGS_FILE = f'{root_path}/settings.json'\n",
54
  " if os.path.exists(SETTINGS_FILE):\n",
55
  " with open(SETTINGS_FILE, 'r') as f:\n",
56
+ " return json.load(f)\n",
57
+ " return {}\n",
58
  "\n",
59
  "settings = load_settings()\n",
60
+ "ngrok_token = settings.get('ngrok_token', \"\")\n",
61
+ "zrok_token = settings.get('zrok_token', \"\")\n",
62
+ "commandline_arguments = settings.get('commandline_arguments', \"\")\n",
63
+ "change_webui = settings.get('change_webui', \"\")\n",
 
64
  "\n",
65
  "# ======================== TUNNEL V2 ========================\n",
66
  "print('Please Wait...')\n",
 
69
  " try:\n",
70
  " url = f'https://api64.ipify.org?format=json&{version}=true'\n",
71
  " response = requests.get(url)\n",
72
+ " return response.json().get('ip', 'N/A')\n",
 
 
73
  " except Exception as e:\n",
74
  " print(f\"Error getting public {version} address:\", e)\n",
75
  "\n",
76
  "# Check if public IP is already saved, if not then get it\n",
77
+ "public_ip_file = f\"{root_path}/public_ip.txt\"\n",
78
+ "if os.path.exists(public_ip_file):\n",
79
+ " with open(public_ip_file, 'r') as file:\n",
80
  " public_ipv4 = file.read().strip()\n",
81
+ "else:\n",
82
  " public_ipv4 = get_public_ip(version='ipv4')\n",
83
+ " with open(public_ip_file, 'w') as file:\n",
84
  " file.write(public_ipv4)\n",
85
  "\n",
86
  "tunnel_class = pickle.load(open(f\"{root_path}/new_tunnel\", \"rb\"), encoding=\"utf-8\")\n",
87
+ "tunnel_port = 1834\n",
88
  "tunnel = tunnel_class(tunnel_port)\n",
89
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
90
  "tunnel.add_tunnel(command=\"lt --port {port}\", name=\"lt\", pattern=re.compile(r\"[\\w-]+\\.loca\\.lt\"), note=\"Password : \" + \"\\033[32m\" + public_ipv4 + \"\\033[0m\" + \" rerun cell if 404 error.\")\n",
91
  "\n",
 
92
  "if zrok_token:\n",
93
+ " !zrok enable {zrok_token} &> /dev/null\n",
94
  " tunnel.add_tunnel(command=\"zrok share public http://localhost:{port}/ --headless\", name=\"zrok\", pattern=re.compile(r\"[\\w-]+\\.share\\.zrok\\.io\"))\n",
95
  "\n",
96
  "clear_output()\n",
97
  "\n",
 
98
  "# =============== Automatic Fixing Path V3 ===============\n",
99
+ "paths_to_check = {\n",
100
+ " \"tagger_hf_cache_dir\": f\"{webui_path}/models/interrogators/\",\n",
101
+ " \"additional_networks_extra_lora_path\": f\"{webui_path}/models/Lora/\",\n",
102
+ " \"ad_extra_models_dir\": f\"{webui_path}/models/adetailer/\",\n",
103
+ " \"sd_checkpoint_hash\": \"\",\n",
104
+ " \"sd_model_checkpoint\": \"\",\n",
105
+ " \"sd_vae\": \"None\"\n",
106
+ "}\n",
107
  "\n",
108
  "config_path = f'{webui_path}/ui-config.json'\n",
109
  "\n",
110
+ "if os.path.exists(config_path):\n",
111
+ " with open(config_path, 'r') as file:\n",
112
+ " config_data = json.load(file)\n",
113
  "\n",
114
+ " for key, value in paths_to_check.items():\n",
115
+ " if key in config_data and config_data[key] != value:\n",
116
+ " sed_command = f\"sed -i 's|\\\"{key}\\\": \\\".*\\\"|\\\"{key}\\\": \\\"{value}\\\"|' {config_path}\"\n",
117
+ " os.system(sed_command)\n",
 
 
 
 
 
118
  "\n",
119
+ " if env == 'Kaggle':\n",
120
+ " get_ipython().system('sed -i \\'s/\"civitai_interface\\\\/NSFW content\\\\/value\":.*/\"civitai_interface\\\\/NSFW content\\\\/value\": false/g\\' {webui_path}/ui-config.json')\n",
121
  "\n",
122
  "with tunnel:\n",
123
  " %cd {webui_path}\n",
 
128
  " if env != \"Google Colab\":\n",
129
  " commandline_arguments += f' --encrypt-pass={tunnel_port} --api'\n",
130
  "\n",
 
131
  " if change_webui == 'Forge':\n",
132
  " commandline_arguments += ' --cuda-stream --pin-shared-memory'\n",
133
  "\n",
134
  " !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
135
  "\n",
 
 
136
  "start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
137
  "time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
138
  "print(f\"\\n⌚️ \\033[0mYou have been conducting this session for - \\033[33m{time_since_start}\\033[0m\\n\\n\")\n",
139
  "\n",
 
140
  "if zrok_token:\n",
141
  " !zrok disable &> /dev/null"
142
  ]
files_cells/notebooks/ru/launch_ru.ipynb CHANGED
@@ -33,7 +33,6 @@
33
  "from datetime import timedelta\n",
34
  "from IPython.display import clear_output\n",
35
  "\n",
36
- "\n",
37
  "# ================= DETECT ENV =================\n",
38
  "def detect_environment():\n",
39
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
@@ -45,24 +44,23 @@
45
  " for env_var, (environment, path) in environments.items():\n",
46
  " if env_var in os.environ:\n",
47
  " return environment, path, free_plan\n",
 
48
  "\n",
49
  "env, root_path, free_plan = detect_environment()\n",
50
  "webui_path = f\"{root_path}/sdw\"\n",
51
- "# ----------------------------------------------\n",
52
  "\n",
53
  "def load_settings():\n",
54
  " SETTINGS_FILE = f'{root_path}/settings.json'\n",
55
  " if os.path.exists(SETTINGS_FILE):\n",
56
  " with open(SETTINGS_FILE, 'r') as f:\n",
57
- " settings = json.load(f)\n",
58
- " return settings\n",
59
  "\n",
60
  "settings = load_settings()\n",
61
- "ngrok_token = settings['ngrok_token']\n",
62
- "zrok_token = settings['zrok_token']\n",
63
- "commandline_arguments = settings['commandline_arguments']\n",
64
- "change_webui = settings['change_webui']\n",
65
- "\n",
66
  "\n",
67
  "# ======================== TUNNEL V2 ========================\n",
68
  "print('Please Wait...')\n",
@@ -71,60 +69,55 @@
71
  " try:\n",
72
  " url = f'https://api64.ipify.org?format=json&{version}=true'\n",
73
  " response = requests.get(url)\n",
74
- " data = response.json()\n",
75
- " public_ip = data['ip']\n",
76
- " return public_ip\n",
77
  " except Exception as e:\n",
78
  " print(f\"Error getting public {version} address:\", e)\n",
79
  "\n",
80
  "# Check if public IP is already saved, if not then get it\n",
81
- "try:\n",
82
- " with open(f\"{root_path}/public_ip.txt\", \"r\") as file:\n",
 
83
  " public_ipv4 = file.read().strip()\n",
84
- "except FileNotFoundError:\n",
85
  " public_ipv4 = get_public_ip(version='ipv4')\n",
86
- " with open(f\"{root_path}/public_ip.txt\", \"w\") as file:\n",
87
  " file.write(public_ipv4)\n",
88
  "\n",
89
  "tunnel_class = pickle.load(open(f\"{root_path}/new_tunnel\", \"rb\"), encoding=\"utf-8\")\n",
90
- "tunnel_port = 1734\n",
91
  "tunnel = tunnel_class(tunnel_port)\n",
92
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
93
  "tunnel.add_tunnel(command=\"lt --port {port}\", name=\"lt\", pattern=re.compile(r\"[\\w-]+\\.loca\\.lt\"), note=\"Password : \" + \"\\033[32m\" + public_ipv4 + \"\\033[0m\" + \" rerun cell if 404 error.\")\n",
94
  "\n",
95
- "''' add zrok tunnel '''\n",
96
  "if zrok_token:\n",
97
- " get_ipython().system('zrok enable {zrok_token} &> /dev/null')\n",
98
  " tunnel.add_tunnel(command=\"zrok share public http://localhost:{port}/ --headless\", name=\"zrok\", pattern=re.compile(r\"[\\w-]+\\.share\\.zrok\\.io\"))\n",
99
  "\n",
100
  "clear_output()\n",
101
  "\n",
102
- "\n",
103
  "# =============== Automatic Fixing Path V3 ===============\n",
104
- "paths_to_check = [\n",
105
- " (\"tagger_hf_cache_dir\", f\"{webui_path}/models/interrogators/\"),\n",
106
- " (\"additional_networks_extra_lora_path\", f\"{webui_path}/models/Lora/\"),\n",
107
- " (\"ad_extra_models_dir\", f\"{webui_path}/models/adetailer/\"),\n",
108
- " (\"sd_checkpoint_hash\", \"\"),\n",
109
- " (\"sd_model_checkpoint\", \"\"),\n",
110
- " (\"sd_vae\", \"None\")\n",
111
- "]\n",
112
  "\n",
113
  "config_path = f'{webui_path}/ui-config.json'\n",
114
  "\n",
115
- "with open(config_path, 'r') as file:\n",
116
- " config_data = json.load(file)\n",
 
117
  "\n",
118
- "for key, value in paths_to_check:\n",
119
- " if key in config_data and config_data[key] != value:\n",
120
- " sed_command = f\"sed -i 's|\\\"{key}\\\": \\\".*\\\"|\\\"{key}\\\": \\\"{value}\\\"|' {config_path}\"\n",
121
- " os.system(sed_command)\n",
122
- "\n",
123
- "# Additional check for Kaggle\n",
124
- "if env == 'Kaggle':\n",
125
- " get_ipython().system('sed -i \\'s/\"civitai_interface\\\\/NSFW content\\\\/value\":.*/\"civitai_interface\\\\/NSFW content\\\\/value\": false/g\\' {webui_path}/ui-config.json')\n",
126
- "# -------------------------------------------------------\n",
127
  "\n",
 
 
128
  "\n",
129
  "with tunnel:\n",
130
  " %cd {webui_path}\n",
@@ -135,19 +128,15 @@
135
  " if env != \"Google Colab\":\n",
136
  " commandline_arguments += f' --encrypt-pass={tunnel_port} --api'\n",
137
  "\n",
138
- " # -- FORGE --\n",
139
  " if change_webui == 'Forge':\n",
140
  " commandline_arguments += ' --cuda-stream --pin-shared-memory'\n",
141
  "\n",
142
  " !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
143
  "\n",
144
- "\n",
145
- "# after runnig\n",
146
  "start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
147
  "time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
148
  "print(f\"\\n⌚️ \\033[0mВы проводите эту сессию в течение - \\033[33m{time_since_start}\\033[0m\\n\\n\")\n",
149
  "\n",
150
- "''' del zrok tunnel '''\n",
151
  "if zrok_token:\n",
152
  " !zrok disable &> /dev/null"
153
  ]
 
33
  "from datetime import timedelta\n",
34
  "from IPython.display import clear_output\n",
35
  "\n",
 
36
  "# ================= DETECT ENV =================\n",
37
  "def detect_environment():\n",
38
  " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)\n",
 
44
  " for env_var, (environment, path) in environments.items():\n",
45
  " if env_var in os.environ:\n",
46
  " return environment, path, free_plan\n",
47
+ " return 'Unknown', '/unknown/path', free_plan\n",
48
  "\n",
49
  "env, root_path, free_plan = detect_environment()\n",
50
  "webui_path = f\"{root_path}/sdw\"\n",
 
51
  "\n",
52
  "def load_settings():\n",
53
  " SETTINGS_FILE = f'{root_path}/settings.json'\n",
54
  " if os.path.exists(SETTINGS_FILE):\n",
55
  " with open(SETTINGS_FILE, 'r') as f:\n",
56
+ " return json.load(f)\n",
57
+ " return {}\n",
58
  "\n",
59
  "settings = load_settings()\n",
60
+ "ngrok_token = settings.get('ngrok_token', \"\")\n",
61
+ "zrok_token = settings.get('zrok_token', \"\")\n",
62
+ "commandline_arguments = settings.get('commandline_arguments', \"\")\n",
63
+ "change_webui = settings.get('change_webui', \"\")\n",
 
64
  "\n",
65
  "# ======================== TUNNEL V2 ========================\n",
66
  "print('Please Wait...')\n",
 
69
  " try:\n",
70
  " url = f'https://api64.ipify.org?format=json&{version}=true'\n",
71
  " response = requests.get(url)\n",
72
+ " return response.json().get('ip', 'N/A')\n",
 
 
73
  " except Exception as e:\n",
74
  " print(f\"Error getting public {version} address:\", e)\n",
75
  "\n",
76
  "# Check if public IP is already saved, if not then get it\n",
77
+ "public_ip_file = f\"{root_path}/public_ip.txt\"\n",
78
+ "if os.path.exists(public_ip_file):\n",
79
+ " with open(public_ip_file, 'r') as file:\n",
80
  " public_ipv4 = file.read().strip()\n",
81
+ "else:\n",
82
  " public_ipv4 = get_public_ip(version='ipv4')\n",
83
+ " with open(public_ip_file, 'w') as file:\n",
84
  " file.write(public_ipv4)\n",
85
  "\n",
86
  "tunnel_class = pickle.load(open(f\"{root_path}/new_tunnel\", \"rb\"), encoding=\"utf-8\")\n",
87
+ "tunnel_port = 1834\n",
88
  "tunnel = tunnel_class(tunnel_port)\n",
89
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
90
  "tunnel.add_tunnel(command=\"lt --port {port}\", name=\"lt\", pattern=re.compile(r\"[\\w-]+\\.loca\\.lt\"), note=\"Password : \" + \"\\033[32m\" + public_ipv4 + \"\\033[0m\" + \" rerun cell if 404 error.\")\n",
91
  "\n",
 
92
  "if zrok_token:\n",
93
+ " !zrok enable {zrok_token} &> /dev/null\n",
94
  " tunnel.add_tunnel(command=\"zrok share public http://localhost:{port}/ --headless\", name=\"zrok\", pattern=re.compile(r\"[\\w-]+\\.share\\.zrok\\.io\"))\n",
95
  "\n",
96
  "clear_output()\n",
97
  "\n",
 
98
  "# =============== Automatic Fixing Path V3 ===============\n",
99
+ "paths_to_check = {\n",
100
+ " \"tagger_hf_cache_dir\": f\"{webui_path}/models/interrogators/\",\n",
101
+ " \"additional_networks_extra_lora_path\": f\"{webui_path}/models/Lora/\",\n",
102
+ " \"ad_extra_models_dir\": f\"{webui_path}/models/adetailer/\",\n",
103
+ " \"sd_checkpoint_hash\": \"\",\n",
104
+ " \"sd_model_checkpoint\": \"\",\n",
105
+ " \"sd_vae\": \"None\"\n",
106
+ "}\n",
107
  "\n",
108
  "config_path = f'{webui_path}/ui-config.json'\n",
109
  "\n",
110
+ "if os.path.exists(config_path):\n",
111
+ " with open(config_path, 'r') as file:\n",
112
+ " config_data = json.load(file)\n",
113
  "\n",
114
+ " for key, value in paths_to_check.items():\n",
115
+ " if key in config_data and config_data[key] != value:\n",
116
+ " sed_command = f\"sed -i 's|\\\"{key}\\\": \\\".*\\\"|\\\"{key}\\\": \\\"{value}\\\"|' {config_path}\"\n",
117
+ " os.system(sed_command)\n",
 
 
 
 
 
118
  "\n",
119
+ " if env == 'Kaggle':\n",
120
+ " get_ipython().system('sed -i \\'s/\"civitai_interface\\\\/NSFW content\\\\/value\":.*/\"civitai_interface\\\\/NSFW content\\\\/value\": false/g\\' {webui_path}/ui-config.json')\n",
121
  "\n",
122
  "with tunnel:\n",
123
  " %cd {webui_path}\n",
 
128
  " if env != \"Google Colab\":\n",
129
  " commandline_arguments += f' --encrypt-pass={tunnel_port} --api'\n",
130
  "\n",
 
131
  " if change_webui == 'Forge':\n",
132
  " commandline_arguments += ' --cuda-stream --pin-shared-memory'\n",
133
  "\n",
134
  " !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
135
  "\n",
 
 
136
  "start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
137
  "time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
138
  "print(f\"\\n⌚️ \\033[0mВы проводите эту сессию в течение - \\033[33m{time_since_start}\\033[0m\\n\\n\")\n",
139
  "\n",
 
140
  "if zrok_token:\n",
141
  " !zrok disable &> /dev/null"
142
  ]
files_cells/python/en/launch_en.py CHANGED
@@ -9,7 +9,6 @@ import cloudpickle as pickle
9
  from datetime import timedelta
10
  from IPython.display import clear_output
11
 
12
-
13
  # ================= DETECT ENV =================
14
  def detect_environment():
15
  free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
@@ -21,24 +20,23 @@ def detect_environment():
21
  for env_var, (environment, path) in environments.items():
22
  if env_var in os.environ:
23
  return environment, path, free_plan
 
24
 
25
  env, root_path, free_plan = detect_environment()
26
  webui_path = f"{root_path}/sdw"
27
- # ----------------------------------------------
28
 
29
  def load_settings():
30
  SETTINGS_FILE = f'{root_path}/settings.json'
31
  if os.path.exists(SETTINGS_FILE):
32
  with open(SETTINGS_FILE, 'r') as f:
33
- settings = json.load(f)
34
- return settings
35
 
36
  settings = load_settings()
37
- ngrok_token = settings['ngrok_token']
38
- zrok_token = settings['zrok_token']
39
- commandline_arguments = settings['commandline_arguments']
40
- change_webui = settings['change_webui']
41
-
42
 
43
  # ======================== TUNNEL V2 ========================
44
  print('Please Wait...')
@@ -47,60 +45,55 @@ def get_public_ip(version='ipv4'):
47
  try:
48
  url = f'https://api64.ipify.org?format=json&{version}=true'
49
  response = requests.get(url)
50
- data = response.json()
51
- public_ip = data['ip']
52
- return public_ip
53
  except Exception as e:
54
  print(f"Error getting public {version} address:", e)
55
 
56
  # Check if public IP is already saved, if not then get it
57
- try:
58
- with open(f"{root_path}/public_ip.txt", "r") as file:
 
59
  public_ipv4 = file.read().strip()
60
- except FileNotFoundError:
61
  public_ipv4 = get_public_ip(version='ipv4')
62
- with open(f"{root_path}/public_ip.txt", "w") as file:
63
  file.write(public_ipv4)
64
 
65
  tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-8")
66
- tunnel_port = 1734
67
  tunnel = tunnel_class(tunnel_port)
68
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
69
  tunnel.add_tunnel(command="lt --port {port}", name="lt", pattern=re.compile(r"[\w-]+\.loca\.lt"), note="Password : " + "\033[32m" + public_ipv4 + "\033[0m" + " rerun cell if 404 error.")
70
 
71
- ''' add zrok tunnel '''
72
  if zrok_token:
73
  get_ipython().system('zrok enable {zrok_token} &> /dev/null')
74
  tunnel.add_tunnel(command="zrok share public http://localhost:{port}/ --headless", name="zrok", pattern=re.compile(r"[\w-]+\.share\.zrok\.io"))
75
 
76
  clear_output()
77
 
78
-
79
  # =============== Automatic Fixing Path V3 ===============
80
- paths_to_check = [
81
- ("tagger_hf_cache_dir", f"{webui_path}/models/interrogators/"),
82
- ("additional_networks_extra_lora_path", f"{webui_path}/models/Lora/"),
83
- ("ad_extra_models_dir", f"{webui_path}/models/adetailer/"),
84
- ("sd_checkpoint_hash", ""),
85
- ("sd_model_checkpoint", ""),
86
- ("sd_vae", "None")
87
- ]
88
 
89
  config_path = f'{webui_path}/ui-config.json'
90
 
91
- with open(config_path, 'r') as file:
92
- config_data = json.load(file)
 
93
 
94
- for key, value in paths_to_check:
95
- if key in config_data and config_data[key] != value:
96
- sed_command = f"sed -i 's|\"{key}\": \".*\"|\"{key}\": \"{value}\"|' {config_path}"
97
- os.system(sed_command)
98
-
99
- # Additional check for Kaggle
100
- if env == 'Kaggle':
101
- get_ipython().system('sed -i \'s/"civitai_interface\\/NSFW content\\/value":.*/"civitai_interface\\/NSFW content\\/value": false/g\' {webui_path}/ui-config.json')
102
- # -------------------------------------------------------
103
 
 
 
104
 
105
  with tunnel:
106
  get_ipython().run_line_magic('cd', '{webui_path}')
@@ -111,19 +104,15 @@ with tunnel:
111
  if env != "Google Colab":
112
  commandline_arguments += f' --encrypt-pass={tunnel_port} --api'
113
 
114
- # -- FORGE --
115
  if change_webui == 'Forge':
116
  commandline_arguments += ' --cuda-stream --pin-shared-memory'
117
 
118
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
119
 
120
-
121
- # after runnig
122
  start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
123
  time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
124
  print(f"\n⌚️ \033[0mYou have been conducting this session for - \033[33m{time_since_start}\033[0m\n\n")
125
 
126
- ''' del zrok tunnel '''
127
  if zrok_token:
128
  get_ipython().system('zrok disable &> /dev/null')
129
 
 
9
  from datetime import timedelta
10
  from IPython.display import clear_output
11
 
 
12
  # ================= DETECT ENV =================
13
  def detect_environment():
14
  free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
 
20
  for env_var, (environment, path) in environments.items():
21
  if env_var in os.environ:
22
  return environment, path, free_plan
23
+ return 'Unknown', '/unknown/path', free_plan
24
 
25
  env, root_path, free_plan = detect_environment()
26
  webui_path = f"{root_path}/sdw"
 
27
 
28
  def load_settings():
29
  SETTINGS_FILE = f'{root_path}/settings.json'
30
  if os.path.exists(SETTINGS_FILE):
31
  with open(SETTINGS_FILE, 'r') as f:
32
+ return json.load(f)
33
+ return {}
34
 
35
  settings = load_settings()
36
+ ngrok_token = settings.get('ngrok_token', "")
37
+ zrok_token = settings.get('zrok_token', "")
38
+ commandline_arguments = settings.get('commandline_arguments', "")
39
+ change_webui = settings.get('change_webui', "")
 
40
 
41
  # ======================== TUNNEL V2 ========================
42
  print('Please Wait...')
 
45
  try:
46
  url = f'https://api64.ipify.org?format=json&{version}=true'
47
  response = requests.get(url)
48
+ return response.json().get('ip', 'N/A')
 
 
49
  except Exception as e:
50
  print(f"Error getting public {version} address:", e)
51
 
52
  # Check if public IP is already saved, if not then get it
53
+ public_ip_file = f"{root_path}/public_ip.txt"
54
+ if os.path.exists(public_ip_file):
55
+ with open(public_ip_file, 'r') as file:
56
  public_ipv4 = file.read().strip()
57
+ else:
58
  public_ipv4 = get_public_ip(version='ipv4')
59
+ with open(public_ip_file, 'w') as file:
60
  file.write(public_ipv4)
61
 
62
  tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-8")
63
+ tunnel_port = 1834
64
  tunnel = tunnel_class(tunnel_port)
65
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
66
  tunnel.add_tunnel(command="lt --port {port}", name="lt", pattern=re.compile(r"[\w-]+\.loca\.lt"), note="Password : " + "\033[32m" + public_ipv4 + "\033[0m" + " rerun cell if 404 error.")
67
 
 
68
  if zrok_token:
69
  get_ipython().system('zrok enable {zrok_token} &> /dev/null')
70
  tunnel.add_tunnel(command="zrok share public http://localhost:{port}/ --headless", name="zrok", pattern=re.compile(r"[\w-]+\.share\.zrok\.io"))
71
 
72
  clear_output()
73
 
 
74
  # =============== Automatic Fixing Path V3 ===============
75
+ paths_to_check = {
76
+ "tagger_hf_cache_dir": f"{webui_path}/models/interrogators/",
77
+ "additional_networks_extra_lora_path": f"{webui_path}/models/Lora/",
78
+ "ad_extra_models_dir": f"{webui_path}/models/adetailer/",
79
+ "sd_checkpoint_hash": "",
80
+ "sd_model_checkpoint": "",
81
+ "sd_vae": "None"
82
+ }
83
 
84
  config_path = f'{webui_path}/ui-config.json'
85
 
86
+ if os.path.exists(config_path):
87
+ with open(config_path, 'r') as file:
88
+ config_data = json.load(file)
89
 
90
+ for key, value in paths_to_check.items():
91
+ if key in config_data and config_data[key] != value:
92
+ sed_command = f"sed -i 's|\"{key}\": \".*\"|\"{key}\": \"{value}\"|' {config_path}"
93
+ os.system(sed_command)
 
 
 
 
 
94
 
95
+ if env == 'Kaggle':
96
+ get_ipython().system('sed -i \'s/"civitai_interface\\/NSFW content\\/value":.*/"civitai_interface\\/NSFW content\\/value": false/g\' {webui_path}/ui-config.json')
97
 
98
  with tunnel:
99
  get_ipython().run_line_magic('cd', '{webui_path}')
 
104
  if env != "Google Colab":
105
  commandline_arguments += f' --encrypt-pass={tunnel_port} --api'
106
 
 
107
  if change_webui == 'Forge':
108
  commandline_arguments += ' --cuda-stream --pin-shared-memory'
109
 
110
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
111
 
 
 
112
  start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
113
  time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
114
  print(f"\n⌚️ \033[0mYou have been conducting this session for - \033[33m{time_since_start}\033[0m\n\n")
115
 
 
116
  if zrok_token:
117
  get_ipython().system('zrok disable &> /dev/null')
118
 
files_cells/python/ru/launch_ru.py CHANGED
@@ -9,7 +9,6 @@ import cloudpickle as pickle
9
  from datetime import timedelta
10
  from IPython.display import clear_output
11
 
12
-
13
  # ================= DETECT ENV =================
14
  def detect_environment():
15
  free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
@@ -21,24 +20,23 @@ def detect_environment():
21
  for env_var, (environment, path) in environments.items():
22
  if env_var in os.environ:
23
  return environment, path, free_plan
 
24
 
25
  env, root_path, free_plan = detect_environment()
26
  webui_path = f"{root_path}/sdw"
27
- # ----------------------------------------------
28
 
29
  def load_settings():
30
  SETTINGS_FILE = f'{root_path}/settings.json'
31
  if os.path.exists(SETTINGS_FILE):
32
  with open(SETTINGS_FILE, 'r') as f:
33
- settings = json.load(f)
34
- return settings
35
 
36
  settings = load_settings()
37
- ngrok_token = settings['ngrok_token']
38
- zrok_token = settings['zrok_token']
39
- commandline_arguments = settings['commandline_arguments']
40
- change_webui = settings['change_webui']
41
-
42
 
43
  # ======================== TUNNEL V2 ========================
44
  print('Please Wait...')
@@ -47,60 +45,55 @@ def get_public_ip(version='ipv4'):
47
  try:
48
  url = f'https://api64.ipify.org?format=json&{version}=true'
49
  response = requests.get(url)
50
- data = response.json()
51
- public_ip = data['ip']
52
- return public_ip
53
  except Exception as e:
54
  print(f"Error getting public {version} address:", e)
55
 
56
  # Check if public IP is already saved, if not then get it
57
- try:
58
- with open(f"{root_path}/public_ip.txt", "r") as file:
 
59
  public_ipv4 = file.read().strip()
60
- except FileNotFoundError:
61
  public_ipv4 = get_public_ip(version='ipv4')
62
- with open(f"{root_path}/public_ip.txt", "w") as file:
63
  file.write(public_ipv4)
64
 
65
  tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-8")
66
- tunnel_port = 1734
67
  tunnel = tunnel_class(tunnel_port)
68
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
69
  tunnel.add_tunnel(command="lt --port {port}", name="lt", pattern=re.compile(r"[\w-]+\.loca\.lt"), note="Password : " + "\033[32m" + public_ipv4 + "\033[0m" + " rerun cell if 404 error.")
70
 
71
- ''' add zrok tunnel '''
72
  if zrok_token:
73
  get_ipython().system('zrok enable {zrok_token} &> /dev/null')
74
  tunnel.add_tunnel(command="zrok share public http://localhost:{port}/ --headless", name="zrok", pattern=re.compile(r"[\w-]+\.share\.zrok\.io"))
75
 
76
  clear_output()
77
 
78
-
79
  # =============== Automatic Fixing Path V3 ===============
80
- paths_to_check = [
81
- ("tagger_hf_cache_dir", f"{webui_path}/models/interrogators/"),
82
- ("additional_networks_extra_lora_path", f"{webui_path}/models/Lora/"),
83
- ("ad_extra_models_dir", f"{webui_path}/models/adetailer/"),
84
- ("sd_checkpoint_hash", ""),
85
- ("sd_model_checkpoint", ""),
86
- ("sd_vae", "None")
87
- ]
88
 
89
  config_path = f'{webui_path}/ui-config.json'
90
 
91
- with open(config_path, 'r') as file:
92
- config_data = json.load(file)
 
93
 
94
- for key, value in paths_to_check:
95
- if key in config_data and config_data[key] != value:
96
- sed_command = f"sed -i 's|\"{key}\": \".*\"|\"{key}\": \"{value}\"|' {config_path}"
97
- os.system(sed_command)
98
-
99
- # Additional check for Kaggle
100
- if env == 'Kaggle':
101
- get_ipython().system('sed -i \'s/"civitai_interface\\/NSFW content\\/value":.*/"civitai_interface\\/NSFW content\\/value": false/g\' {webui_path}/ui-config.json')
102
- # -------------------------------------------------------
103
 
 
 
104
 
105
  with tunnel:
106
  get_ipython().run_line_magic('cd', '{webui_path}')
@@ -111,19 +104,15 @@ with tunnel:
111
  if env != "Google Colab":
112
  commandline_arguments += f' --encrypt-pass={tunnel_port} --api'
113
 
114
- # -- FORGE --
115
  if change_webui == 'Forge':
116
  commandline_arguments += ' --cuda-stream --pin-shared-memory'
117
 
118
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
119
 
120
-
121
- # after runnig
122
  start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
123
  time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
124
  print(f"\n⌚️ \033[0mВы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m\n\n")
125
 
126
- ''' del zrok tunnel '''
127
  if zrok_token:
128
  get_ipython().system('zrok disable &> /dev/null')
129
 
 
9
  from datetime import timedelta
10
  from IPython.display import clear_output
11
 
 
12
  # ================= DETECT ENV =================
13
  def detect_environment():
14
  free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024 ** 3) <= 20)
 
20
  for env_var, (environment, path) in environments.items():
21
  if env_var in os.environ:
22
  return environment, path, free_plan
23
+ return 'Unknown', '/unknown/path', free_plan
24
 
25
  env, root_path, free_plan = detect_environment()
26
  webui_path = f"{root_path}/sdw"
 
27
 
28
  def load_settings():
29
  SETTINGS_FILE = f'{root_path}/settings.json'
30
  if os.path.exists(SETTINGS_FILE):
31
  with open(SETTINGS_FILE, 'r') as f:
32
+ return json.load(f)
33
+ return {}
34
 
35
  settings = load_settings()
36
+ ngrok_token = settings.get('ngrok_token', "")
37
+ zrok_token = settings.get('zrok_token', "")
38
+ commandline_arguments = settings.get('commandline_arguments', "")
39
+ change_webui = settings.get('change_webui', "")
 
40
 
41
  # ======================== TUNNEL V2 ========================
42
  print('Please Wait...')
 
45
  try:
46
  url = f'https://api64.ipify.org?format=json&{version}=true'
47
  response = requests.get(url)
48
+ return response.json().get('ip', 'N/A')
 
 
49
  except Exception as e:
50
  print(f"Error getting public {version} address:", e)
51
 
52
  # Check if public IP is already saved, if not then get it
53
+ public_ip_file = f"{root_path}/public_ip.txt"
54
+ if os.path.exists(public_ip_file):
55
+ with open(public_ip_file, 'r') as file:
56
  public_ipv4 = file.read().strip()
57
+ else:
58
  public_ipv4 = get_public_ip(version='ipv4')
59
+ with open(public_ip_file, 'w') as file:
60
  file.write(public_ipv4)
61
 
62
  tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-8")
63
+ tunnel_port = 1834
64
  tunnel = tunnel_class(tunnel_port)
65
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
66
  tunnel.add_tunnel(command="lt --port {port}", name="lt", pattern=re.compile(r"[\w-]+\.loca\.lt"), note="Password : " + "\033[32m" + public_ipv4 + "\033[0m" + " rerun cell if 404 error.")
67
 
 
68
  if zrok_token:
69
  get_ipython().system('zrok enable {zrok_token} &> /dev/null')
70
  tunnel.add_tunnel(command="zrok share public http://localhost:{port}/ --headless", name="zrok", pattern=re.compile(r"[\w-]+\.share\.zrok\.io"))
71
 
72
  clear_output()
73
 
 
74
  # =============== Automatic Fixing Path V3 ===============
75
+ paths_to_check = {
76
+ "tagger_hf_cache_dir": f"{webui_path}/models/interrogators/",
77
+ "additional_networks_extra_lora_path": f"{webui_path}/models/Lora/",
78
+ "ad_extra_models_dir": f"{webui_path}/models/adetailer/",
79
+ "sd_checkpoint_hash": "",
80
+ "sd_model_checkpoint": "",
81
+ "sd_vae": "None"
82
+ }
83
 
84
  config_path = f'{webui_path}/ui-config.json'
85
 
86
+ if os.path.exists(config_path):
87
+ with open(config_path, 'r') as file:
88
+ config_data = json.load(file)
89
 
90
+ for key, value in paths_to_check.items():
91
+ if key in config_data and config_data[key] != value:
92
+ sed_command = f"sed -i 's|\"{key}\": \".*\"|\"{key}\": \"{value}\"|' {config_path}"
93
+ os.system(sed_command)
 
 
 
 
 
94
 
95
+ if env == 'Kaggle':
96
+ get_ipython().system('sed -i \'s/"civitai_interface\\/NSFW content\\/value":.*/"civitai_interface\\/NSFW content\\/value": false/g\' {webui_path}/ui-config.json')
97
 
98
  with tunnel:
99
  get_ipython().run_line_magic('cd', '{webui_path}')
 
104
  if env != "Google Colab":
105
  commandline_arguments += f' --encrypt-pass={tunnel_port} --api'
106
 
 
107
  if change_webui == 'Forge':
108
  commandline_arguments += ' --cuda-stream --pin-shared-memory'
109
 
110
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
111
 
 
 
112
  start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
113
  time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
114
  print(f"\n⌚️ \033[0mВы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m\n\n")
115
 
 
116
  if zrok_token:
117
  get_ipython().system('zrok disable &> /dev/null')
118