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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"metadata": {},
|
| 6 |
+
"source": [
|
| 7 |
+
"# Dependencies"
|
| 8 |
+
]
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"cell_type": "code",
|
| 12 |
+
"execution_count": null,
|
| 13 |
+
"metadata": {},
|
| 14 |
+
"outputs": [],
|
| 15 |
+
"source": [
|
| 16 |
+
"# Install the dependencies\n",
|
| 17 |
+
"\n",
|
| 18 |
+
"force_reinstall= False\n",
|
| 19 |
+
"\n",
|
| 20 |
+
"# Set to true only if you want to install the dependencies again.\n",
|
| 21 |
+
"\n",
|
| 22 |
+
"#--------------------\n",
|
| 23 |
+
"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)"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"cell_type": "markdown",
|
| 28 |
+
"metadata": {},
|
| 29 |
+
"source": [
|
| 30 |
+
"# Install/Update AUTOMATIC1111 repo"
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"cell_type": "code",
|
| 35 |
+
"execution_count": null,
|
| 36 |
+
"metadata": {},
|
| 37 |
+
"outputs": [],
|
| 38 |
+
"source": [
|
| 39 |
+
"Huggingface_token_optional=\"\"\n",
|
| 40 |
+
"\n",
|
| 41 |
+
"# 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",
|
| 42 |
+
"\n",
|
| 43 |
+
"#--------------------\n",
|
| 44 |
+
"repo(Huggingface_token_optional)"
|
| 45 |
+
]
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"cell_type": "markdown",
|
| 49 |
+
"metadata": {},
|
| 50 |
+
"source": [
|
| 51 |
+
"# Model Download/Load"
|
| 52 |
+
]
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"cell_type": "code",
|
| 56 |
+
"execution_count": null,
|
| 57 |
+
"metadata": {},
|
| 58 |
+
"outputs": [],
|
| 59 |
+
"source": [
|
| 60 |
+
"Original_Model_Version = \"SDXL\"\n",
|
| 61 |
+
"\n",
|
| 62 |
+
"# Choices are \"SDXL\", \"v1.5\", \"v2-512\", \"v2-768\"\n",
|
| 63 |
+
"\n",
|
| 64 |
+
"#-------------- Or\n",
|
| 65 |
+
"\n",
|
| 66 |
+
"Path_to_MODEL = \"\"\n",
|
| 67 |
+
"\n",
|
| 68 |
+
"# Insert the full path of your trained model or to a folder containing multiple models.\n",
|
| 69 |
+
"\n",
|
| 70 |
+
"\n",
|
| 71 |
+
"MODEL_LINK = \"\"\n",
|
| 72 |
+
"\n",
|
| 73 |
+
"# A direct link to a Model or a shared gdrive link.\n",
|
| 74 |
+
"\n",
|
| 75 |
+
"\n",
|
| 76 |
+
"#--------------------\n",
|
| 77 |
+
"model=mdl(Original_Model_Version, Path_to_MODEL, MODEL_LINK)"
|
| 78 |
+
]
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"cell_type": "markdown",
|
| 82 |
+
"metadata": {},
|
| 83 |
+
"source": [
|
| 84 |
+
"# LoRA Download"
|
| 85 |
+
]
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"cell_type": "code",
|
| 89 |
+
"execution_count": null,
|
| 90 |
+
"metadata": {},
|
| 91 |
+
"outputs": [],
|
| 92 |
+
"source": [
|
| 93 |
+
"# Download/update ControlNet extension and its models.\n",
|
| 94 |
+
"\n",
|
| 95 |
+
"ControlNet_v1_Model = \"all\"\n",
|
| 96 |
+
"\n",
|
| 97 |
+
"# 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",
|
| 98 |
+
"\n",
|
| 99 |
+
"ControlNet_XL_Model = \"all\"\n",
|
| 100 |
+
"\n",
|
| 101 |
+
"# Choices are : none; all; 1: Canny; 2: Depth; 3: Sketch; 4: OpenPose; 5: Recolor\n",
|
| 102 |
+
"\n",
|
| 103 |
+
"#--------------------\n",
|
| 104 |
+
"CNet(ControlNet_v1_Model, ControlNet_XL_Model)"
|
| 105 |
+
]
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"cell_type": "markdown",
|
| 109 |
+
"metadata": {},
|
| 110 |
+
"source": [
|
| 111 |
+
"# Start Stable-Diffusion"
|
| 112 |
+
]
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"cell_type": "code",
|
| 116 |
+
"execution_count": null,
|
| 117 |
+
"metadata": {},
|
| 118 |
+
"outputs": [],
|
| 119 |
+
"source": [
|
| 120 |
+
"User = \"\"\n",
|
| 121 |
+
"\n",
|
| 122 |
+
"Password= \"\"\n",
|
| 123 |
+
"\n",
|
| 124 |
+
"# Add credentials to your Gradio interface (optional).\n",
|
| 125 |
+
"\n",
|
| 126 |
+
"#-----------------\n",
|
| 127 |
+
"configf=sd(User, Password, model) if 'model' in locals() else sd(User, Password, \"\");import gradio;gradio.close_all()\n",
|
| 128 |
+
"!python /workspace/sd/stable-diffusion-webui/webui.py $configf"
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
{
|
| 132 |
+
"cell_type": "markdown",
|
| 133 |
+
"metadata": {},
|
| 134 |
+
"source": [
|
| 135 |
+
"# Backup SD folder"
|
| 136 |
+
]
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
"cell_type": "code",
|
| 140 |
+
"execution_count": null,
|
| 141 |
+
"metadata": {},
|
| 142 |
+
"outputs": [],
|
| 143 |
+
"source": [
|
| 144 |
+
"# This will backup your sd folder -without the models- to your huggingface account, so you can restore it whenever you start an instance.\n",
|
| 145 |
+
"\n",
|
| 146 |
+
"Huggingface_Write_token=\"\"\n",
|
| 147 |
+
"\n",
|
| 148 |
+
"# Must be a WRITE token, get yours here : https://huggingface.co/settings/tokens\n",
|
| 149 |
+
"\n",
|
| 150 |
+
"#--------------------\n",
|
| 151 |
+
"save(Huggingface_Write_token)"
|
| 152 |
+
]
|
| 153 |
+
}
|
| 154 |
+
],
|
| 155 |
+
"metadata": {
|
| 156 |
+
"language_info": {
|
| 157 |
+
"name": "python"
|
| 158 |
+
}
|
| 159 |
+
},
|
| 160 |
+
"nbformat": 4,
|
| 161 |
+
"nbformat_minor": 2
|
| 162 |
+
}
|
Notebooks/SDXL-LoRA-RNPD.ipynb
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": null,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"# Dependencies"
|
| 10 |
+
]
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"cell_type": "code",
|
| 14 |
+
"execution_count": null,
|
| 15 |
+
"metadata": {},
|
| 16 |
+
"outputs": [],
|
| 17 |
+
"source": [
|
| 18 |
+
"# Install the dependencies\n",
|
| 19 |
+
"\n",
|
| 20 |
+
"force_reinstall= False\n",
|
| 21 |
+
"\n",
|
| 22 |
+
"# Set to true only if you want to install the dependencies again.\n",
|
| 23 |
+
"\n",
|
| 24 |
+
"#--------------------\n",
|
| 25 |
+
"with open('/dev/null', 'w') as devnull:import requests, os, time, importlib;open('/workspace/sdxllorarunpod.py', 'wb').write(requests.get('https://huggingface.co/datasets/TheLastBen/RNPD/raw/main/Scripts/sdxllorarunpod.py').content);os.chdir('/workspace');import sdxllorarunpod;importlib.reload(sdxllorarunpod);from sdxllorarunpod import *;restored=False;restoreda=False;Deps(force_reinstall)"
|
| 26 |
+
]
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"cell_type": "markdown",
|
| 30 |
+
"metadata": {},
|
| 31 |
+
"source": [
|
| 32 |
+
"# Download the model"
|
| 33 |
+
]
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"cell_type": "code",
|
| 37 |
+
"execution_count": null,
|
| 38 |
+
"metadata": {},
|
| 39 |
+
"outputs": [],
|
| 40 |
+
"source": [
|
| 41 |
+
"# Run the cell to download the model\n",
|
| 42 |
+
"\n",
|
| 43 |
+
"#-------------\n",
|
| 44 |
+
"MODEL_NAMExl=dls_xlf(\"\", \"\", \"\")"
|
| 45 |
+
]
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"cell_type": "markdown",
|
| 49 |
+
"metadata": {},
|
| 50 |
+
"source": [
|
| 51 |
+
"# Create/Load a Session"
|
| 52 |
+
]
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"cell_type": "code",
|
| 56 |
+
"execution_count": null,
|
| 57 |
+
"metadata": {},
|
| 58 |
+
"outputs": [],
|
| 59 |
+
"source": [
|
| 60 |
+
"Session_Name = \"Example-Session\"\n",
|
| 61 |
+
"\n",
|
| 62 |
+
"# Enter the session name, it if it exists, it will load it, otherwise it'll create an new session.\n",
|
| 63 |
+
"\n",
|
| 64 |
+
"#-----------------\n",
|
| 65 |
+
"[WORKSPACE, Session_Name, INSTANCE_NAME, OUTPUT_DIR, SESSION_DIR, INSTANCE_DIR, CAPTIONS_DIR, MDLPTH, MODEL_NAMExl]=sess_xl(Session_Name, MODEL_NAMExl if 'MODEL_NAMExl' in locals() else \"\")"
|
| 66 |
+
]
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"cell_type": "markdown",
|
| 70 |
+
"metadata": {},
|
| 71 |
+
"source": [
|
| 72 |
+
"# Instance Images\n",
|
| 73 |
+
"The most important step is to rename the instance pictures to one unique unknown identifier"
|
| 74 |
+
]
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"cell_type": "code",
|
| 78 |
+
"execution_count": null,
|
| 79 |
+
"metadata": {},
|
| 80 |
+
"outputs": [],
|
| 81 |
+
"source": [
|
| 82 |
+
"Remove_existing_instance_images= True\n",
|
| 83 |
+
"\n",
|
| 84 |
+
"# Set to False to keep the existing instance images if any.\n",
|
| 85 |
+
"\n",
|
| 86 |
+
"\n",
|
| 87 |
+
"IMAGES_FOLDER_OPTIONAL= \"\"\n",
|
| 88 |
+
"\n",
|
| 89 |
+
"# If you prefer to specify directly the folder of the pictures instead of uploading, this will add the pictures to the existing (if any) instance images. Leave EMPTY to upload.\n",
|
| 90 |
+
"\n",
|
| 91 |
+
"\n",
|
| 92 |
+
"Smart_crop_images = True\n",
|
| 93 |
+
"\n",
|
| 94 |
+
"# Automatically crop your input images.\n",
|
| 95 |
+
"\n",
|
| 96 |
+
"Crop_size = 1024\n",
|
| 97 |
+
"\n",
|
| 98 |
+
"# 1024 is the native resolution\n",
|
| 99 |
+
"\n",
|
| 100 |
+
"\n",
|
| 101 |
+
"#--------------------------------------------\n",
|
| 102 |
+
"\n",
|
| 103 |
+
"# Disabled when \"Smart_crop_images\" is set to \"True\"\n",
|
| 104 |
+
"\n",
|
| 105 |
+
"Resize_to_1024_and_keep_aspect_ratio = False\n",
|
| 106 |
+
"\n",
|
| 107 |
+
"# Will resize the smallest dimension to 1024 without cropping while keeping the aspect ratio (make sure you have enough VRAM)\n",
|
| 108 |
+
"\n",
|
| 109 |
+
"\n",
|
| 110 |
+
"# Check out this example for naming : https://i.imgur.com/d2lD3rz.jpeg\n",
|
| 111 |
+
"\n",
|
| 112 |
+
"#-----------------\n",
|
| 113 |
+
"uplder(Remove_existing_instance_images, Smart_crop_images, Crop_size, Resize_to_1024_and_keep_aspect_ratio, IMAGES_FOLDER_OPTIONAL, INSTANCE_DIR, CAPTIONS_DIR)"
|
| 114 |
+
]
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"cell_type": "markdown",
|
| 118 |
+
"metadata": {},
|
| 119 |
+
"source": [
|
| 120 |
+
"# Manual Captioning"
|
| 121 |
+
]
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"cell_type": "code",
|
| 125 |
+
"execution_count": null,
|
| 126 |
+
"metadata": {},
|
| 127 |
+
"outputs": [],
|
| 128 |
+
"source": [
|
| 129 |
+
"# Open a tool to manually caption the instance images.\n",
|
| 130 |
+
"\n",
|
| 131 |
+
"#-----------------\n",
|
| 132 |
+
"caption(CAPTIONS_DIR, INSTANCE_DIR)"
|
| 133 |
+
]
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"cell_type": "markdown",
|
| 137 |
+
"metadata": {},
|
| 138 |
+
"source": [
|
| 139 |
+
"# Train LoRA"
|
| 140 |
+
]
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"cell_type": "code",
|
| 144 |
+
"execution_count": null,
|
| 145 |
+
"metadata": {},
|
| 146 |
+
"outputs": [],
|
| 147 |
+
"source": [
|
| 148 |
+
"# Training Settings\n",
|
| 149 |
+
"\n",
|
| 150 |
+
"# Epoch = Number of steps/images\n",
|
| 151 |
+
"\n",
|
| 152 |
+
"\n",
|
| 153 |
+
"UNet_Training_Epochs= 120\n",
|
| 154 |
+
"\n",
|
| 155 |
+
"UNet_Learning_Rate= \"1e-6\"\n",
|
| 156 |
+
"\n",
|
| 157 |
+
"# Keep the learning rate between 1e-6 and 3e-6\n",
|
| 158 |
+
"\n",
|
| 159 |
+
"\n",
|
| 160 |
+
"Text_Encoder_Training_Epochs= 40\n",
|
| 161 |
+
"\n",
|
| 162 |
+
"# The training is highly affected by this value, a total of 300 steps (not epochs) is enough, set to 0 if enhancing existing concepts\n",
|
| 163 |
+
"\n",
|
| 164 |
+
"Text_Encoder_Learning_Rate= \"1e-6\"\n",
|
| 165 |
+
"\n",
|
| 166 |
+
"# Keep the learning rate at 1e-6 or lower\n",
|
| 167 |
+
"\n",
|
| 168 |
+
"\n",
|
| 169 |
+
"External_Captions= False\n",
|
| 170 |
+
"\n",
|
| 171 |
+
"# Load the captions from a text file for each instance image\n",
|
| 172 |
+
"\n",
|
| 173 |
+
"\n",
|
| 174 |
+
"LoRA_Dim = 64\n",
|
| 175 |
+
"\n",
|
| 176 |
+
"# Dimension of the LoRa model, between 64 and 128 is good enough\n",
|
| 177 |
+
"\n",
|
| 178 |
+
"\n",
|
| 179 |
+
"Save_VRAM = False\n",
|
| 180 |
+
"\n",
|
| 181 |
+
"# Use as low as 10GB VRAM with Dim = 64\n",
|
| 182 |
+
"\n",
|
| 183 |
+
"\n",
|
| 184 |
+
"Intermediary_Save_Epoch = \"[30,60]\"\n",
|
| 185 |
+
"\n",
|
| 186 |
+
"# [30,60] means it will save intermediary models at epoch 30 and epoch 60, you can add as many as you want like [30,60,80,100]\n",
|
| 187 |
+
"\n",
|
| 188 |
+
"\n",
|
| 189 |
+
"#-----------------\n",
|
| 190 |
+
"dbtrainxl(UNet_Training_Epochs, Text_Encoder_Training_Epochs, UNet_Learning_Rate, Text_Encoder_Learning_Rate, LoRA_Dim, False, 1024, MODEL_NAMExl, SESSION_DIR, INSTANCE_DIR, CAPTIONS_DIR, External_Captions, INSTANCE_NAME, Session_Name, OUTPUT_DIR, 0, Save_VRAM, Intermediary_Save_Epoch)"
|
| 191 |
+
]
|
| 192 |
+
},
|
| 193 |
+
{
|
| 194 |
+
"cell_type": "markdown",
|
| 195 |
+
"metadata": {},
|
| 196 |
+
"source": [
|
| 197 |
+
"# Test the Trained Model"
|
| 198 |
+
]
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"cell_type": "markdown",
|
| 202 |
+
"metadata": {},
|
| 203 |
+
"source": [
|
| 204 |
+
"# ComfyUI"
|
| 205 |
+
]
|
| 206 |
+
},
|
| 207 |
+
{
|
| 208 |
+
"cell_type": "code",
|
| 209 |
+
"execution_count": null,
|
| 210 |
+
"metadata": {},
|
| 211 |
+
"outputs": [],
|
| 212 |
+
"source": [
|
| 213 |
+
"Args=\"--listen --port 3000 --preview-method auto\"\n",
|
| 214 |
+
"\n",
|
| 215 |
+
"\n",
|
| 216 |
+
"Huggingface_token_optional= \"\"\n",
|
| 217 |
+
"\n",
|
| 218 |
+
"# Restore your backed-up Comfy folder by entering your huggingface token, leave it empty to start fresh or continue with the existing sd folder (if any).\n",
|
| 219 |
+
"\n",
|
| 220 |
+
"#--------------------\n",
|
| 221 |
+
"restored=sdcmff(Huggingface_token_optional, MDLPTH, restored)\n",
|
| 222 |
+
"!python /workspace/ComfyUI/main.py $Args"
|
| 223 |
+
]
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"cell_type": "markdown",
|
| 227 |
+
"metadata": {},
|
| 228 |
+
"source": [
|
| 229 |
+
"# A1111"
|
| 230 |
+
]
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"cell_type": "code",
|
| 234 |
+
"execution_count": null,
|
| 235 |
+
"metadata": {},
|
| 236 |
+
"outputs": [],
|
| 237 |
+
"source": [
|
| 238 |
+
"User = \"\"\n",
|
| 239 |
+
"\n",
|
| 240 |
+
"Password= \"\"\n",
|
| 241 |
+
"\n",
|
| 242 |
+
"# Add credentials to your Gradio interface (optional).\n",
|
| 243 |
+
"\n",
|
| 244 |
+
"\n",
|
| 245 |
+
"Huggingface_token_optional= \"\"\n",
|
| 246 |
+
"\n",
|
| 247 |
+
"# 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",
|
| 248 |
+
"\n",
|
| 249 |
+
"#-----------------\n",
|
| 250 |
+
"configf, restoreda=test(MDLPTH, User, Password, Huggingface_token_optional, restoreda)\n",
|
| 251 |
+
"!python /workspace/sd/stable-diffusion-webui/webui.py $configf"
|
| 252 |
+
]
|
| 253 |
+
},
|
| 254 |
+
{
|
| 255 |
+
"cell_type": "markdown",
|
| 256 |
+
"metadata": {},
|
| 257 |
+
"source": [
|
| 258 |
+
"# Free up space"
|
| 259 |
+
]
|
| 260 |
+
},
|
| 261 |
+
{
|
| 262 |
+
"cell_type": "code",
|
| 263 |
+
"execution_count": null,
|
| 264 |
+
"metadata": {},
|
| 265 |
+
"outputs": [],
|
| 266 |
+
"source": [
|
| 267 |
+
"# Display a list of sessions from which you can remove any session you don't need anymore\n",
|
| 268 |
+
"\n",
|
| 269 |
+
"#-------------------------\n",
|
| 270 |
+
"clean()"
|
| 271 |
+
]
|
| 272 |
+
}
|
| 273 |
+
],
|
| 274 |
+
"metadata": {
|
| 275 |
+
"language_info": {
|
| 276 |
+
"name": "python"
|
| 277 |
+
}
|
| 278 |
+
},
|
| 279 |
+
"nbformat": 4,
|
| 280 |
+
"nbformat_minor": 2
|
| 281 |
+
}
|