Spaces:
Runtime error
Runtime error
Commit
·
e8417f2
1
Parent(s):
aae0d40
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,112 +1,14 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
cmd.append("--pre")
|
| 16 |
-
|
| 17 |
-
# add '-q' if not verbose
|
| 18 |
-
if not verbose:
|
| 19 |
-
cmd.append("-q")
|
| 20 |
-
|
| 21 |
-
# add package name
|
| 22 |
-
cmd.append(package)
|
| 23 |
-
|
| 24 |
-
# add extra_index_url if it exists
|
| 25 |
-
if extra_index_url:
|
| 26 |
-
cmd.extend(["--extra-index-url", extra_index_url])
|
| 27 |
-
|
| 28 |
-
if verbose:
|
| 29 |
-
print(cmd)
|
| 30 |
-
|
| 31 |
-
# run the command and capture output
|
| 32 |
-
result = subprocess.run(cmd, capture_output=not verbose, text=True)
|
| 33 |
-
|
| 34 |
-
if verbose:
|
| 35 |
-
# print stdout and stderr if verbose
|
| 36 |
-
print(result.stdout)
|
| 37 |
-
print(result.stderr)
|
| 38 |
-
|
| 39 |
-
except Exception as e:
|
| 40 |
-
print(f"failed to install {package}: {e}")
|
| 41 |
-
return
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
def install_requirements(verbose=False):
|
| 45 |
-
|
| 46 |
-
# Detect System
|
| 47 |
-
os_system = platform.system()
|
| 48 |
-
print(f"system detected: {os_system}")
|
| 49 |
-
|
| 50 |
-
# Install pytorch
|
| 51 |
-
torch = [
|
| 52 |
-
"torch",
|
| 53 |
-
"torchvision",
|
| 54 |
-
"torchaudio"
|
| 55 |
-
]
|
| 56 |
-
extra_index_url = "https://download.pytorch.org/whl/nightly/cu121"
|
| 57 |
-
pip_install_packages(torch, extra_index_url=extra_index_url, verbose=verbose, pre=True)
|
| 58 |
-
|
| 59 |
-
# List of common packages to install
|
| 60 |
-
common = [
|
| 61 |
-
"clean-fid",
|
| 62 |
-
"colab-convert",
|
| 63 |
-
"einops",
|
| 64 |
-
"ftfy",
|
| 65 |
-
"ipython",
|
| 66 |
-
"ipywidgets",
|
| 67 |
-
"jsonmerge",
|
| 68 |
-
"jupyterlab",
|
| 69 |
-
"jupyter_http_over_ws",
|
| 70 |
-
"kornia",
|
| 71 |
-
"matplotlib",
|
| 72 |
-
"notebook",
|
| 73 |
-
"numexpr",
|
| 74 |
-
"omegaconf",
|
| 75 |
-
"opencv-python",
|
| 76 |
-
"pandas",
|
| 77 |
-
"pytorch_lightning==1.7.7",
|
| 78 |
-
"resize-right",
|
| 79 |
-
"scikit-image==0.19.3",
|
| 80 |
-
"scikit-learn",
|
| 81 |
-
"timm",
|
| 82 |
-
"torchdiffeq",
|
| 83 |
-
"transformers==4.19.2",
|
| 84 |
-
"safetensors",
|
| 85 |
-
"albumentations",
|
| 86 |
-
"more_itertools",
|
| 87 |
-
"devtools",
|
| 88 |
-
"validators",
|
| 89 |
-
"numpngw",
|
| 90 |
-
"open-clip-torch",
|
| 91 |
-
"torchsde",
|
| 92 |
-
"ninja",
|
| 93 |
-
"pydantic",
|
| 94 |
-
]
|
| 95 |
-
pip_install_packages(common)
|
| 96 |
-
|
| 97 |
-
# Xformers install
|
| 98 |
-
linux_xformers = [
|
| 99 |
-
"triton",
|
| 100 |
-
"xformers==0.0.21.dev546",
|
| 101 |
-
]
|
| 102 |
-
windows_xformers = [
|
| 103 |
-
"xformers==0.0.21.dev546",
|
| 104 |
-
]
|
| 105 |
-
xformers = windows_xformers if os_system == 'Windows' else linux_xformers
|
| 106 |
-
pip_install_packages(xformers)
|
| 107 |
-
|
| 108 |
-
if __name__ == "__main__":
|
| 109 |
-
parser = argparse.ArgumentParser()
|
| 110 |
-
parser.add_argument('--verbose', action='store_true', help='print pip install stuff')
|
| 111 |
-
args = parser.parse_args()
|
| 112 |
-
install_requirements(verbose=args.verbose)
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.chdir(f"/home/users/app")
|
| 3 |
+
os.system(f"apt -y update -qq")
|
| 4 |
+
os.system(f"wget https://github.com/camenduru/gperftools/releases/download/v1.0/libtcmalloc_minimal.so.4 -O /home/users/app/libtcmalloc_minimal.so.4")
|
| 5 |
+
os.system(f"env LD_PRELOAD=/content/libtcmalloc_minimal.so.4")
|
| 6 |
+
os.system(f"apt -y install -qq aria2")
|
| 7 |
+
os.system(f"pip install -q xformers==0.0.20 triton==2.0.0 -U")
|
| 8 |
+
os.system(f"git clone -b v2.6 https://dagshub.com/camenduru/ui")
|
| 9 |
+
os.system(f"git clone https://github.com/camenduru/control /home/users/app/ui/extensions/control")
|
| 10 |
+
os.system(f"cd /home/users/app/ui")
|
| 11 |
+
os.system(f"git reset --hard")
|
| 12 |
+
os.system(f"git -C /content/ui/repositories/stable-diffusion-stability-ai reset --hard")
|
| 13 |
+
os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/sd_xl_base_1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensors -d /home/users/app/ui/models/Stable-diffusion -o sd_xl_base_1.0.safetensors")
|
| 14 |
+
os.system(f"python launch.py --listen --xformers --enable-insecure-extension-access --theme dark --gradio-queue --multiple")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|