viyi commited on
Commit
c8224b6
·
verified ·
1 Parent(s): cb9215c

Upload sdwui-start-util.dev.ipynb

Browse files
Files changed (1) hide show
  1. sdwui-start-util.dev.ipynb +39 -10
sdwui-start-util.dev.ipynb CHANGED
@@ -115,6 +115,7 @@
115
  " \n",
116
  "show_shell_info = locals().get('hidden_console_info') or globals().get('hidden_console_info')\n",
117
  "if show_shell_info is None: show_shell_info = False\n",
 
118
  "\n",
119
  "_multi_case = locals().get('multi_case') or globals().get('multi_case') or False\n",
120
  " \n",
@@ -284,8 +285,6 @@
284
  "os.environ['google_drive'] = google_drive\n",
285
  "os.environ['input_path'] = _input_path\n",
286
  "\n",
287
- "space_string = ' \\n\\r\\t\\'\\\",'\n",
288
- "\n",
289
  "def replace_path(input_str:str):\n",
290
  " if not input_str: return ''\n",
291
  " for key in _config_args:\n",
@@ -301,9 +300,9 @@
301
  " .replace('$output_path',_output_path)\\\n",
302
  " .replace('{output_path}',_output_path)\\\n",
303
  " .replace('{sdwui}','stable-diffusion-webui')\\\n",
304
- " .replace('{wui}',\"webui\")\\\n",
305
- " .strip()\n",
306
  "\n",
 
307
  "\n",
308
  "def config_reader(conf:str):\n",
309
  " conf = conf or \"\"\n",
@@ -501,7 +500,7 @@
501
  " if 'frp_ssl_dir' in locals() or 'frp_ssl_dir' in globals():\n",
502
  " frpcSSLFFlies = frpcSSLFFlies + config_reader(locals().get('frp_ssl_dir') or globals().get('frp_ssl_dir'))\n",
503
  " # frpc 文件目录 如果目录不存在,会自动下载,也可以在数据集搜索 viyiviyi/utils 添加\n",
504
- " frpcExePath = os.path.join(_input_path,'utils-tools/frpc_v0.51.0')\n",
505
  " # 其他需要加载的webui启动参数 写到【参数列表】这个配置去\n",
506
  " otherArgs = '--xformers'\n",
507
  " if 'sd_start_args' in locals() or 'sd_start_args' in globals():\n",
@@ -1097,8 +1096,9 @@
1097
  " folder_list = [] \n",
1098
  " for item in os.listdir(directory): \n",
1099
  " if os.path.isdir(os.path.join(directory, item)): \n",
1100
- " folder_list.append(item) \n",
1101
- " return folder_list \n",
 
1102
  "def read_text_file(file_path:str):\n",
1103
  " if not Path(file_path).exists(): return ''\n",
1104
  " with open(file_path,\"r\") as f:\n",
@@ -1346,7 +1346,7 @@
1346
  "outputs": [],
1347
  "source": [
1348
  "envInstalled=False\n",
1349
- "quickStart = True\n",
1350
  "#安装\n",
1351
  "def install():\n",
1352
  " print('安装')\n",
@@ -1428,7 +1428,28 @@
1428
  "\n",
1429
  " get_ipython().system(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -V''')\n",
1430
  " get_ipython().system(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -m pip -V''')\n",
1431
- "\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1432
  " envInstalled = True\n",
1433
  " print('安装需要的python环境 完成')\n",
1434
  " \n",
@@ -1474,13 +1495,20 @@
1474
  " if i>0:\n",
1475
  " print(f'使用第{i+1}张显卡启动第{i+1}个服务,通过frpc或nrgok地址后加{_sub_path[i]}进行访问')\n",
1476
  "\n",
 
 
 
1477
  " restart_times = 0\n",
1478
  " last_restart_time = time.time()\n",
1479
  " while _runing:\n",
1480
  " os.chdir(f'{_install_path}/{_ui_dir_name}')\n",
1481
  " root_path = _sub_path[i]\n",
1482
  " if root_path.endswith('/'): root_path = root_path[:-1]\n",
1483
- " get_ipython().system(f'''venv/bin/python3 launch.py --device-id={i} --port {str(_server_port+1+i)} --subpath={_sub_path[i]}''')\n",
 
 
 
 
1484
  " print('10秒后重启服务')\n",
1485
  " if time.time() - last_restart_time < 60:\n",
1486
  " restart_times = restart_times + 1\n",
@@ -1554,6 +1582,7 @@
1554
  " proxy_thread.start()\n",
1555
  " if isInstall is False or _reLoad: \n",
1556
  " print('安装运行环境')\n",
 
1557
  " install()\n",
1558
  " link_dir()\n",
1559
  " init_huggingface()\n",
 
115
  " \n",
116
  "show_shell_info = locals().get('hidden_console_info') or globals().get('hidden_console_info')\n",
117
  "if show_shell_info is None: show_shell_info = False\n",
118
+ "else: show_shell_info = not show_shell_info\n",
119
  "\n",
120
  "_multi_case = locals().get('multi_case') or globals().get('multi_case') or False\n",
121
  " \n",
 
285
  "os.environ['google_drive'] = google_drive\n",
286
  "os.environ['input_path'] = _input_path\n",
287
  "\n",
 
 
288
  "def replace_path(input_str:str):\n",
289
  " if not input_str: return ''\n",
290
  " for key in _config_args:\n",
 
300
  " .replace('$output_path',_output_path)\\\n",
301
  " .replace('{output_path}',_output_path)\\\n",
302
  " .replace('{sdwui}','stable-diffusion-webui')\\\n",
303
+ " .replace('{wui}',\"webui\")\n",
 
304
  "\n",
305
+ "space_string = ' \\n\\r\\t\\'\\\",'\n",
306
  "\n",
307
  "def config_reader(conf:str):\n",
308
  " conf = conf or \"\"\n",
 
500
  " if 'frp_ssl_dir' in locals() or 'frp_ssl_dir' in globals():\n",
501
  " frpcSSLFFlies = frpcSSLFFlies + config_reader(locals().get('frp_ssl_dir') or globals().get('frp_ssl_dir'))\n",
502
  " # frpc 文件目录 如果目录不存在,会自动下载,也可以在数据集搜索 viyiviyi/utils 添加\n",
503
+ " frpcExePath = os.path.join(_input_path,'utils-tools/frpc')\n",
504
  " # 其他需要加载的webui启动参数 写到【参数列表】这个配置去\n",
505
  " otherArgs = '--xformers'\n",
506
  " if 'sd_start_args' in locals() or 'sd_start_args' in globals():\n",
 
1096
  " folder_list = [] \n",
1097
  " for item in os.listdir(directory): \n",
1098
  " if os.path.isdir(os.path.join(directory, item)): \n",
1099
+ " folder_list.append(item) \n",
1100
+ " return folder_list\n",
1101
+ "\n",
1102
  "def read_text_file(file_path:str):\n",
1103
  " if not Path(file_path).exists(): return ''\n",
1104
  " with open(file_path,\"r\") as f:\n",
 
1346
  "outputs": [],
1347
  "source": [
1348
  "envInstalled=False\n",
1349
+ "quickStart = False\n",
1350
  "#安装\n",
1351
  "def install():\n",
1352
  " print('安装')\n",
 
1428
  "\n",
1429
  " get_ipython().system(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -V''')\n",
1430
  " get_ipython().system(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -m pip -V''')\n",
1431
+ " \n",
1432
+ " if not quickStart:\n",
1433
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -V''')\n",
1434
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -m pip -V''')\n",
1435
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python -m pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121''')\n",
1436
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python -m pip install xformers==0.0.27''')\n",
1437
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python -m pip install -r requirements_versions.txt''')\n",
1438
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python -m pip install spandrel==0.3.0''')\n",
1439
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python -m pip install opencv-python''')\n",
1440
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python -m pip install pydantic==1.10.15''')\n",
1441
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python -m pip install transformers -U''')\n",
1442
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python -m pip install llama-cpp-python''')\n",
1443
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python -m pip install pytorch_lightning==2.3.3 torchsde==0.2.6 spandrel==0.3.4''')\n",
1444
+ " \n",
1445
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -m pip install open-clip-torch -U''')\n",
1446
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -m pip install protobuf==4.25.8''')\n",
1447
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -m pip install blendmodes==2022''')\n",
1448
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -m pip install Pillow==9.5.0''')\n",
1449
+ " run(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -m pip install basicsr''')\n",
1450
+ " \n",
1451
+ " get_ipython().system(f'''{_install_path}/{_ui_dir_name}/venv/bin/python3 -m pip install basicsr''')\n",
1452
+ " \n",
1453
  " envInstalled = True\n",
1454
  " print('安装需要的python环境 完成')\n",
1455
  " \n",
 
1495
  " if i>0:\n",
1496
  " print(f'使用第{i+1}张显卡启动第{i+1}个服务,通过frpc或nrgok地址后加{_sub_path[i]}进行访问')\n",
1497
  "\n",
1498
+ " current_thread = threading.current_thread()\n",
1499
+ " current_thread.name = f\"solo_webui__{i}\"\n",
1500
+ " \n",
1501
  " restart_times = 0\n",
1502
  " last_restart_time = time.time()\n",
1503
  " while _runing:\n",
1504
  " os.chdir(f'{_install_path}/{_ui_dir_name}')\n",
1505
  " root_path = _sub_path[i]\n",
1506
  " if root_path.endswith('/'): root_path = root_path[:-1]\n",
1507
+ " if torch.cuda.device_count() == 2 and not _multi_case:\n",
1508
+ " os.environ['CUDA_VISIBLE_DEVICES']='0,1'\n",
1509
+ " get_ipython().system(f'''venv/bin/python3 launch.py --port {str(_server_port+1+i)} --subpath={_sub_path[i]}''')\n",
1510
+ " else: \n",
1511
+ " get_ipython().system(f'''venv/bin/python3 launch.py --device-id={i} --port {str(_server_port+1+i)} --subpath={_sub_path[i]}''')\n",
1512
  " print('10秒后重启服务')\n",
1513
  " if time.time() - last_restart_time < 60:\n",
1514
  " restart_times = restart_times + 1\n",
 
1582
  " proxy_thread.start()\n",
1583
  " if isInstall is False or _reLoad: \n",
1584
  " print('安装运行环境')\n",
1585
+ " os.environ['MPLBACKEND'] = 'Agg'\n",
1586
  " install()\n",
1587
  " link_dir()\n",
1588
  " init_huggingface()\n",