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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"nbformat": 4,
|
| 3 |
+
"nbformat_minor": 0,
|
| 4 |
+
"metadata": {
|
| 5 |
+
"colab": {
|
| 6 |
+
"provenance": [],
|
| 7 |
+
"gpuType": "T4",
|
| 8 |
+
"collapsed_sections": [
|
| 9 |
+
"UdQ1VHdI8lCf"
|
| 10 |
+
]
|
| 11 |
+
},
|
| 12 |
+
"kernelspec": {
|
| 13 |
+
"name": "python3",
|
| 14 |
+
"display_name": "Python 3"
|
| 15 |
+
},
|
| 16 |
+
"language_info": {
|
| 17 |
+
"name": "python"
|
| 18 |
+
},
|
| 19 |
+
"accelerator": "GPU"
|
| 20 |
+
},
|
| 21 |
+
"cells": [
|
| 22 |
+
{
|
| 23 |
+
"cell_type": "markdown",
|
| 24 |
+
"source": [
|
| 25 |
+
"# Colab for roop-unleashed - Gradio version\n",
|
| 26 |
+
"https://github.com/C0untFloyd/roop-unleashed\n"
|
| 27 |
+
],
|
| 28 |
+
"metadata": {
|
| 29 |
+
"id": "G9BdiCppV6AS"
|
| 30 |
+
}
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"cell_type": "markdown",
|
| 34 |
+
"source": [
|
| 35 |
+
"Install CUDA V11.8 on Google Cloud Compute"
|
| 36 |
+
],
|
| 37 |
+
"metadata": {
|
| 38 |
+
"id": "CanIXgLJgaOj"
|
| 39 |
+
}
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"cell_type": "code",
|
| 43 |
+
"source": [
|
| 44 |
+
"!apt-get -y update\n",
|
| 45 |
+
"!apt-get -y install cuda-toolkit-11-8\n",
|
| 46 |
+
"import os\n",
|
| 47 |
+
"os.environ[\"LD_LIBRARY_PATH\"] += \":\" + \"/usr/local/cuda-11/lib64\"\n",
|
| 48 |
+
"os.environ[\"LD_LIBRARY_PATH\"] += \":\" + \"/usr/local/cuda-11.8/lib64\""
|
| 49 |
+
],
|
| 50 |
+
"metadata": {
|
| 51 |
+
"id": "96GE4UgYg3Ej"
|
| 52 |
+
},
|
| 53 |
+
"execution_count": null,
|
| 54 |
+
"outputs": []
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"cell_type": "markdown",
|
| 58 |
+
"source": [
|
| 59 |
+
"Installing & preparing requirements"
|
| 60 |
+
],
|
| 61 |
+
"metadata": {
|
| 62 |
+
"id": "0ZYRNb0AWLLW"
|
| 63 |
+
}
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"cell_type": "code",
|
| 67 |
+
"execution_count": null,
|
| 68 |
+
"metadata": {
|
| 69 |
+
"id": "t1yPuhdySqCq"
|
| 70 |
+
},
|
| 71 |
+
"outputs": [],
|
| 72 |
+
"source": [
|
| 73 |
+
"!git clone https://github.com/C0untFloyd/roop-unleashed.git\n",
|
| 74 |
+
"%cd roop-unleashed\n",
|
| 75 |
+
"!mv config_colab.yaml config.yaml\n",
|
| 76 |
+
"!pip install pip install -r requirements.txt"
|
| 77 |
+
]
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"cell_type": "markdown",
|
| 81 |
+
"source": [
|
| 82 |
+
"Running roop-unleashed with default config"
|
| 83 |
+
],
|
| 84 |
+
"metadata": {
|
| 85 |
+
"id": "u_4JQiSlV9Fi"
|
| 86 |
+
}
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"cell_type": "code",
|
| 90 |
+
"source": [
|
| 91 |
+
"!python run.py"
|
| 92 |
+
],
|
| 93 |
+
"metadata": {
|
| 94 |
+
"id": "Is6U2huqSzLE"
|
| 95 |
+
},
|
| 96 |
+
"execution_count": null,
|
| 97 |
+
"outputs": []
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"cell_type": "markdown",
|
| 101 |
+
"source": [
|
| 102 |
+
"### Download generated images folder\n",
|
| 103 |
+
"(only needed if you want to zip the generated output)"
|
| 104 |
+
],
|
| 105 |
+
"metadata": {
|
| 106 |
+
"id": "UdQ1VHdI8lCf"
|
| 107 |
+
}
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"cell_type": "code",
|
| 111 |
+
"source": [
|
| 112 |
+
"import shutil\n",
|
| 113 |
+
"import os\n",
|
| 114 |
+
"from google.colab import files\n",
|
| 115 |
+
"\n",
|
| 116 |
+
"def zip_directory(directory_path, zip_path):\n",
|
| 117 |
+
" shutil.make_archive(zip_path, 'zip', directory_path)\n",
|
| 118 |
+
"\n",
|
| 119 |
+
"# Set the directory path you want to download\n",
|
| 120 |
+
"directory_path = '/content/roop-unleashed/output'\n",
|
| 121 |
+
"\n",
|
| 122 |
+
"# Set the zip file name\n",
|
| 123 |
+
"zip_filename = 'fake_output.zip'\n",
|
| 124 |
+
"\n",
|
| 125 |
+
"# Zip the directory\n",
|
| 126 |
+
"zip_directory(directory_path, zip_filename)\n",
|
| 127 |
+
"\n",
|
| 128 |
+
"# Download the zip file\n",
|
| 129 |
+
"files.download(zip_filename+'.zip')\n"
|
| 130 |
+
],
|
| 131 |
+
"metadata": {
|
| 132 |
+
"colab": {
|
| 133 |
+
"base_uri": "https://localhost:8080/",
|
| 134 |
+
"height": 17
|
| 135 |
+
},
|
| 136 |
+
"id": "oYjWveAmw10X",
|
| 137 |
+
"outputId": "5b4c3650-f951-434a-c650-5525a8a70c1e"
|
| 138 |
+
},
|
| 139 |
+
"execution_count": null,
|
| 140 |
+
"outputs": [
|
| 141 |
+
{
|
| 142 |
+
"output_type": "display_data",
|
| 143 |
+
"data": {
|
| 144 |
+
"text/plain": [
|
| 145 |
+
"<IPython.core.display.Javascript object>"
|
| 146 |
+
],
|
| 147 |
+
"application/javascript": [
|
| 148 |
+
"\n",
|
| 149 |
+
" async function download(id, filename, size) {\n",
|
| 150 |
+
" if (!google.colab.kernel.accessAllowed) {\n",
|
| 151 |
+
" return;\n",
|
| 152 |
+
" }\n",
|
| 153 |
+
" const div = document.createElement('div');\n",
|
| 154 |
+
" const label = document.createElement('label');\n",
|
| 155 |
+
" label.textContent = `Downloading \"${filename}\": `;\n",
|
| 156 |
+
" div.appendChild(label);\n",
|
| 157 |
+
" const progress = document.createElement('progress');\n",
|
| 158 |
+
" progress.max = size;\n",
|
| 159 |
+
" div.appendChild(progress);\n",
|
| 160 |
+
" document.body.appendChild(div);\n",
|
| 161 |
+
"\n",
|
| 162 |
+
" const buffers = [];\n",
|
| 163 |
+
" let downloaded = 0;\n",
|
| 164 |
+
"\n",
|
| 165 |
+
" const channel = await google.colab.kernel.comms.open(id);\n",
|
| 166 |
+
" // Send a message to notify the kernel that we're ready.\n",
|
| 167 |
+
" channel.send({})\n",
|
| 168 |
+
"\n",
|
| 169 |
+
" for await (const message of channel.messages) {\n",
|
| 170 |
+
" // Send a message to notify the kernel that we're ready.\n",
|
| 171 |
+
" channel.send({})\n",
|
| 172 |
+
" if (message.buffers) {\n",
|
| 173 |
+
" for (const buffer of message.buffers) {\n",
|
| 174 |
+
" buffers.push(buffer);\n",
|
| 175 |
+
" downloaded += buffer.byteLength;\n",
|
| 176 |
+
" progress.value = downloaded;\n",
|
| 177 |
+
" }\n",
|
| 178 |
+
" }\n",
|
| 179 |
+
" }\n",
|
| 180 |
+
" const blob = new Blob(buffers, {type: 'application/binary'});\n",
|
| 181 |
+
" const a = document.createElement('a');\n",
|
| 182 |
+
" a.href = window.URL.createObjectURL(blob);\n",
|
| 183 |
+
" a.download = filename;\n",
|
| 184 |
+
" div.appendChild(a);\n",
|
| 185 |
+
" a.click();\n",
|
| 186 |
+
" div.remove();\n",
|
| 187 |
+
" }\n",
|
| 188 |
+
" "
|
| 189 |
+
]
|
| 190 |
+
},
|
| 191 |
+
"metadata": {}
|
| 192 |
+
},
|
| 193 |
+
{
|
| 194 |
+
"output_type": "display_data",
|
| 195 |
+
"data": {
|
| 196 |
+
"text/plain": [
|
| 197 |
+
"<IPython.core.display.Javascript object>"
|
| 198 |
+
],
|
| 199 |
+
"application/javascript": [
|
| 200 |
+
"download(\"download_789eab11-93d2-4880-adf3-6aceee0cc5f9\", \"fake_output.zip.zip\", 80125)"
|
| 201 |
+
]
|
| 202 |
+
},
|
| 203 |
+
"metadata": {}
|
| 204 |
+
}
|
| 205 |
+
]
|
| 206 |
+
}
|
| 207 |
+
]
|
| 208 |
+
}
|