spg commited on
Commit
f20b895
β€’
1 Parent(s): c462423
Files changed (2) hide show
  1. README.md +6 -5
  2. app.py +54 -0
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
- title: Lora
3
- emoji: πŸƒ
4
- colorFrom: gray
5
- colorTo: gray
6
  sdk: gradio
7
- sdk_version: 3.29.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Taiyi Stable Diffusion Chinese Webui
3
+ emoji: πŸ’©
4
+ colorFrom: green
5
+ colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 3.16.1
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from subprocess import getoutput
3
+
4
+ gpu_info = getoutput('nvidia-smi')
5
+ os.system(f"pip install -q triton==2.0.0.dev20221120")
6
+ if("A10G" in gpu_info):
7
+ os.system(f"pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/xformers-0.0.15.dev0+4c06c79.d20221205-cp38-cp38-linux_x86_64.whl")
8
+ elif("T4" in gpu_info):
9
+ os.system(f"pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/xformers-0.0.15.dev0+1515f77.d20221130-cp38-cp38-linux_x86_64.whl")
10
+
11
+ os.system(
12
+ f"git clone https://{os.getenv('GITHUB_TOKEN_NAME')}:{os.getenv('GITHUB_TOKEN')}@github.com/IDEA-CCNL/taiyi-webui.git /home/user/app/stable-diffusion-webui")
13
+ yaml_path = f"/home/user/app/stable-diffusion-webui/configs/{os.getenv('YAML_NAME')}"
14
+ os.system(f"sed -i 's|your_path|{os.getenv('MODEL_NAME')}|g' {yaml_path}")
15
+ os.system(f"sed -i 's|use_auth_token: False|use_auth_token: {os.getenv('HF_TOKEN')}|g' {yaml_path}")
16
+ os.chdir("/home/user/app/stable-diffusion-webui")
17
+
18
+ os.system(f"wget -q https://github.com/camenduru/webui/raw/main/env_patch.py -O /home/user/app/env_patch.py")
19
+ os.system(f"sed -i '$a fastapi==0.90.0' /home/user/app/stable-diffusion-webui/requirements_versions.txt")
20
+ 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")
21
+ os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
22
+ os.system(f"sed -i -e '/(train_interface, \"Train\", \"ti\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
23
+ os.system(f"sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
24
+ os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
25
+ os.system(
26
+ 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''')
27
+ os.system(f"sed -i -e 's/ show_progress=False,/ show_progress=True,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
28
+ os.system(f"sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' /home/user/app/stable-diffusion-webui/webui.py")
29
+ os.system(
30
+ f"sed -i -e 's/ outputs=\[/queue=False, &/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
31
+ os.system(f"sed -i -e 's/ queue=False, / /g' /home/user/app/stable-diffusion-webui/modules/ui.py")
32
+
33
+ # ----------------------------Please duplicate this space and delete this block if you don't want to see the extra header----------------------------
34
+ os.system(f"wget -q https://raw.githubusercontent.com/GGGGGGXY/webui/master/header_patch.py -O /home/user/app/header_patch.py")
35
+ os.system(f"sed -i -e '/demo:/r /home/user/app/header_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
36
+ # ---------------------------------------------------------------------------------------------------------------------------------------------------
37
+
38
+ # if "IS_SHARED_UI" in os.environ:
39
+ if True:
40
+ os.system(f"rm -rfv /home/user/app/stable-diffusion-webui/scripts/")
41
+
42
+ os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-config.json -O /home/user/app/shared-config.json")
43
+ os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-ui-config.json -O /home/user/app/shared-ui-config.json")
44
+
45
+ ckpt_path = os.path.join("/home/user/app/stable-diffusion-webui/models/Stable-diffusion",
46
+ os.path.split(os.getenv('MODEL_CKPT_URL'))[-1])
47
+ os.system(f"wget -q {os.getenv('MODEL_CKPT_URL')} -O {ckpt_path}")
48
+
49
+ sr_ckpt = os.path.join("/home/user/app/stable-diffusion-webui",
50
+ os.path.split(os.getenv('SR_CKPT'))[-1])
51
+ os.system(f"wget -q {os.getenv('SR_CKPT')} -O {sr_ckpt}")
52
+
53
+ os.system(
54
+ f"python launch.py --enable-insecure-extension-access --xformers --disable-console-progressbars --disable-safe-unpickle --enable-console-prompts --ui-config-file /home/user/app/shared-ui-config.json --ui-settings-file /home/user/app/shared-config.json --cors-allow-origins huggingface.co,hf.space --no-progressbar-hiding --ckpt={ckpt_path} --inpainting_sr_ckpt={sr_ckpt} --config={yaml_path}")