Spaces:
Running
Running
Commit
·
dd64fe9
1
Parent(s):
345ac3b
Create ui.py
Browse files
ui.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import modal, os, sys, shlex
|
2 |
+
|
3 |
+
stub = modal.Stub("stable-diffusion-webui")
|
4 |
+
volume = modal.NetworkFileSystem.new().persisted("stable-diffusion-webui")
|
5 |
+
|
6 |
+
@stub.function(
|
7 |
+
modal.Image.from_registry("nvidia/cuda:12.2.0-base-ubuntu22.04", add_python="3.11")
|
8 |
+
.run_commands(
|
9 |
+
"apt update -y && \
|
10 |
+
apt install -y software-properties-common && \
|
11 |
+
apt update -y && \
|
12 |
+
add-apt-repository -y ppa:git-core/ppa && \
|
13 |
+
apt update -y && \
|
14 |
+
apt install -y git git-lfs && \
|
15 |
+
git --version && \
|
16 |
+
apt install -y aria2 libgl1 libglib2.0-0 wget && \
|
17 |
+
pip install -q torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url https://download.pytorch.org/whl/cu118 && \
|
18 |
+
pip install -q xformers==0.0.20 triton==2.0.0 packaging==23.1"
|
19 |
+
),
|
20 |
+
network_file_systems={"/content/stable-diffusion-webui": volume},
|
21 |
+
gpu="T4",
|
22 |
+
timeout=60000,
|
23 |
+
)
|
24 |
+
async def run():
|
25 |
+
os.system(f"git clone -b v2.6 https://github.com/camenduru/stable-diffusion-webui /content/stable-diffusion-webui")
|
26 |
+
os.chdir(f"/content/stable-diffusion-webui")
|
27 |
+
# os.system(f"rm -rf /content/stable-diffusion-webui/repositories")
|
28 |
+
os.system(f"git reset --hard")
|
29 |
+
os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/counterfeit-xl/resolve/main/counterfeitxl_v10.safetensors -d /content/stable-diffusion-webui/models/Stable-diffusion -o counterfeitxl_v10.safetensors")
|
30 |
+
os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/juggernaut-xl/resolve/main/juggernautXL_version2.safetensors -d /content/stable-diffusion-webui/models/Stable-diffusion -o juggernautXL_version2.safetensors")
|
31 |
+
os.system(f"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/sd_xl_refiner_1.0/resolve/main/sd_xl_refiner_1.0_0.9vae.safetensors -d /content/stable-diffusion-webui/models/Stable-diffusion -o sd_xl_refiner_1.0_0.9vae.safetensors")
|
32 |
+
os.environ['HF_HOME'] = '/content/stable-diffusion-webui/cache/huggingface'
|
33 |
+
# os.system(f"python launch.py --cors-allow-origins=* --xformers --theme dark --gradio-debug --share")
|
34 |
+
sys.path.append('/content/stable-diffusion-webui')
|
35 |
+
sys.argv = shlex.split("--cors-allow-origins=* --xformers --theme dark --gradio-debug --share")
|
36 |
+
from modules import launch_utils
|
37 |
+
launch_utils.startup_timer.record("initial startup")
|
38 |
+
launch_utils.prepare_environment()
|
39 |
+
launch_utils.start()
|
40 |
+
|
41 |
+
@stub.local_entrypoint()
|
42 |
+
def main():
|
43 |
+
run.remote()
|