File size: 5,953 Bytes
3362754 |
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 |
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4",
"collapsed_sections": [
"UdQ1VHdI8lCf"
],
"toc_visible": true,
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/C0untFloyd/roop-unleashed/blob/gradio/roop-unleashed.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"# Colab for roop-unleashed - Gradio version\n",
"https://github.com/C0untFloyd/roop-unleashed\n"
],
"metadata": {
"id": "G9BdiCppV6AS"
}
},
{
"cell_type": "markdown",
"source": [
"Installing & preparing requirements"
],
"metadata": {
"id": "0ZYRNb0AWLLW"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "t1yPuhdySqCq"
},
"outputs": [],
"source": [
"!git clone -b gradio --single-branch https://github.com/C0untFloyd/roop-unleashed.git\n",
"%cd roop-unleashed\n",
"!pip install pip install -r requirements.txt"
]
},
{
"cell_type": "markdown",
"source": [
"Running roop-unleashed with GPU Support"
],
"metadata": {
"id": "u_4JQiSlV9Fi"
}
},
{
"cell_type": "code",
"source": [
"!python run.py --execution-provider cuda"
],
"metadata": {
"id": "Is6U2huqSzLE"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"### Download generated images folder"
],
"metadata": {
"id": "UdQ1VHdI8lCf"
}
},
{
"cell_type": "code",
"source": [
"import shutil\n",
"import os\n",
"from google.colab import files\n",
"\n",
"def zip_directory(directory_path, zip_path):\n",
" shutil.make_archive(zip_path, 'zip', directory_path)\n",
"\n",
"# Set the directory path you want to download\n",
"directory_path = '/content/roop-unleashed/output'\n",
"\n",
"# Set the zip file name\n",
"zip_filename = 'fake_output.zip'\n",
"\n",
"# Zip the directory\n",
"zip_directory(directory_path, zip_filename)\n",
"\n",
"# Download the zip file\n",
"files.download(zip_filename+'.zip')\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 17
},
"id": "oYjWveAmw10X",
"outputId": "5b4c3650-f951-434a-c650-5525a8a70c1e"
},
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.Javascript object>"
],
"application/javascript": [
"\n",
" async function download(id, filename, size) {\n",
" if (!google.colab.kernel.accessAllowed) {\n",
" return;\n",
" }\n",
" const div = document.createElement('div');\n",
" const label = document.createElement('label');\n",
" label.textContent = `Downloading \"${filename}\": `;\n",
" div.appendChild(label);\n",
" const progress = document.createElement('progress');\n",
" progress.max = size;\n",
" div.appendChild(progress);\n",
" document.body.appendChild(div);\n",
"\n",
" const buffers = [];\n",
" let downloaded = 0;\n",
"\n",
" const channel = await google.colab.kernel.comms.open(id);\n",
" // Send a message to notify the kernel that we're ready.\n",
" channel.send({})\n",
"\n",
" for await (const message of channel.messages) {\n",
" // Send a message to notify the kernel that we're ready.\n",
" channel.send({})\n",
" if (message.buffers) {\n",
" for (const buffer of message.buffers) {\n",
" buffers.push(buffer);\n",
" downloaded += buffer.byteLength;\n",
" progress.value = downloaded;\n",
" }\n",
" }\n",
" }\n",
" const blob = new Blob(buffers, {type: 'application/binary'});\n",
" const a = document.createElement('a');\n",
" a.href = window.URL.createObjectURL(blob);\n",
" a.download = filename;\n",
" div.appendChild(a);\n",
" a.click();\n",
" div.remove();\n",
" }\n",
" "
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.core.display.Javascript object>"
],
"application/javascript": [
"download(\"download_789eab11-93d2-4880-adf3-6aceee0cc5f9\", \"fake_output.zip.zip\", 80125)"
]
},
"metadata": {}
}
]
}
]
} |