JosephusCheung commited on
Commit
eae4fd4
1 Parent(s): 433142c

Upload ACertainModel_on_SD_WEBUI.ipynb

Browse files
Files changed (1) hide show
  1. ACertainModel_on_SD_WEBUI.ipynb +175 -0
ACertainModel_on_SD_WEBUI.ipynb ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "VBDPqhYnyBL1"
7
+ },
8
+ "source": [
9
+ "Check GPU"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": null,
15
+ "metadata": {
16
+ "id": "woQCdVO8x-Kt"
17
+ },
18
+ "outputs": [],
19
+ "source": [
20
+ "!nvidia-smi"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "markdown",
25
+ "metadata": {
26
+ "id": "OHCtG9MT0jLq"
27
+ },
28
+ "source": [
29
+ "Clone webui repository and download the model."
30
+ ]
31
+ },
32
+ {
33
+ "cell_type": "code",
34
+ "execution_count": null,
35
+ "metadata": {
36
+ "id": "ZzRNMT42Gw_p"
37
+ },
38
+ "outputs": [],
39
+ "source": [
40
+ "%cd /content\n",
41
+ "!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui\n",
42
+ "%cd stable-diffusion-webui\n",
43
+ "!git pull\n",
44
+ "!mkdir -p /content/stable-diffusion-webui/models/Stable-diffusion\n",
45
+ "%cd /content/stable-diffusion-webui/models/Stable-diffusion/\n",
46
+ "!apt install -y -qq aria2\n",
47
+ "!aria2c --summary-interval=10 -x 16 -s 16 --allow-overwrite=true -Z https://huggingface.co/JosephusCheung/ACertainModel/resolve/main/ACertainModel-half.ckpt\n",
48
+ "%cd /content\n",
49
+ "!aria2c --summary-interval=10 -x 16 -s 16 --allow-overwrite=true -Z https://huggingface.co/JosephusCheung/ACertainModel/resolve/main/animevae.pt"
50
+ ]
51
+ },
52
+ {
53
+ "cell_type": "markdown",
54
+ "metadata": {
55
+ "id": "xt8lbdmC04ox"
56
+ },
57
+ "source": [
58
+ "Launch web ui. You will get a link to nnn.gradio.app, follow it.\n",
59
+ "\n",
60
+ "Commandline arguments are:\n",
61
+ " - `--share` - create online gradio.app link\n",
62
+ " - `--gradio-debug` - print outputs to console\n",
63
+ " - `--gradio-auth me:qwerty` - add authentication to gradio: username me, password qwerty"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "execution_count": null,
69
+ "metadata": {
70
+ "colab": {
71
+ "base_uri": "https://localhost:8080/"
72
+ },
73
+ "id": "R-xAdMA5wxXd",
74
+ "outputId": "c3f7f6fe-7769-452d-9433-3023c156a244"
75
+ },
76
+ "outputs": [
77
+ {
78
+ "output_type": "stream",
79
+ "name": "stdout",
80
+ "text": [
81
+ "Interrupted with signal 2 in <frame at 0x7f1864c71cf0, file '/usr/local/lib/python3.8/dist-packages/gradio/blocks.py', line 1559, code block_thread>\n"
82
+ ]
83
+ }
84
+ ],
85
+ "source": [
86
+ "%cd /content/stable-diffusion-webui\n",
87
+ "\n",
88
+ "# hacks to load model in colab\n",
89
+ "!sed -i 's/map_location=\"cpu\"/map_location=\"cuda\"/g' /content/stable-diffusion-webui/modules/sd_models.py\n",
90
+ "\n",
91
+ "!pip install -U -qq pip\n",
92
+ "!pip install -qq -r requirements.txt\n",
93
+ "!pip install -qq -U --pre triton\n",
94
+ "!pip install -qq pytorch_lightning==1.7.7\n",
95
+ "!pip install https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.15/xformers-0.0.15.dev0+189828c.d20221207-cp38-cp38-linux_x86_64.whl\n",
96
+ "!echo \"\" > /tmp/requirements_empty.txt\n",
97
+ "!COMMANDLINE_ARGS=\"--xformers --share --gradio-debug --vae-path /content/animevae.pt\" REQS_FILE=\"/tmp/requirements_empty.txt\" python launch.py"
98
+ ]
99
+ },
100
+ {
101
+ "cell_type": "markdown",
102
+ "metadata": {
103
+ "id": "T3957x2AY7iP"
104
+ },
105
+ "source": [
106
+ "commands for ***after*** you have gotten done with a session\n",
107
+ "============================================================================"
108
+ ]
109
+ },
110
+ {
111
+ "cell_type": "markdown",
112
+ "metadata": {
113
+ "id": "aCtJffM2ZE06"
114
+ },
115
+ "source": [
116
+ "Zip images for downloading on local drive (click the folder icon on the left, the one below {x})"
117
+ ]
118
+ },
119
+ {
120
+ "cell_type": "code",
121
+ "execution_count": null,
122
+ "metadata": {
123
+ "id": "TmRqNyiAZCHu"
124
+ },
125
+ "outputs": [],
126
+ "source": [
127
+ "!zip -r /content/stable-diffusion-webui /content/stable-diffusion-webui/outputs "
128
+ ]
129
+ },
130
+ {
131
+ "cell_type": "markdown",
132
+ "metadata": {
133
+ "id": "tcslU-S2ZNr9"
134
+ },
135
+ "source": [
136
+ "Save images to Google Drive **Warning: this will cause google to scan your drive, so if you intend to use this and worry about that kind of stuff, probablly just set this up on a clean account that's just for this colab**"
137
+ ]
138
+ },
139
+ {
140
+ "cell_type": "code",
141
+ "execution_count": null,
142
+ "metadata": {
143
+ "id": "-N0lnu-TZOTW"
144
+ },
145
+ "outputs": [],
146
+ "source": [
147
+ "from google.colab import drive # type: ignore\n",
148
+ "\n",
149
+ "try:\n",
150
+ " drive_path = \"/content/drive\"\n",
151
+ " drive.mount(drive_path,force_remount=False)\n",
152
+ "except:\n",
153
+ " print(\"...error mounting drive or with drive path variables\")\n",
154
+ "\n",
155
+ "!cp -r \"/content/stable-diffusion-webui/outputs\" \"/content/drive/MyDrive\""
156
+ ]
157
+ }
158
+ ],
159
+ "metadata": {
160
+ "accelerator": "GPU",
161
+ "colab": {
162
+ "provenance": []
163
+ },
164
+ "gpuClass": "premium",
165
+ "kernelspec": {
166
+ "display_name": "Python 3",
167
+ "name": "python3"
168
+ },
169
+ "language_info": {
170
+ "name": "python"
171
+ }
172
+ },
173
+ "nbformat": 4,
174
+ "nbformat_minor": 0
175
+ }