Spaces:
Running
Running
stlaurentjr
commited on
Commit
•
18b6589
1
Parent(s):
80c5943
Update scripts/mainrunpodA1111.py
Browse files- scripts/mainrunpodA1111.py +11 -77
scripts/mainrunpodA1111.py
CHANGED
@@ -22,60 +22,15 @@ import zipfile
|
|
22 |
|
23 |
|
24 |
def Deps(force_reinstall):
|
25 |
-
import os
|
26 |
-
from subprocess import call
|
27 |
-
import venv
|
28 |
-
|
29 |
-
venv_dir = '/workspace/venv'
|
30 |
-
#activate_script = os.path.join(venv_dir, 'bin', 'activate')
|
31 |
|
32 |
if not force_reinstall and os.path.exists('/usr/local/lib/python3.10/dist-packages/safetensors'):
|
33 |
-
# Активация виртуального окружения и обновление pip
|
34 |
-
#call(f'/bin/bash -c "source {activate_script} && pip install --upgrade pip"', shell=True)
|
35 |
-
|
36 |
ntbks()
|
37 |
print('[1;32mModules and notebooks updated, dependencies already installed')
|
38 |
os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
39 |
os.environ['PYTHONWARNINGS'] = 'ignore'
|
40 |
else:
|
41 |
-
# Создание виртуального окружения
|
42 |
-
venv.create(venv_dir, with_pip=True)
|
43 |
-
|
44 |
-
# Запись требований в файл requirements.txt
|
45 |
-
requirements = """
|
46 |
-
fastapi==0.87.0
|
47 |
-
onnxruntime==1.13.1
|
48 |
-
scipy==1.9.3
|
49 |
-
uvicorn==0.20.0
|
50 |
-
rembg==2.0.30
|
51 |
-
future
|
52 |
-
lmdb
|
53 |
-
google-auth<3,>=1.6.3
|
54 |
-
google-auth-oauthlib<0.5,>=0.4.1
|
55 |
-
grpcio>=1.24.3
|
56 |
-
markdown>=2.6.8
|
57 |
-
tensorboard-data-server<0.7.0,>=0.6.0
|
58 |
-
tensorboard-plugin-wit>=1.6.0
|
59 |
-
werkzeug>=1.0.1
|
60 |
-
requests==2.28.1
|
61 |
-
protobuf<4,>=3.20.2
|
62 |
-
gradio==3.41.2
|
63 |
-
gradio-client==0.5.0
|
64 |
-
huggingface-hub>=0.14.0
|
65 |
-
diskcache
|
66 |
-
pillow-avif-plugin
|
67 |
-
tomesd
|
68 |
-
pyre-extensions==0.0.29
|
69 |
-
"""
|
70 |
-
|
71 |
-
#with open("/workspace/requirements.txt", "w") as req_file:
|
72 |
-
# req_file.write(requirements)
|
73 |
-
|
74 |
-
# Активация виртуального окружения и установка зависимостей из файла requirements.txt
|
75 |
-
#call(f'/bin/bash -c "source {activate_script} && pip install -r /workspace/requirements.txt"', shell=True)
|
76 |
-
|
77 |
call('pip install --root-user-action=ignore --disable-pip-version-check --no-deps -qq gdown PyWavelets numpy==1.23.5 accelerate==0.12.0 --force-reinstall', shell=True, stdout=open('/dev/null', 'w'))
|
78 |
-
|
79 |
if os.path.exists('deps'):
|
80 |
call("rm -r deps", shell=True)
|
81 |
if os.path.exists('diffusers'):
|
@@ -84,43 +39,22 @@ def Deps(force_reinstall):
|
|
84 |
if not os.path.exists('cache'):
|
85 |
call('mkdir cache', shell=True)
|
86 |
os.chdir('deps')
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
# Проверка, что файл существует
|
92 |
-
if not os.path.exists("/workspace/deps/dependencies.tar.zst"):
|
93 |
-
raise FileNotFoundError("The file /workspace/deps/dependencies.tar.zst does not exist")
|
94 |
-
|
95 |
-
# Распаковка файла
|
96 |
-
call('tar -C / --zstd -xf /workspace/deps/dependencies.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
|
97 |
-
|
98 |
-
# Проверка наличия файла перед использованием sed
|
99 |
-
hub_py_path = "/usr/local/lib/python3.10/dist-packages/transformers/utils/hub.py"
|
100 |
-
if os.path.exists(hub_py_path):
|
101 |
-
call("sed -i 's@~/.cache@/workspace/cache@' {}".format(hub_py_path), shell=True)
|
102 |
-
else:
|
103 |
-
print(f"Warning: {hub_py_path} does not exist")
|
104 |
-
|
105 |
-
# Остальная часть кода
|
106 |
os.chdir('/workspace')
|
|
|
|
|
107 |
call("git clone --depth 1 -q --branch main https://github.com/TheLastBen/diffusers", shell=True, stdout=open('/dev/null', 'w'))
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
#call(f'/bin/bash -c "source {activate_script} && pip install rembg==2.0.30"', shell=True)
|
112 |
-
|
113 |
-
call(f'pip install --root-user-action=ignore --disable-pip-version-check -qq gradio==3.41.2"', shell=True)
|
114 |
-
call(f'pip install fastapi==0.87.0 onnxruntime==1.13.1 scipy==1.9.3 uvicorn==0.20.0"', shell=True)
|
115 |
-
call(f'pip install rembg==2.0.30"', shell=True)
|
116 |
-
#call("rm -r deps", shell=True)
|
117 |
-
|
118 |
os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
119 |
os.environ['PYTHONWARNINGS'] = 'ignore'
|
120 |
call("sed -i 's@text = _formatwarnmsg(msg)@text =\"\"@g' /usr/lib/python3.10/warnings.py", shell=True)
|
121 |
-
|
122 |
|
123 |
-
|
124 |
|
125 |
|
126 |
|
|
|
22 |
|
23 |
|
24 |
def Deps(force_reinstall):
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
if not force_reinstall and os.path.exists('/usr/local/lib/python3.10/dist-packages/safetensors'):
|
|
|
|
|
|
|
27 |
ntbks()
|
28 |
print('[1;32mModules and notebooks updated, dependencies already installed')
|
29 |
os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
30 |
os.environ['PYTHONWARNINGS'] = 'ignore'
|
31 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
call('pip install --root-user-action=ignore --disable-pip-version-check --no-deps -qq gdown PyWavelets numpy==1.23.5 accelerate==0.12.0 --force-reinstall', shell=True, stdout=open('/dev/null', 'w'))
|
33 |
+
ntbks()
|
34 |
if os.path.exists('deps'):
|
35 |
call("rm -r deps", shell=True)
|
36 |
if os.path.exists('diffusers'):
|
|
|
39 |
if not os.path.exists('cache'):
|
40 |
call('mkdir cache', shell=True)
|
41 |
os.chdir('deps')
|
42 |
+
dwn("https://huggingface.co/spaces/stlaurentjr/RNPD/resolve/main/deps/rnpddeps-t2.tar.zst", "/workspace/deps/rnpddeps-t2.tar.zst", "Installing dependencies")
|
43 |
+
call('tar -C / --zstd -xf rnpddeps-t2.tar.zst', shell=True, stdout=open('/dev/null', 'w'))
|
44 |
+
call("sed -i 's@~/.cache@/workspace/cache@' /usr/local/lib/python3.10/dist-packages/transformers/utils/hub.py", shell=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
os.chdir('/workspace')
|
46 |
+
call("pip install diskcache --root-user-action=ignore --disable-pip-version-check", shell=True, stdout=open('/dev/null', 'w'))
|
47 |
+
call("pip install pillow-avif-plugin --root-user-action=ignore --disable-pip-version-check", shell=True, stdout=open('/dev/null', 'w'))
|
48 |
call("git clone --depth 1 -q --branch main https://github.com/TheLastBen/diffusers", shell=True, stdout=open('/dev/null', 'w'))
|
49 |
+
call('pip install --root-user-action=ignore --disable-pip-version-check -qq gradio==3.41.2', shell=True, stdout=open('/dev/null', 'w'))
|
50 |
+
call("rm -r deps", shell=True)
|
51 |
+
os.chdir('/workspace')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
os.environ['TORCH_HOME'] = '/workspace/cache/torch'
|
53 |
os.environ['PYTHONWARNINGS'] = 'ignore'
|
54 |
call("sed -i 's@text = _formatwarnmsg(msg)@text =\"\"@g' /usr/lib/python3.10/warnings.py", shell=True)
|
55 |
+
clear_output()
|
56 |
|
57 |
+
done()
|
58 |
|
59 |
|
60 |
|