forked from miaoshouai/miaoshouai-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
29 lines (23 loc) · 1.17 KB
/
install.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
import launch
import os
import gzip
import io
def install_preset_models_if_needed():
assets_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)), "assets")
configs_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs")
for model_filename in ["civitai_models.json", "liandange_models.json"]:
gzip_file = os.path.join(assets_folder, f"{model_filename}.gz")
target_file = os.path.join(configs_folder, f"{model_filename}")
if not os.path.exists(target_file):
with gzip.open(gzip_file, "rb") as compressed_file:
with io.TextIOWrapper(compressed_file, encoding="utf-8") as decoder:
content = decoder.read()
with open(target_file, "w") as model_file:
model_file.write(content)
req_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")
with open(req_file) as file:
for lib in file:
lib = lib.strip()
if not launch.is_installed(lib):
launch.run_pip(f"install {lib}", f"Miaoshou assistant requirement: {lib}")
install_preset_models_if_needed()