NagisaNao commited on
Commit
afae1b4
·
verified ·
1 Parent(s): 950e7a7

👀

Browse files
files_cells/notebooks/en/downloading_en.ipynb CHANGED
@@ -506,8 +506,8 @@
506
  "\n",
507
  " return unique_models\n",
508
  "\n",
509
- "submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
510
- "submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
511
  "submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet\n",
512
  "\n",
513
  "for submodel in submodels:\n",
 
506
  "\n",
507
  " return unique_models\n",
508
  "\n",
509
+ "submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
510
+ "submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
511
  "submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet\n",
512
  "\n",
513
  "for submodel in submodels:\n",
files_cells/notebooks/en/launch_en.ipynb CHANGED
@@ -64,7 +64,7 @@
64
  "change_webui = settings['change_webui']\n",
65
  "\n",
66
  "\n",
67
- "# ======================== TUNNEL ========================\n",
68
  "print('Please Wait...')\n",
69
  "\n",
70
  "def get_public_ip(version='ipv4'):\n",
@@ -77,10 +77,17 @@
77
  " except Exception as e:\n",
78
  " print(f\"Error getting public {version} address:\", e)\n",
79
  "\n",
80
- "public_ipv4 = get_public_ip(version='ipv4')\n",
 
 
 
 
 
 
 
81
  "\n",
82
  "tunnel_class = pickle.load(open(f\"{root_path}/new_tunnel\", \"rb\"), encoding=\"utf-8\")\n",
83
- "tunnel_port= 1734\n",
84
  "tunnel = tunnel_class(tunnel_port)\n",
85
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
86
  "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,17 +98,32 @@
91
  " tunnel.add_tunnel(command=\"zrok share public http://localhost:{port}/ --headless\", name=\"zrok\", pattern=re.compile(r\"[\\w-]+\\.share\\.zrok\\.io\"))\n",
92
  "\n",
93
  "clear_output()\n",
94
- "# ======================== TUNNEL ========================\n",
95
  "\n",
96
  "\n",
97
- " # automatic fixing path V2\n",
98
- "!sed -i 's|\"tagger_hf_cache_dir\": \".*\"|\"tagger_hf_cache_dir\": \"{webui_path}/models/interrogators/\"|' {webui_path}/config.json\n",
99
- "!sed -i 's|\"additional_networks_extra_lora_path\": \".*\"|\"additional_networks_extra_lora_path\": \"{webui_path}/models/Lora/\"|' {webui_path}/config.json\n",
100
- "!sed -i 's|\"ad_extra_models_dir\": \".*\"|\"ad_extra_models_dir\": \"{webui_path}/models/adetailer/\"|' {webui_path}/config.json\n",
101
- "!sed -i 's/\"sd_checkpoint_hash\": \".*\"/\"sd_checkpoint_hash\": \"\"/g; s/\"sd_model_checkpoint\": \".*\"/\"sd_model_checkpoint\": \"\"/g; s/\"sd_vae\": \".*\"/\"sd_vae\": \"None\"/g' {webui_path}/config.json\n",
102
- "# for kaggle\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  "if env == 'Kaggle':\n",
104
- " !sed -i 's/\"civitai_interface\\/NSFW content\\/value\":.*/\"civitai_interface\\/NSFW content\\/value\": false/g' {webui_path}/ui-config.json\n",
 
105
  "\n",
106
  "\n",
107
  "with tunnel:\n",
 
64
  "change_webui = settings['change_webui']\n",
65
  "\n",
66
  "\n",
67
+ "# ======================== TUNNEL V2 ========================\n",
68
  "print('Please Wait...')\n",
69
  "\n",
70
  "def get_public_ip(version='ipv4'):\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",
 
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",
files_cells/notebooks/ru/downloading_ru.ipynb CHANGED
@@ -506,8 +506,8 @@
506
  "\n",
507
  " return unique_models\n",
508
  "\n",
509
- "submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
510
- "submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
511
  "submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet\n",
512
  "\n",
513
  "for submodel in submodels:\n",
 
506
  "\n",
507
  " return unique_models\n",
508
  "\n",
509
+ "submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
510
+ "submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
511
  "submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet\n",
512
  "\n",
513
  "for submodel in submodels:\n",
files_cells/notebooks/ru/launch_ru.ipynb CHANGED
@@ -64,7 +64,7 @@
64
  "change_webui = settings['change_webui']\n",
65
  "\n",
66
  "\n",
67
- "# ======================== TUNNEL ========================\n",
68
  "print('Please Wait...')\n",
69
  "\n",
70
  "def get_public_ip(version='ipv4'):\n",
@@ -77,10 +77,17 @@
77
  " except Exception as e:\n",
78
  " print(f\"Error getting public {version} address:\", e)\n",
79
  "\n",
80
- "public_ipv4 = get_public_ip(version='ipv4')\n",
 
 
 
 
 
 
 
81
  "\n",
82
  "tunnel_class = pickle.load(open(f\"{root_path}/new_tunnel\", \"rb\"), encoding=\"utf-8\")\n",
83
- "tunnel_port= 1734\n",
84
  "tunnel = tunnel_class(tunnel_port)\n",
85
  "tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
86
  "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,17 +98,32 @@
91
  " tunnel.add_tunnel(command=\"zrok share public http://localhost:{port}/ --headless\", name=\"zrok\", pattern=re.compile(r\"[\\w-]+\\.share\\.zrok\\.io\"))\n",
92
  "\n",
93
  "clear_output()\n",
94
- "# ======================== TUNNEL ========================\n",
95
  "\n",
96
  "\n",
97
- "# automatic fixing path V2\n",
98
- "!sed -i 's|\"tagger_hf_cache_dir\": \".*\"|\"tagger_hf_cache_dir\": \"{webui_path}/models/interrogators/\"|' {webui_path}/config.json\n",
99
- "!sed -i 's|\"additional_networks_extra_lora_path\": \".*\"|\"additional_networks_extra_lora_path\": \"{webui_path}/models/Lora/\"|' {webui_path}/config.json\n",
100
- "!sed -i 's|\"ad_extra_models_dir\": \".*\"|\"ad_extra_models_dir\": \"{webui_path}/models/adetailer/\"|' {webui_path}/config.json\n",
101
- "!sed -i 's/\"sd_checkpoint_hash\": \".*\"/\"sd_checkpoint_hash\": \"\"/g; s/\"sd_model_checkpoint\": \".*\"/\"sd_model_checkpoint\": \"\"/g; s/\"sd_vae\": \".*\"/\"sd_vae\": \"None\"/g' {webui_path}/config.json\n",
102
- "# for kaggle\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  "if env == 'Kaggle':\n",
104
- " !sed -i 's/\"civitai_interface\\/NSFW content\\/value\":.*/\"civitai_interface\\/NSFW content\\/value\": false/g' {webui_path}/ui-config.json\n",
 
105
  "\n",
106
  "\n",
107
  "with tunnel:\n",
 
64
  "change_webui = settings['change_webui']\n",
65
  "\n",
66
  "\n",
67
+ "# ======================== TUNNEL V2 ========================\n",
68
  "print('Please Wait...')\n",
69
  "\n",
70
  "def get_public_ip(version='ipv4'):\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",
 
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",
files_cells/python/en/downloading_en.py CHANGED
@@ -496,8 +496,8 @@ def add_submodels(selection, num_selection, model_dict, dst_dir):
496
 
497
  return unique_models
498
 
499
- submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
500
- submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
501
  submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet
502
 
503
  for submodel in submodels:
 
496
 
497
  return unique_models
498
 
499
+ submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
500
+ submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
501
  submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet
502
 
503
  for submodel in submodels:
files_cells/python/en/launch_en.py CHANGED
@@ -40,7 +40,7 @@ commandline_arguments = settings['commandline_arguments']
40
  change_webui = settings['change_webui']
41
 
42
 
43
- # ======================== TUNNEL ========================
44
  print('Please Wait...')
45
 
46
  def get_public_ip(version='ipv4'):
@@ -53,10 +53,17 @@ def get_public_ip(version='ipv4'):
53
  except Exception as e:
54
  print(f"Error getting public {version} address:", e)
55
 
56
- public_ipv4 = get_public_ip(version='ipv4')
 
 
 
 
 
 
 
57
 
58
  tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-8")
59
- tunnel_port= 1734
60
  tunnel = tunnel_class(tunnel_port)
61
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
62
  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,17 +74,32 @@ if zrok_token:
67
  tunnel.add_tunnel(command="zrok share public http://localhost:{port}/ --headless", name="zrok", pattern=re.compile(r"[\w-]+\.share\.zrok\.io"))
68
 
69
  clear_output()
70
- # ======================== TUNNEL ========================
71
 
72
 
73
- # automatic fixing path V2
74
- get_ipython().system('sed -i \'s|"tagger_hf_cache_dir": ".*"|"tagger_hf_cache_dir": "{webui_path}/models/interrogators/"|\' {webui_path}/config.json')
75
- get_ipython().system('sed -i \'s|"additional_networks_extra_lora_path": ".*"|"additional_networks_extra_lora_path": "{webui_path}/models/Lora/"|\' {webui_path}/config.json')
76
- get_ipython().system('sed -i \'s|"ad_extra_models_dir": ".*"|"ad_extra_models_dir": "{webui_path}/models/adetailer/"|\' {webui_path}/config.json')
77
- get_ipython().system('sed -i \'s/"sd_checkpoint_hash": ".*"/"sd_checkpoint_hash": ""/g; s/"sd_model_checkpoint": ".*"/"sd_model_checkpoint": ""/g; s/"sd_vae": ".*"/"sd_vae": "None"/g\' {webui_path}/config.json')
78
- # for kaggle
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  if env == 'Kaggle':
80
  get_ipython().system('sed -i \'s/"civitai_interface\\/NSFW content\\/value":.*/"civitai_interface\\/NSFW content\\/value": false/g\' {webui_path}/ui-config.json')
 
81
 
82
 
83
  with tunnel:
 
40
  change_webui = settings['change_webui']
41
 
42
 
43
+ # ======================== TUNNEL V2 ========================
44
  print('Please Wait...')
45
 
46
  def get_public_ip(version='ipv4'):
 
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.")
 
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:
files_cells/python/ru/downloading_ru.py CHANGED
@@ -496,8 +496,8 @@ def add_submodels(selection, num_selection, model_dict, dst_dir):
496
 
497
  return unique_models
498
 
499
- submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
500
- submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
501
  submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet
502
 
503
  for submodel in submodels:
 
496
 
497
  return unique_models
498
 
499
+ submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
500
+ submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
501
  submodels += add_submodels(controlnet, controlnet_Num, controlnet_list, control_dir) # controlnet
502
 
503
  for submodel in submodels:
files_cells/python/ru/launch_ru.py CHANGED
@@ -40,7 +40,7 @@ commandline_arguments = settings['commandline_arguments']
40
  change_webui = settings['change_webui']
41
 
42
 
43
- # ======================== TUNNEL ========================
44
  print('Please Wait...')
45
 
46
  def get_public_ip(version='ipv4'):
@@ -53,10 +53,17 @@ def get_public_ip(version='ipv4'):
53
  except Exception as e:
54
  print(f"Error getting public {version} address:", e)
55
 
56
- public_ipv4 = get_public_ip(version='ipv4')
 
 
 
 
 
 
 
57
 
58
  tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-8")
59
- tunnel_port= 1734
60
  tunnel = tunnel_class(tunnel_port)
61
  tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
62
  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,17 +74,32 @@ if zrok_token:
67
  tunnel.add_tunnel(command="zrok share public http://localhost:{port}/ --headless", name="zrok", pattern=re.compile(r"[\w-]+\.share\.zrok\.io"))
68
 
69
  clear_output()
70
- # ======================== TUNNEL ========================
71
 
72
 
73
- # automatic fixing path V2
74
- get_ipython().system('sed -i \'s|"tagger_hf_cache_dir": ".*"|"tagger_hf_cache_dir": "{webui_path}/models/interrogators/"|\' {webui_path}/config.json')
75
- get_ipython().system('sed -i \'s|"additional_networks_extra_lora_path": ".*"|"additional_networks_extra_lora_path": "{webui_path}/models/Lora/"|\' {webui_path}/config.json')
76
- get_ipython().system('sed -i \'s|"ad_extra_models_dir": ".*"|"ad_extra_models_dir": "{webui_path}/models/adetailer/"|\' {webui_path}/config.json')
77
- get_ipython().system('sed -i \'s/"sd_checkpoint_hash": ".*"/"sd_checkpoint_hash": ""/g; s/"sd_model_checkpoint": ".*"/"sd_model_checkpoint": ""/g; s/"sd_vae": ".*"/"sd_vae": "None"/g\' {webui_path}/config.json')
78
- # for kaggle
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  if env == 'Kaggle':
80
  get_ipython().system('sed -i \'s/"civitai_interface\\/NSFW content\\/value":.*/"civitai_interface\\/NSFW content\\/value": false/g\' {webui_path}/ui-config.json')
 
81
 
82
 
83
  with tunnel:
 
40
  change_webui = settings['change_webui']
41
 
42
 
43
+ # ======================== TUNNEL V2 ========================
44
  print('Please Wait...')
45
 
46
  def get_public_ip(version='ipv4'):
 
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.")
 
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: