AhhhhCraaaap commited on
Commit
305189c
1 Parent(s): b83a35b

Upload stable_diffusion_1_5_webui_STABLE (2).ipynb

Browse files
stable_diffusion_1_5_webui_STABLE (2).ipynb ADDED
@@ -0,0 +1,414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "SKi-oMBwhutR"
7
+ },
8
+ "source": [
9
+ "# AUTOMATIC1111 Stable Diffusion WebUI 1.5 + ChilloutMix Checkpoint\n",
10
+ "\n",
11
+ "For generating AI Onlyfans\n",
12
+ "\n",
13
+ "> [@nang](https://github.com/nathan-149) \n",
14
+ "> Based off of: [@wibus-wee](https://github.com/wibus-wee)\n",
15
+ "> Reference: [camenduru/stable-diffusion-webui-colab](https://github.com/camenduru/stable-diffusion-webui-colab)"
16
+ ]
17
+ },
18
+ {
19
+ "cell_type": "code",
20
+ "execution_count": null,
21
+ "metadata": {
22
+ "id": "oL8eHMWfLzO7"
23
+ },
24
+ "outputs": [],
25
+ "source": [
26
+ "#@title 2. Check GPU & Dev Environment\n",
27
+ "\n",
28
+ "from IPython.display import display\n",
29
+ "import ipywidgets as widgets\n",
30
+ "import requests \n",
31
+ "\n",
32
+ "import os, subprocess\n",
33
+ "paperspace_m4000 = False\n",
34
+ "#@markdown Paperspace platform?\n",
35
+ "isPaperspace = False #@param {type:\"boolean\"}\n",
36
+ "try:\n",
37
+ " subprocess.run(['nvidia-smi', '--query-gpu=name', '--format=csv,noheader'], stdout=subprocess.PIPE)\n",
38
+ " if 'M4000' in subprocess.run(['nvidia-smi', '--query-gpu=name', '--format=csv,noheader'], stdout=subprocess.PIPE).stdout.decode('utf-8'):\n",
39
+ " print(\"WARNING: You're using Quadro M4000 GPU,xformers won't work。\")\n",
40
+ " paperspace_m4000 = True\n",
41
+ " isPaperspace = True\n",
42
+ " else:\n",
43
+ " print(\"Your GPU is suitable - \" + subprocess.run(['nvidia-smi', '--query-gpu=name', '--format=csv,noheader'], stdout=subprocess.PIPE).stdout.decode('utf-8') + \"。\")\n",
44
+ " print(\"Platform: Paperspace\" if isPaperspace else \"Platform: Colab\")\n",
45
+ "except:\n",
46
+ " print(\"No GPU appears to be available. Please check your runtime type\")\n",
47
+ " exit()\n",
48
+ "\n",
49
+ "rootDir = isPaperspace and '/tmp' or '/content'\n",
50
+ "stableDiffusionWebUIInstalled = os.path.exists(rootDir + '/stable-diffusion-webui')\n",
51
+ "%store rootDir\n",
52
+ "%store paperspace_m4000 \n",
53
+ "%store isPaperspace\n",
54
+ "%store stableDiffusionWebUIInstalled"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": null,
60
+ "metadata": {
61
+ "id": "SaAJk33ppFw1"
62
+ },
63
+ "outputs": [],
64
+ "source": [
65
+ "import requests\n",
66
+ "#@title 3. Install dependencies and extensions \n",
67
+ "\n",
68
+ "#@markdown ## **Extensions**\n",
69
+ "\n",
70
+ "#@markdown xformer\n",
71
+ "xformersInstall = True #@param {type:\"boolean\"}\n",
72
+ "#@markdown ControlNet\n",
73
+ "controlNetExtension = False #@param {type:\"boolean\"}\n",
74
+ "#@markdown OpenPose Editor\n",
75
+ "openPoseExtension = False #@param {type:\"boolean\"}\n",
76
+ "#@markdown Civitai Browser\n",
77
+ "civitaiBrowserExtension = False #@param {type:\"boolean\"}\n",
78
+ "#@markdown HuggingFace \n",
79
+ "huggingFaceExtension = False #@param {type:\"boolean\"}\n",
80
+ "#@markdown Images Browser \n",
81
+ "imagesBrowserExtension = False #@param {type:\"boolean\"}\n",
82
+ "#@markdown Additional Networks \n",
83
+ "additionalNetworksExtension = True #@param {type:\"boolean\"}\n",
84
+ "#@markdown Deforum \n",
85
+ "deforumExtension = False #@param {type:\"boolean\"}\n",
86
+ "#@markdown Kohya sd-scripts \n",
87
+ "kohyaExtension = False #@param {type:\"boolean\"}\n",
88
+ "#@markdown DreamBooth \n",
89
+ "dreamBoothExtension = False #@param {type:\"boolean\"}\n",
90
+ "\n",
91
+ "\n",
92
+ "#@markdown ---\n",
93
+ "#@markdown ## **Textual Inversion**\n",
94
+ "#@markdown Ulzzang-6500 (Korean doll aesthetic)\n",
95
+ "ulzzang6500 = True #@param {type:\"boolean\"}\n",
96
+ "#@markdown Pure Eros Face\n",
97
+ "pureErosFace = True #@param {type:\"boolean\"}\n",
98
+ "\n",
99
+ "#@markdown ---\n",
100
+ "\n",
101
+ "#@markdown ## **Startup Options**\n",
102
+ "\n",
103
+ "#@markdown API Support\n",
104
+ "apiSupport = True #@param {type:\"boolean\"}\n",
105
+ "\n",
106
+ "textualInversionDownloadIDs = {\n",
107
+ " 'ulzzang6500': 8109,\n",
108
+ " 'pureErosFace': 4514,\n",
109
+ "}\n",
110
+ "\n",
111
+ "def getLatestModelDownloadURL(id):\n",
112
+ " try:\n",
113
+ " if type(id) == int:\n",
114
+ " res = requests.get(endpoint + '/' + str(id)).json()\n",
115
+ " latest = res['modelVersions'][0]\n",
116
+ " downloadLink = latest['files'][0]['downloadUrl']\n",
117
+ " name = latest['files'][0]['name']\n",
118
+ " return {\n",
119
+ " 'url': downloadLink,\n",
120
+ " 'name': name\n",
121
+ " }\n",
122
+ " else:\n",
123
+ " return {\n",
124
+ " 'url': id,\n",
125
+ " 'name': id.split('/')[-1]\n",
126
+ " }\n",
127
+ " except:\n",
128
+ " print(\"Lora model \" + str(id) + \" not found. Skip.\")\n",
129
+ " return None\n",
130
+ "\n",
131
+ "def getSpecificModelDownloadURL(id, version):\n",
132
+ " try:\n",
133
+ " if type(id) == int:\n",
134
+ " res = requests.get(endpoint + '/' + str(id)).json()\n",
135
+ " for modelVersion in res['modelVersions']:\n",
136
+ " if modelVersion['name'] == version:\n",
137
+ " # if modelVersion[\"baseModel\"] != \"SD 1.5\":\n",
138
+ " # print(\"Lora model \" + str(id) + \" is not SD 1.5, may not work. Skip.\")\n",
139
+ " # return None\n",
140
+ " downloadLink = modelVersion['files'][0]['downloadUrl']\n",
141
+ " name = modelVersion['files'][0]['name']\n",
142
+ " return {\n",
143
+ " 'url': downloadLink,\n",
144
+ " 'name': name\n",
145
+ " }\n",
146
+ " else:\n",
147
+ " return {\n",
148
+ " 'url': id,\n",
149
+ " 'name': id.split('/')[-1]\n",
150
+ " }\n",
151
+ " except:\n",
152
+ " print(\"Lora model \" + str(id) + \" version \" + version + \" not found. Skip.\")\n",
153
+ " return None\n",
154
+ "\n",
155
+ "def getTextualInversionDownloadURLs():\n",
156
+ " downloadURLs = []\n",
157
+ " for key in textualInversionDownloadIDs:\n",
158
+ " if not eval(key): # skip if not selected\n",
159
+ " continue\n",
160
+ " if type(textualInversionDownloadIDs[key]) is int:\n",
161
+ " downloadURLs.append(getLatestModelDownloadURL(textualInversionDownloadIDs[key]))\n",
162
+ " elif type(textualInversionDownloadIDs[key]) is dict: # {'id': 123, 'version': 'v1.0'}\n",
163
+ " downloadURLs.append(getSpecificModelDownloadURL(textualInversionDownloadIDs[key]['id'], textualInversionDownloadIDs[key]['version']))\n",
164
+ " elif type(textualInversionDownloadIDs[key]) is str: # url\n",
165
+ " downloadURLs.append({ 'url': textualInversionDownloadIDs[key], 'name': textualInversionDownloadIDs[key].split('/')[-1] })\n",
166
+ " downloadURLs = [x for x in downloadURLs if x is not None]\n",
167
+ " return downloadURLs\n",
168
+ " \n",
169
+ "textualInversionDownloadURLs = getTextualInversionDownloadURLs()\n",
170
+ "\n",
171
+ "%store -r paperspace_m4000 \n",
172
+ "%store -r isPaperspace\n",
173
+ "%store -r rootDir \n",
174
+ "%store -r checkpoints\n",
175
+ "%store -r downloadLinks\n",
176
+ "%store -r stableDiffusionWebUIInstalled\n",
177
+ "\n",
178
+ "import subprocess\n",
179
+ "\n",
180
+ "!apt-get -y install -qq aria2\n",
181
+ "ariaInstalled = False\n",
182
+ "\n",
183
+ "try:\n",
184
+ " subprocess.run(['aria2c', '--version'], stdout=subprocess.PIPE)\n",
185
+ " ariaInstalled = True\n",
186
+ "except:\n",
187
+ " pass\n",
188
+ "\n",
189
+ "if paperspace_m4000:\n",
190
+ " if xformersInstall:\n",
191
+ " !pip install ninja\n",
192
+ " !pip install -v -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers\n",
193
+ " !pip install -q --pre triton\n",
194
+ "else:\n",
195
+ " !pip install -q https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230118-cp38-cp38-linux_x86_64.whl\n",
196
+ " !pip install -q --pre triton\n",
197
+ " \n",
198
+ "\n",
199
+ "!git clone -b v2.0 https://github.com/nathan-149/stable-diffusion-webui {rootDir}/stable-diffusion-webui\n",
200
+ "!wget https://raw.githubusercontent.com/nathan-149/stable-diffusion-webui-scripts/main/run_n_times.py -O {rootDir}/stable-diffusion-webui/scripts/run_n_times.py\n",
201
+ "if deforumExtension:\n",
202
+ " !git clone https://github.com/deforum-art/deforum-for-automatic1111-webui {rootDir}/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui\n",
203
+ "if imagesBrowserExtension:\n",
204
+ " !git clone https://github.com/AlUlkesh/stable-diffusion-webui-images-browser {rootDir}/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser\n",
205
+ "if huggingFaceExtension:\n",
206
+ " !git clone https://github.com/camenduru/stable-diffusion-webui-huggingface {rootDir}/stable-diffusion-webui/extensions/stable-diffusion-webui-huggingface\n",
207
+ "if civitaiBrowserExtension:\n",
208
+ " !git clone -b v2.0 https://github.com/camenduru/sd-civitai-browser {rootDir}/stable-diffusion-webui/extensions/sd-civitai-browser\n",
209
+ "if openPoseExtension:\n",
210
+ " !git clone https://github.com/camenduru/openpose-editor {rootDir}/stable-diffusion-webui/extensions/openpose-editor\n",
211
+ "if controlNetExtension:\n",
212
+ " !git clone https://github.com/Mikubill/sd-webui-controlnet {rootDir}/stable-diffusion-webui/extensions/sd-webui-controlnet\n",
213
+ "if additionalNetworksExtension:\n",
214
+ " !git clone https://github.com/kohya-ss/sd-webui-additional-networks {rootDir}/stable-diffusion-webui/extensions/sd-webui-additional-networks\n",
215
+ "if kohyaExtension:\n",
216
+ " !git clone https://github.com/ddpn08/kohya-sd-scripts-webui.git {rootDir}/stable-diffusion-webui/extensions/kohya-sd-scripts-webui\n",
217
+ "if dreamBoothExtension:\n",
218
+ " !git clone https://github.com/d8ahazard/sd_dreambooth_extension {rootDir}/stable-diffusion-webui/extensions/sd_dreambooth_extension\n",
219
+ "\n",
220
+ "if isPaperspace:\n",
221
+ " %cd /stable-diffusion-webui\n",
222
+ "else:\n",
223
+ " %cd {rootDir}/stable-diffusion-webui\n",
224
+ "\n",
225
+ "\n",
226
+ "webuiControlNetModels = [\n",
227
+ " \"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_canny-fp16.safetensors\",\n",
228
+ " \"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors\",\n",
229
+ " \"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_hed-fp16.safetensors\",\n",
230
+ " \"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_mlsd-fp16.safetensors\",\n",
231
+ " \"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_normal-fp16.safetensors\",\n",
232
+ " \"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors\",\n",
233
+ " \"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_scribble-fp16.safetensors\",\n",
234
+ " \"https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_seg-fp16.safetensors\",\n",
235
+ "]\n",
236
+ "annotatorLink = [\n",
237
+ " \"https://huggingface.co/ckpt/ControlNet/resolve/main/hand_pose_model.pth\",\n",
238
+ " \"https://huggingface.co/ckpt/ControlNet/resolve/main/body_pose_model.pth\",\n",
239
+ " \"https://huggingface.co/ckpt/ControlNet/resolve/main/dpt_hybrid-midas-501f0c75.pt\",\n",
240
+ " \"https://huggingface.co/ckpt/ControlNet/resolve/main/mlsd_large_512_fp32.pth\",\n",
241
+ " \"https://huggingface.co/ckpt/ControlNet/resolve/main/mlsd_tiny_512_fp32.pth\",\n",
242
+ " \"https://huggingface.co/ckpt/ControlNet/resolve/main/network-bsds500.pth\",\n",
243
+ " \"https://huggingface.co/ckpt/ControlNet/resolve/main/upernet_global_small.pth\",\n",
244
+ "]\n",
245
+ "\n",
246
+ "def ariaDownload(downloadLink, checkpoint, path):\n",
247
+ " if (type(downloadLink) == list and type(checkpoint) == list):\n",
248
+ " for i in downloadLink:\n",
249
+ " !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M {i} -d {path} -o {checkpoint[downloadLink.index(i)]}\n",
250
+ " else:\n",
251
+ " !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M {downloadLink} -d {path} -o {checkpoint}\n",
252
+ "def wgetDownload(downloadLink, checkpoint, path):\n",
253
+ " if (type(downloadLink) == list and type(checkpoint) == list):\n",
254
+ " for i in downloadLink:\n",
255
+ " !wget -c {i} -P {path} -O {checkpoint[downloadLink.index(i)]}\n",
256
+ " else:\n",
257
+ " !wget -c {downloadLink} -P {path} -O {checkpoint}\n",
258
+ "def autoDetectDownload(downloadLink, checkpoint, path):\n",
259
+ " if ariaInstalled:\n",
260
+ " ariaDownload(downloadLink, checkpoint, path)\n",
261
+ " else:\n",
262
+ " wgetDownload(downloadLink, checkpoint, path)\n",
263
+ "\n",
264
+ "if controlNetExtension:\n",
265
+ " for model in webuiControlNetModels:\n",
266
+ " autoDetectDownload(model, model.split('/')[-1], rootDir + \"/stable-diffusion-webui/extensions/sd-webui-controlnet/models\")\n",
267
+ " for model in annotatorLink:\n",
268
+ " autoDetectDownload(model, model.split('/')[-1], rootDir + \"/stable-diffusion-webui/extensions/sd-webui-controlnet/annotator\")\n",
269
+ "for model in textualInversionDownloadURLs:\n",
270
+ " autoDetectDownload(model[\"url\"], model[\"name\"], rootDir + \"/stable-diffusion-webui/embeddings\")\n",
271
+ "\n",
272
+ "if additionalNetworksExtension:\n",
273
+ " !ln -s {rootDir}/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/lora {rootDir}/stable-diffusion-webui/models/Lora\n",
274
+ "\n",
275
+ "\n",
276
+ "stableDiffusionWebUIInstalled = True\n",
277
+ "%store stableDiffusionWebUIInstalled\n",
278
+ "\n",
279
+ "%cd {rootDir}/stable-diffusion-webui\n",
280
+ "!sed -i -e '''/prepare_environment()/a\\ os.system\\(f\\\"\"\"sed -i -e ''\\\"s/self.logvar\\\\[t\\\\]/self.logvar\\\\[t.item()\\\\]/g\\\"'' {rootDir}/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py\"\"\")''' {rootDir}/stable-diffusion-webui/launch.py\n",
281
+ "!sed -i -e '''/prepare_environment()/a\\ os.system\\(f\\\"\"\"sed -i -e ''\\\"s/dict()))/dict())).cuda()/g\\\"'' {rootDir}/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py\"\"\")''' {rootDir}/stable-diffusion-webui/launch.py\n",
282
+ "if dreamBoothExtension:\n",
283
+ " !export REQS_FILE=\"./extensions/sd_dreambooth_extension/requirements.txt\"\n",
284
+ "\n",
285
+ "\n"
286
+ ]
287
+ },
288
+ {
289
+ "cell_type": "code",
290
+ "execution_count": null,
291
+ "metadata": {
292
+ "id": "ht3hxbzPFL3G"
293
+ },
294
+ "outputs": [],
295
+ "source": [
296
+ "#@title Download Chilloutmix Checkpoint\n",
297
+ "\n",
298
+ "checkpoint = 'chilloutmix.safetensors' #@param [\"chilloutmix.safetensors\"]\n",
299
+ "\n",
300
+ "downloadLink = 'https://civitai.com/api/download/models/11745' #@param \n",
301
+ "\n",
302
+ "\n",
303
+ "!wget -c {downloadLink} -O /content/stable-diffusion-webui/models/Stable-diffusion/{checkpoint}\n",
304
+ "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/sd14/resolve/main/sd-v1-4.ckpt -d /content/stable-diffusion-webui/models/Stable-diffusion -o sd-v1-4.ckpt\n",
305
+ "\n"
306
+ ]
307
+ },
308
+ {
309
+ "cell_type": "code",
310
+ "execution_count": null,
311
+ "metadata": {
312
+ "id": "D7tw6cMcMOba"
313
+ },
314
+ "outputs": [],
315
+ "source": [
316
+ "#@title Download Loras\n",
317
+ "\n",
318
+ "loraLinks = dict((\n",
319
+ " ('koreanDollLikeness_v15.safetensors', 'https://civitai.com/api/download/models/31284'),\n",
320
+ " ('xswltry1.safetensors', 'https://civitai.com/api/download/models/29131'),\n",
321
+ " ('liyuuLora_liyuuV1.safetensors', 'https://civitai.com/models/9997/liyuu-lora'),\n",
322
+ " ('aiBeautyIthlinni_ithlinniV1.safetensors', 'https://civitai.com/api/download/models/19671'),\n",
323
+ " ('Cute_girl_mix4.safetensors', 'https://civitai.com/api/download/models/16677'),\n",
324
+ " ('breastinclassBetter_v141.safetensors', 'https://civitai.com/api/download/models/23250'),\n",
325
+ " ('chilloutmixss_xss10.safetensors', 'https://huggingface.co/HankChang/chilloutmixss_xss10/resolve/main/chilloutmixss_xss10.safetensors'),\n",
326
+ " ('moxin.safetensors', 'https://civitai.com/api/download/models/14856'),\n",
327
+ " ('legspread10.safetensors', 'https://civitai.com/api/download/models/29760'),\n",
328
+ " ('taiwan.safetensors', 'https://civitai.com/api/download/models/20684')\n",
329
+ "))\n",
330
+ "\n",
331
+ "\n",
332
+ "for lora, link in loraLinks.items():\n",
333
+ " print('\\nKey: %s' % lora)\n",
334
+ " print('Value: %s' % link)\n",
335
+ " !wget -c {link} -O /content/stable-diffusion-webui/models/Lora/{lora}\n",
336
+ "\n"
337
+ ]
338
+ },
339
+ {
340
+ "cell_type": "code",
341
+ "execution_count": null,
342
+ "metadata": {
343
+ "id": "pddH4PXZB-fZ"
344
+ },
345
+ "outputs": [],
346
+ "source": [
347
+ "#@title Run UI!\n",
348
+ "%pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchtext==0.14.1 torchaudio==0.13.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu117\n",
349
+ "!cd /content/stable-diffusion-webui/ && python launch.py --enable-insecure-extension-access --share"
350
+ ]
351
+ },
352
+ {
353
+ "cell_type": "code",
354
+ "execution_count": null,
355
+ "metadata": {
356
+ "id": "W0k4xg3rLzO8"
357
+ },
358
+ "outputs": [],
359
+ "source": [
360
+ "#@title 5. Export Photos to /export\n",
361
+ "%store -r rootDir \n",
362
+ "\n",
363
+ "from pathlib import Path\n",
364
+ "import os, subprocess\n",
365
+ "\n",
366
+ "export_storage_dir = Path(rootDir, 'export')\n",
367
+ "export_storage_dir.mkdir(exist_ok=True)\n",
368
+ "\n",
369
+ "!if [ $(dpkg-query -W -f='${Status}' p7zip-full 2>/dev/null | grep -c \"ok installed\") = 0 ]; then sudo apt update && sudo apt install -y p7zip-full; fi # install 7z if it isn't already installed\n",
370
+ "from datetime import datetime\n",
371
+ "datetime_str = datetime.now().strftime('%m-%d-%Y_%H-%M-%S')\n",
372
+ "%cd \"{export_storage_dir}\"\n",
373
+ "!mkdir -p \"{datetime_str}/log\"\n",
374
+ "!cd \"{rootDir}/stable-diffusion-webui/log\" && mv * \"{export_storage_dir / datetime_str / 'log'}\"\n",
375
+ "!cd \"{rootDir}/stable-diffusion-webui/outputs\" && mv * \"{export_storage_dir / datetime_str}\"\n",
376
+ "s = subprocess.run(f'find \"{Path(export_storage_dir, datetime_str)}\" -type d -name .ipynb_checkpoints -exec rm -rv {{}} +', shell=True)\n",
377
+ "!7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on \"{datetime_str}.7z\" \"{export_storage_dir / datetime_str}\""
378
+ ]
379
+ }
380
+ ],
381
+ "metadata": {
382
+ "accelerator": "GPU",
383
+ "colab": {
384
+ "machine_shape": "hm",
385
+ "private_outputs": true,
386
+ "provenance": []
387
+ },
388
+ "gpuClass": "premium",
389
+ "kernelspec": {
390
+ "display_name": "Python 3",
391
+ "language": "python",
392
+ "name": "python3"
393
+ },
394
+ "language_info": {
395
+ "codemirror_mode": {
396
+ "name": "ipython",
397
+ "version": 3
398
+ },
399
+ "file_extension": ".py",
400
+ "mimetype": "text/x-python",
401
+ "name": "python",
402
+ "nbconvert_exporter": "python",
403
+ "pygments_lexer": "ipython3",
404
+ "version": "3.9.6"
405
+ },
406
+ "vscode": {
407
+ "interpreter": {
408
+ "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
409
+ }
410
+ }
411
+ },
412
+ "nbformat": 4,
413
+ "nbformat_minor": 0
414
+ }