forked from Sygil-Dev/sygil-webui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelauncher.py
64 lines (44 loc) · 1.77 KB
/
relauncher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os, time
# USER CHANGABLE ARGUMENTS
# Change to `True` if you wish to enable these common arguments
# Run upscaling models on the CPU
extra_models_cpu = False
# Automatically open a new browser window or tab on first launch
open_in_browser = False
# Run Stable Diffusion in Optimized Mode - Only requires 4Gb of VRAM, but is significantly slower
optimized = False
# Run in Optimized Turbo Mode - Needs more VRAM than regular optimized mode, but is faster
optimized_turbo = False
# Creates a public xxxxx.gradio.app share link to allow others to use your interface (requires properly forwarded ports to work correctly)
share = False
# Enter other `--arguments` you wish to use - Must be entered as a `--argument ` syntax
additional_arguments = ""
# BEGIN RELAUNCHER PYTHON CODE
common_arguments = ""
if extra_models_cpu == True:
common_arguments += "--extra-models-cpu "
if optimized_turbo == True:
common_arguments += "--optimized-turbo "
if optimized == True:
common_arguments += "--optimized "
if share == True:
common_arguments += "--share "
if open_in_browser == True:
inbrowser_argument = "--inbrowser "
else:
inbrowser_argument = ""
n = 0
while True:
if n == 0:
print('Relauncher: Launching...')
os.system(f"python scripts/webui.py {common_arguments} {inbrowser_argument} {additional_arguments}")
else:
print(f'\tRelaunch count: {n}')
print('Relauncher: Launching...')
os.system(f"python scripts/webui.py {common_arguments} {additional_arguments}")
n += 1
if n > 100:
print ('Too many relaunch attempts. Aborting...')
break
print('Relauncher: Process is ending. Relaunching in 1s...')
time.sleep(1)