forked from pythoninoffice/amd_webui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_app.py
71 lines (55 loc) · 2.61 KB
/
start_app.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
65
66
67
68
69
70
71
# Made by https://github.com/pythoninoffice
#adjusted by SimolZimol
import importlib.util
import platform
import subprocess
import sys
import pathlib
import time
python = sys.executable
if sys.version[:4] == "3.10":
onnx_nightly = 'ort_nightly_directml-1.16.0.dev20230915012-cp310-cp310-win_amd64.whl'
elif sys.version[:3] == "3.9":
onnx_nightly = 'ort_nightly_directml-1.16.0.dev20230919002-cp39-cp39-win_amd64.whl'
elif sys.version[:3] == "3.8":
onnx_nightly = 'ort_nightly_directml-1.16.0.dev20230919002-cp38-cp38-win_amd64.whl'
elif sys.version[:3] == "3.11":
onnx_nightly = 'ort_nightly_directml-1.16.0.dev20230919002-cp311-cp311-win_amd64.whl'
else:
print('no support python version found, install any of the 3.8, 3.9, 3.10 or 3.11!')
print(f'You are using python version - {sys.version}')
required_lib = ['torch', 'onnxruntime', 'transformers', 'scipy', 'ftfy', 'discord.py']
standard_onnx = 'onnx'
repositories = pathlib.Path().absolute() / 'repositories'
git_repos = ['https://github.com/huggingface/diffusers']
requirements = pathlib.Path().absolute() /'requirements.txt'
def pip_install(lib):
subprocess.run(f'echo Installing {lib}...', shell=True)
subprocess.run(f'echo "{python}" -m pip install {lib}', shell=True)
subprocess.run(f'"{python}" -m pip install {lib}', shell=True, capture_output=True)
subprocess.run(f'"{python}" -m pip install {lib}', shell=True, capture_output=True)
def pip_install_requirements():
subprocess.run(f'echo installing requirements', shell=True)
subprocess.run(f'"{python}" -m pip install -r requirements.txt', shell=True, capture_output=True)
def is_installed(lib):
library = importlib.util.find_spec(lib)
return (library is not None)
def git_clone(repo_url, repo_name):
repo_dir = repositories/repo_name
if not repo_dir.exists():
repo_dir.mkdir(parents=True, exist_ok=True)
subprocess.run(f'echo cloning {repo_dir}', shell=True)
subprocess.run(f'git clone {repo_url} "{repo_dir}"', shell=True)
else:
subprocess.run(f'echo {repo_name} already exists!', shell=True)
#git_clone('https://github.com/huggingface/diffusers','diffusers')
#subprocess.run(rf'echo "{python}" -m pip install -e .\repositories\diffusers', shell=True)
#subprocess.run(rf'"{python}" -m pip install -e .\repositories\diffusers', shell=True, capture_output=True)
#for lib in required_lib:
# if not is_installed(lib):
# pip_install(lib)
pip_install_requirements()
subprocess.run(f'"{python}" -m pip install repositories/{onnx_nightly}', shell=True)
subprocess.run('echo Done installing', shell=True)
import amd_webui
amd_webui.start_app()