Nitinnn commited on
Commit
d253690
1 Parent(s): 35b886b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -43
app.py CHANGED
@@ -1,43 +1,22 @@
1
- import os
2
- from subprocess import getoutput
3
-
4
- gpu_info = getoutput('nvidia-smi')
5
- if("A10G" in gpu_info):
6
- 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")
7
- elif("T4" in gpu_info):
8
- 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")
9
-
10
- os.system(f"git clone -b v1.5 https://github.com/camenduru/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
11
- os.chdir("/home/user/app/stable-diffusion-webui")
12
-
13
- os.system(f"wget -q https://github.com/camenduru/webui/raw/main/env_patch.py -O /home/user/app/env_patch.py")
14
- os.system(f"sed -i '$a fastapi==0.90.0' /home/user/app/stable-diffusion-webui/requirements_versions.txt")
15
- 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")
16
- os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
17
- os.system(f"sed -i -e '/(train_interface, \"Train\", \"ti\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
18
- os.system(f"sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
19
- os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
20
- 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''')
21
- os.system(f"sed -i -e 's/ show_progress=False,/ show_progress=True,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
22
- os.system(f"sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' /home/user/app/stable-diffusion-webui/webui.py")
23
- os.system(f"sed -i -e 's/ outputs=\[/queue=False, &/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
24
- os.system(f"sed -i -e 's/ queue=False, / /g' /home/user/app/stable-diffusion-webui/modules/ui.py")
25
-
26
- # ----------------------------Please duplicate this space and delete this block if you don't want to see the extra header----------------------------
27
- # os.system(f"wget -q https://github.com/camenduru/webui/raw/main/header_patch.py -O /home/user/app/header_patch.py")
28
- # os.system(f"sed -i -e '/demo:/r /home/user/app/header_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
29
- # ---------------------------------------------------------------------------------------------------------------------------------------------------
30
-
31
- os.system(f"rm -rfv /home/user/app/stable-diffusion-webui/scripts/")
32
-
33
- os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-config.json -O /home/user/app/shared-config.json")
34
- os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-ui-config.json -O /home/user/app/shared-ui-config.json")
35
-
36
- # os.system(f"wget -q https://huggingface.co/DucHaiten/DucHaitenAIart/resolve/main/DucHaitenAIart_v2.0.safetensors -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/DucHaitenAIart_v2.0-emaonly.safetensors")
37
- os.system(f"wget -q https://huggingface.co/DucHaiten/DucHaitenDreamWorld/resolve/main/DucHaitenDreamWorld_v2.4.1.safetensors -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/DucHaitenDreamWorld_v2.4.1.safetensors")
38
- os.system(f"wget -q https://huggingface.co/DucHaiten/DucHaitenAnime/resolve/main/DucHaitenAnime_v4.0.safetensors -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/DucHaitenAnime_v4.0.safetensors")
39
- os.system(f"wget -q https://huggingface.co/DucHaiten/DucHaitenAnimated/resolve/main/DucHaitenAnimated_v5.0.safetensors -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/DucHaitenAnimated_v5.0.safetensors")
40
- os.system(f"wget -q https://huggingface.co/DucHaiten/DucHaitenAIart/resolve/main/DucHaitenAIart_v3.1.safetensors -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/DucHaitenAIart_v3.1.safetensors")
41
- os.system(f"wget -q https://huggingface.co/userdiffuser/cyberrealistic_v13/resolve/main/cyberrealistic_v13.safetensors -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/Deliberate.safetensors")
42
-
43
- os.system(f"python launch.py --skip-torch-cuda-test --force-enable-xformers --ui-config-file /home/user/app/ui-config.json --ui-settings-file /home/user/app/config.json --disable-console-progressbars --enable-console-prompts --cors-allow-origins huggingface.co,hf.space --no-progressbar-hiding --api")
 
1
+ import torch
2
+ from diffusers import DiffusionPipeline
3
+ import gradio as gr
4
+
5
+ generator = DiffusionPipeline.from_pretrained("Mousewrites/charTurner")
6
+ # move to GPU if available
7
+ if torch.cuda.is_available():
8
+ generator = generator.to("cuda")
9
+
10
+ def generate(prompts):
11
+ images = generator(list(prompts)).images
12
+ return [images]
13
+
14
+ demo = gr.Interface(generate,
15
+ "textbox",
16
+ "image",
17
+ batch=True,
18
+ max_batch_size=1 # Set the batch size based on your CPU/GPU memory
19
+ ).queue()
20
+
21
+ if __name__ == "__main__":
22
+ demo.launch()