File size: 6,633 Bytes
f95b529
 
 
 
 
 
 
ed33666
f95b529
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b4737f9
f95b529
 
 
 
 
 
 
ed33666
f95b529
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed33666
f95b529
 
 
 
 
 
 
 
 
 
 
ed33666
f95b529
ed33666
f95b529
 
67adc01
 
 
b2c325e
 
 
 
 
 
 
ed33666
b2c325e
 
 
 
 
 
 
 
 
 
 
ed33666
b2c325e
ed33666
b2c325e
 
371ce27
 
 
f95b529
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1884af4
b9ba634
67adc01
 
b9ba634
 
67adc01
b9ba634
f95b529
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9e42bc1e-9825-4587-b533-c74607b1a377",
   "metadata": {},
   "source": [
    "## A1111 Runpod Notebook || Курс по нейронным сетям. Раздел Stable Diffusion"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "813d4d10-e6d1-42b1-ae37-ae41ad47e595",
   "metadata": {},
   "source": [
    "# Dependencies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bfd51417-bba8-41fb-ae56-c6555e2a0465",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# Install the dependencies\n",
    "\n",
    "force_reinstall= False\n",
    "\n",
    "# Set to true only if you want to install the dependencies again.\n",
    "\n",
    "#--------------------\n",
    "with open('/dev/null', 'w') as devnull:import requests, os, time, importlib;open('/workspace/mainrunpodA1111.py', 'wb').write(requests.get('https://huggingface.co/spaces/stlaurentjr/RNPD/raw/main/scripts/mainrunpodA1111.py').content);os.chdir('/workspace');time.sleep(2);import mainrunpodA1111;importlib.reload(mainrunpodA1111);from mainrunpodA1111 import *;Deps(force_reinstall)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "76ae705b-15e3-47b9-b226-52e71ef1737d",
   "metadata": {},
   "source": [
    "# Установка/Обновление AUTOMATIC1111 repo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "652afdee-64a4-483b-926a-094c884dd260",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "Huggingface_token_optional=\"\"\n",
    "\n",
    "# Restore your backed-up SD folder by entering your huggingface token, leave it empty to start fresh or continue with the existing sd folder (if any).\n",
    "\n",
    "#--------------------\n",
    "repo(Huggingface_token_optional)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca3a26bb-8625-42b9-9e2f-e55939a536ef",
   "metadata": {},
   "source": [
    "# Model Download/Load"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1e5dbca1-5ee2-41db-be94-9d2919dc3aef",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "Original_Model_Version = \"SDXL\"\n",
    "\n",
    "# Choices are \"SDXL\", \"v1.5\", \"v2-512\", \"v2-768\"\n",
    "\n",
    "#-------------- Or\n",
    "\n",
    "Path_to_MODEL = \"\"\n",
    "\n",
    "# Insert the full path of your trained model or to a folder containing multiple models.\n",
    "\n",
    "\n",
    "MODEL_LINK = \"\"\n",
    "\n",
    "# A direct link to a Model or a shared gdrive link.\n",
    "\n",
    "\n",
    "#--------------------\n",
    "model=mdl(Original_Model_Version, Path_to_MODEL, MODEL_LINK)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c578da4-3164-411c-9255-226ce8157545",
   "metadata": {},
   "source": [
    "# Загрузка Checkpoints"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a0f3dfba-4127-4619-8bb1-4589e84a5fe4",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "model_LINK = \"\"\n",
    "\n",
    "# Downlad the Checkpoints model directly to A1111 Checkpoints folder\n",
    "\n",
    "#--------------------\n",
    "# modeldwn(\"https://drive.google.com/file/d/1O0ez3jYp_u0DLcdsQ9EsIHSQZciOakWn\")\n",
    "# modeldwn(\"https://drive.google.com/file/d/1ldaJzlooJ9CYm96s9FOirpiUH4GU8_jd\")\n",
    "# modeldwn(\"https://drive.google.com/file/d/1nNERcpaW09L4HlqEnsN9JpDpQXU9EOfB\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c578da4-3164-411c-9255-226ce8157545",
   "metadata": {},
   "source": [
    "# Загрузка LoRA"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a0f3dfba-4127-4619-8bb1-4589e84a5fe4",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "LoRA_LINK = \"\"\n",
    "\n",
    "# Downlad the LoRA model directly to A1111 LoRA folder\n",
    "\n",
    "#--------------------\n",
    "# loradwn(\"https://drive.google.com/file/d/1kkhb7J8nlJMI7GPd4QCrKxVh6emv94at\")\n",
    "# loradwn(\"https://drive.google.com/file/d/1lqJOnwnPu6IqrkvQEFM1TPW8osG-J5kK\")\n",
    "# loradwn(\"https://drive.google.com/file/d/1g8dJX-5XlvHZJGJ_Ys_xyfbuQnb6T7oz\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "02706779-fec8-4661-8589-0e28f0d4fb3b",
   "metadata": {},
   "source": [
    "# ControlNet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "222cdfd7-38f1-422b-81a2-963a2a8d504b",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# Download/update ControlNet extension and its models.\n",
    "\n",
    "ControlNet_v1_Model = \"none\"\n",
    "\n",
    "# Choices are : none; all; 1: Canny; 2: Depth; 3: Lineart; 4: MLSD; 5: Normal; 6: OpenPose; 7: Scribble; 8: Seg; 9: ip2p; 10:Shuffle; 11: Inpaint; 12: Softedge; 13: Lineart_Anime; 14: Tile; 15: T2iadapter_Models\n",
    "\n",
    "ControlNet_XL_Model = \"none\"\n",
    "\n",
    "# Choices are : none; all; 1: Canny; 2: Depth; 3: Sketch; 4: OpenPose; 5: Recolor\n",
    "\n",
    "#--------------------\n",
    "CNet(ControlNet_v1_Model, ControlNet_XL_Model)\n",
    "CNet(\"1\", ControlNet_XL_Model)\n",
    "# CNet(\"2\", ControlNet_XL_Model)\n",
    "# CNet(\"3\", ControlNet_XL_Model)\n",
    "CNet(\"6\", ControlNet_XL_Model)\n",
    "CNet(\"11\", ControlNet_XL_Model)\n",
    "CNet(\"14\", ControlNet_XL_Model)\n",
    "CNet(\"15\", ControlNet_XL_Model)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48184b7b-9cd0-4f04-9c85-4464031d6596",
   "metadata": {
    "tags": []
   },
   "source": [
    "# Start Stable-Diffusion"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e73f76a6-01a4-44d0-87a7-77fed9c9b77c",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "User = \"\"\n",
    "\n",
    "Password= \"\"\n",
    "\n",
    "# Add credentials to your Gradio interface (optional).\n",
    "\n",
    "#-----------------\n",
    "configf=sd(User, Password, model) if 'model' in locals() else sd(User, Password, \"\");import gradio;gradio.close_all()\n",
    "!python /workspace/sd/stable-diffusion-webui/webui.py $configf"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}