DanielPinsk commited on
Commit
34bcacc
1 Parent(s): af9a5ad

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -134
app.py DELETED
@@ -1,134 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """StableDiffusionUI_Tom_Riddle_Edition.ipynb
3
-
4
- Automatically generated by Colaboratory.
5
-
6
- Original file is located at
7
- https://colab.research.google.com/github/WASasquatch/StableDiffusionUI-TomRiddle/blob/main/StableDiffusionUI_Tom_Riddle_Edition.ipynb
8
-
9
- # StableDiffusionUI - Tom Riddle Edition ![visitors](https://visitor-badge.glitch.me/badge?page_id=TomRiddleEdition&left_color=blue&right_color=orange) [![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/WASasquatch/StableDiffusionUI-TomRiddle)
10
-
11
- Adapted from: https://colab.research.google.com/drive/1AfAmwLMd_Vx33O9IwY2TmO9wKZ8ABRRa
12
-
13
- Cleaned up for font-end use by **WAS**
14
-
15
- ## Stablity.AI Model Terms of Use
16
-
17
- **By using this Notebook, you agree to the following Terms of Use, and license**
18
-
19
- This model is open access and available to all, with a CreativeML OpenRAIL-M license further specifying rights and usage.
20
-
21
- The CreativeML OpenRAIL License specifies:
22
- 1. You can't use the model to deliberately produce nor share illegal or harmful outputs or content
23
- 2. CompVis claims no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in the license
24
- 3. You may re-distribute the weights and use the model commercially and/or as a service. If you do, please be aware you have to include the same use restrictions as the ones in the license and share a copy of the CreativeML OpenRAIL-M to all your users (please read the license entirely and carefully)
25
-
26
- Please read the full license here: https://huggingface.co/spaces/CompVis/stable-diffusion-license
27
- """
28
-
29
- #@title Check GPU Allocation
30
- !nvidia-smi
31
-
32
- import os, subprocess, time
33
- #@title <font size="6" color="orange">Setup Installations</font>
34
- #@markdown Installation will restart the colab at the end. This is OK. Just run '<font color="green">**Launch WebUI**</font>' when it's restarted.
35
- CLEAR_SETUP_LOG = True #@param{type:'boolean'}
36
- ALLOW_COLAB_RESTART = True #@param{type: 'boolean'}
37
- WD = '/content/stable-diffusion-webui'
38
-
39
- def clear():
40
- from IPython.display import clear_output; return clear_output()
41
-
42
- def fetch_bytes(url_or_path):
43
- if str(url_or_path).startswith('http://') or str(url_or_path).startswith('https://'):
44
- from urllib.request import urlopen
45
- return urlopen(url_or_path)
46
- return open(url_or_path, 'r')
47
-
48
- def packages():
49
- import sys, subprocess
50
- return [r.decode().split('==')[0] for r in subprocess.check_output([sys.executable, '-m', 'pip', 'freeze']).split()]
51
-
52
- res = ''
53
- print('⏳ Installing Stable Diffusion WebUI ...')
54
- os.chdir('/content/')
55
- if not os.path.exists(WD):
56
- res += subprocess.run(['git', 'clone', '--quiet', 'https://github.com/AUTOMATIC1111/stable-diffusion-webui'], stdout=subprocess.PIPE).stdout.decode('utf-8')
57
- os.chdir(WD)
58
- res += subprocess.run(['pip', '-q', 'install', '-r', 'requirements.txt'], stdout=subprocess.PIPE).stdout.decode('utf-8')
59
- print(res)
60
- print('✅ Stable Diffusion WebUI installed.')
61
-
62
- #os.chdir(WD)
63
- if not os.path.exists('repositories'):
64
- os.makedirs('repositories')
65
-
66
- res = ''
67
- print('⏳ Cloning repositories...')
68
- if not os.path.exists(f'{WD}/repositories/stable-diffusion'):
69
- res += subprocess.run(['git', 'clone', '--quiet', 'https://github.com/CompVis/stable-diffusion.git', f'{WD}/repositories/stable-diffusion'], stdout=subprocess.PIPE).stdout.decode('utf-8')
70
- if not os.path.exists(f'{WD}/repositories/taming-transformers'):
71
- res += subprocess.run(['git', 'clone', '--quiet', 'https://github.com/CompVis/taming-transformers.git', f'{WD}/repositories/taming-transformers'], stdout=subprocess.PIPE).stdout.decode('utf-8')
72
- if not os.path.exists(f'{WD}/repositories/CodeFormer'):
73
- os.chdir(f'{WD}/repositories')
74
- res += subprocess.run(['git', 'clone', '--quiet', 'https://github.com/sczhou/CodeFormer.git'], stdout=subprocess.PIPE).stdout.decode('utf-8')
75
- res += subprocess.run(['pip', '-q', 'install', '-r', f'{WD}/repositories/CodeFormer/requirements.txt'], stdout=subprocess.PIPE).stdout.decode('utf-8')
76
- print(res)
77
- print('✅ Repositories cloned.')
78
-
79
- os.chdir(WD)
80
-
81
- # get a token from https://huggingface.co/settings/tokens
82
- try:
83
- with fetch_bytes('https://raw.githubusercontent.com/WASasquatch/easydiffusion/main/key.txt') as f:
84
- k = f.read().decode('utf-8').split(':'); hu = k[0].strip(); ht = k[1].strip()
85
- except OSError as e:
86
- raise e
87
- #user_token = "" #@param {type:"string"}
88
- print('⏳ Downloading model ...')
89
- if not os.path.exists('model.ckpt'):
90
- print(subprocess.run(['wget', '-q', '--show-progress', f'https://{hu}:{ht}@huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt', '-O', 'model.ckpt'], stdout=subprocess.PIPE).stdout.decode('utf-8'))
91
- if os.path.exists('model.ckpt'):
92
- print('✅ Model downloaded.')
93
- else:
94
- print('⚠️ Unable to download the model!')
95
- else:
96
- print('✅ Model downloaded.')
97
-
98
- if not os.path.exists('GFPGANv1.3.pth'):
99
- print(subprocess.run(['wget', '-q', '--show-progress', 'https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth', '-O', 'GFPGANv1.3.pth'], stdout=subprocess.PIPE).stdout.decode('utf-8'))
100
-
101
- os.chdir(WD)
102
-
103
- subprocess.run(['git', 'pull', '--quiet'], stdout=subprocess.DEVNULL)
104
-
105
- if CLEAR_SETUP_LOG:
106
- clear()
107
- print('♻️ Setup finished! Restarting Colab Environment in 5 seconds ...')
108
- time.sleep(5)
109
-
110
- if ALLOW_COLAB_RESTART:
111
- os.kill(os.getpid(), 9) # This will crash Colab (required, everything will still be intact so dont worry)
112
-
113
- """Launch WebUI. You will get a link to nnn.gradio.app, follow it."""
114
-
115
- #@title <font size="6" color="green">Launch WebUI</font>
116
- import sys, os
117
-
118
- WD = '/content/stable-diffusion-webui'
119
- sys.argv = ["--opt-split-attention"]
120
- os.chdir(WD)
121
-
122
- import webui
123
- import modules.ui
124
- import modules.txt2img
125
- import modules.img2img
126
-
127
- demo = modules.ui.create_ui(
128
- txt2img=webui.wrap_gradio_gpu_call(modules.txt2img.txt2img),
129
- img2img=webui.wrap_gradio_gpu_call(modules.img2img.img2img),
130
- run_extras=webui.wrap_gradio_gpu_call(modules.extras.run_extras),
131
- run_pnginfo=modules.extras.run_pnginfo
132
- )
133
-
134
- demo.launch(share=True)