File size: 4,198 Bytes
e1a8883
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Dependencies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "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/runpod_server.py', 'wb').write(requests.get('https://huggingface.co/datasets/TheLastBen/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",
   "metadata": {},
   "source": [
    "# Install/Update AUTOMATIC1111 repo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "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",
   "metadata": {},
   "source": [
    "# Model Download/Load"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "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",
   "metadata": {},
   "source": [
    "# LoRA Download"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Download/update ControlNet extension and its models.\n",
    "\n",
    "ControlNet_v1_Model = \"all\"\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 = \"all\"\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)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Start Stable-Diffusion"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "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"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Backup SD folder"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# This will backup your sd folder -without the models- to your huggingface account, so you can restore it whenever you start an instance.\n",
    "\n",
    "Huggingface_Write_token=\"\"\n",
    "\n",
    "# Must be a WRITE token, get yours here : https://huggingface.co/settings/tokens\n",
    "\n",
    "#--------------------\n",
    "save(Huggingface_Write_token)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}