File size: 3,533 Bytes
cb1effc
 
 
 
 
f4cab5f
cb1effc
f4cab5f
cb1effc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from subprocess import getoutput

gpu_info = getoutput('nvidia-smi')
if("A10G" in gpu_info):
    os.system(f"pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230119.A10G-cp310-cp310-linux_x86_64.whl")
elif("T4" in gpu_info):
    os.system(f"pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230119.A10G-cp310-cp310-linux_x86_64.whl")

os.system(f"git clone -b v1.5 https://github.com/camenduru/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
os.chdir("/home/user/app/stable-diffusion-webui")

os.system(f"wget -q https://github.com/camenduru/webui/raw/main/env_patch.py -O /home/user/app/env_patch.py")
os.system(f"sed -i '$a fastapi==0.90.0' /home/user/app/stable-diffusion-webui/requirements_versions.txt")
os.system(f"sed -i -e '/import image_from_url_text/r /home/user/app/env_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
os.system(f"sed -i -e '/(train_interface, \"Train\", \"ti\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
os.system(f"sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
os.system(f'''sed -i -e "s/document.getElementsByTagName('gradio-app')\[0\].shadowRoot/!!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document/g" /home/user/app/stable-diffusion-webui/script.js''')
os.system(f"sed -i -e 's/                show_progress=False,/                show_progress=True,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
os.system(f"sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' /home/user/app/stable-diffusion-webui/webui.py")
os.system(f"sed -i -e 's/ outputs=\[/queue=False, &/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
os.system(f"sed -i -e 's/               queue=False,  /                /g' /home/user/app/stable-diffusion-webui/modules/ui.py")

# ----------------------------Please duplicate this space and delete this block if you don't want to see the extra header----------------------------
os.system(f"wget -q https://github.com/darkstorm2150/webui/raw/main/OpenGen_header_patch.py -O /home/user/app/OpenGen_header_patch.py")
os.system(f"sed -i -e '/ui.py /r /home/user/app/OpenGen_header_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
os.system(f"rm /home/user/app/OpenGen_header_patch.py")
# ------------------------------------------------------------------------------------------------------------------------------

if("IS_SHARED_UI" in os.environ):
    os.system(f"sed -i -e 's/cdn.gradio.app/images.gradio.app/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
    os.system(f"sed -i -e 's/gradio.app/camenduru.com/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
    os.system(f"wget https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/stable-diffusion-webui-cp38-cp38-linux_x86_64.whl -O /home/user/app/stable-diffusion-webui-cp38-cp38-linux_x86_64.whl")
    os.system(f"pip install -q --no-deps /home/user/app/stable-diffusion-webui-cp38-cp38-linux_x86_64.whl")