|
|
|
|
| import os
|
| import re
|
| import time
|
| import json
|
| import requests
|
| from datetime import timedelta
|
|
|
|
|
| root_path = "/home/studio-lab-user/content"
|
| webui_path = f"{root_path}/sdw"
|
|
|
|
|
| def load_settings():
|
| SETTINGS_FILE = f'{root_path}/settings.json'
|
| if os.path.exists(SETTINGS_FILE):
|
| with open(SETTINGS_FILE, 'r') as f:
|
| settings = json.load(f)
|
| return settings
|
|
|
| settings = load_settings()
|
| ngrok_token = settings['ngrok_token']
|
| zrok_token = settings['zrok_token']
|
| commandline_arguments = settings['commandline_arguments']
|
|
|
|
|
|
|
| get_ipython().system('sed -i \'s#"tagger_hf_cache_dir": ".*models/interrogators"#"tagger_hf_cache_dir": "{root_path}/sdw/models/interrogators"#\' {webui_path}/config.json')
|
| get_ipython().system('sed -i \'s#"additional_networks_extra_lora_path": ".*models/Lora/"#"additional_networks_extra_lora_path": "{root_path}/sdw/models/Lora/"#\' {webui_path}/config.json')
|
|
|
| get_ipython().system('sed -i \'s/"sd_vae":.*/"sd_vae": "None",/; s/"sd_model_checkpoint":.*/"sd_model_checkpoint": "None",/; s/"sd_checkpoint_hash":.*/"sd_checkpoint_hash": "None",/\' {webui_path}/config.json')
|
|
|
|
|
| get_ipython().run_line_magic('cd', '{webui_path}')
|
| commandline_arguments += f" --port=1769"
|
|
|
| if ngrok_token or zrok_token:
|
| if ngrok_token:
|
| commandline_arguments += ' --ngrok ' + ngrok_token
|
|
|
| if zrok_token:
|
| get_ipython().system(f'python ~/content/special/zrok3.py {zrok_token} {commandline_arguments}')
|
|
|
| else:
|
| get_ipython().system(f'COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
|
|
|
| start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
| time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
| print(f"\n⌚️ \033[0mВы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m\n\n")
|
|
|
| else:
|
| print("Not found tokens: Zrok/Ngrok") |