Adityadn commited on
Commit
d215ae6
·
verified ·
1 Parent(s): df169ad

Delete launch.py

Browse files
Files changed (1) hide show
  1. launch.py +0 -127
launch.py DELETED
@@ -1,127 +0,0 @@
1
- import os
2
- import sys
3
- import ssl
4
-
5
- print('[System ARGV] ' + str(sys.argv))
6
-
7
- root = os.path.dirname(os.path.abspath(__file__))
8
- sys.path.append(root)
9
- os.chdir(root)
10
-
11
- os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
12
- os.environ["PYTORCH_MPS_HIGH_WATERMARK_RATIO"] = "0.0"
13
- if "GRADIO_SERVER_PORT" not in os.environ:
14
- os.environ["GRADIO_SERVER_PORT"] = "7865"
15
-
16
- ssl._create_default_https_context = ssl._create_unverified_context
17
-
18
-
19
- import platform
20
- import fooocus_version
21
-
22
- from build_launcher import build_launcher
23
- from modules.launch_util import is_installed, run, python, run_pip, requirements_met
24
- from modules.model_loader import load_file_from_url
25
-
26
-
27
- REINSTALL_ALL = False
28
- TRY_INSTALL_XFORMERS = False
29
-
30
-
31
- def prepare_environment():
32
- torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu121")
33
- torch_command = os.environ.get('TORCH_COMMAND',
34
- f"pip install torch==2.1.0 torchvision==0.16.0 --extra-index-url {torch_index_url}")
35
- requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
36
-
37
- print(f"Python {sys.version}")
38
- print(f"Fooocus version: {fooocus_version.version}")
39
-
40
- if REINSTALL_ALL or not is_installed("torch") or not is_installed("torchvision"):
41
- run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
42
-
43
- if TRY_INSTALL_XFORMERS:
44
- if REINSTALL_ALL or not is_installed("xformers"):
45
- xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.23')
46
- if platform.system() == "Windows":
47
- if platform.python_version().startswith("3.10"):
48
- run_pip(f"install -U -I --no-deps {xformers_package}", "xformers", live=True)
49
- else:
50
- print("Installation of xformers is not supported in this version of Python.")
51
- print(
52
- "You can also check this and build manually: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Xformers#building-xformers-on-windows-by-duckness")
53
- if not is_installed("xformers"):
54
- exit(0)
55
- elif platform.system() == "Linux":
56
- run_pip(f"install -U -I --no-deps {xformers_package}", "xformers")
57
-
58
- if REINSTALL_ALL or not requirements_met(requirements_file):
59
- run_pip(f"install -r \"{requirements_file}\"", "requirements")
60
-
61
- return
62
-
63
-
64
- vae_approx_filenames = [
65
- ('xlvaeapp.pth', 'https://huggingface.co/lllyasviel/misc/resolve/main/xlvaeapp.pth'),
66
- ('vaeapp_sd15.pth', 'https://huggingface.co/lllyasviel/misc/resolve/main/vaeapp_sd15.pt'),
67
- ('xl-to-v1_interposer-v3.1.safetensors',
68
- 'https://huggingface.co/lllyasviel/misc/resolve/main/xl-to-v1_interposer-v3.1.safetensors')
69
- ]
70
-
71
- def ini_args():
72
- from args_manager import args
73
- return args
74
-
75
-
76
- prepare_environment()
77
- build_launcher()
78
- args = ini_args()
79
-
80
-
81
- if args.gpu_device_id is not None:
82
- os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpu_device_id)
83
- print("Set device to:", args.gpu_device_id)
84
-
85
-
86
- from modules import config
87
-
88
- def download_models():
89
- for file_name, url in vae_approx_filenames:
90
- load_file_from_url(url=url, model_dir=config.path_vae_approx, file_name=file_name)
91
-
92
- load_file_from_url(
93
- url='https://huggingface.co/lllyasviel/misc/resolve/main/fooocus_expansion.bin',
94
- model_dir=config.path_fooocus_expansion,
95
- file_name='pytorch_model.bin'
96
- )
97
-
98
- if args.disable_preset_download:
99
- print('Skipped model download.')
100
- return
101
-
102
- if not args.always_download_new_model:
103
- if not os.path.exists(os.path.join(config.paths_checkpoints[0], config.default_base_model_name)):
104
- for alternative_model_name in config.previous_default_models:
105
- if os.path.exists(os.path.join(config.paths_checkpoints[0], alternative_model_name)):
106
- print(f'You do not have [{config.default_base_model_name}] but you have [{alternative_model_name}].')
107
- print(f'Fooocus will use [{alternative_model_name}] to avoid downloading new models, '
108
- f'but you are not using latest models.')
109
- print('Use --always-download-new-model to avoid fallback and always get new models.')
110
- config.checkpoint_downloads = {}
111
- config.default_base_model_name = alternative_model_name
112
- break
113
-
114
- for file_name, url in config.checkpoint_downloads.items():
115
- load_file_from_url(url=url, model_dir=config.paths_checkpoints[0], file_name=file_name)
116
- for file_name, url in config.embeddings_downloads.items():
117
- load_file_from_url(url=url, model_dir=config.path_embeddings, file_name=file_name)
118
- for file_name, url in config.lora_downloads.items():
119
- load_file_from_url(url=url, model_dir=config.paths_loras[0], file_name=file_name)
120
-
121
- return
122
-
123
-
124
- download_models()
125
-
126
-
127
- from webui import *