Spaces:
Running
Running
File size: 5,577 Bytes
6ccea25 |
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 |
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "G9BdiCppV6AS"
},
"source": [
"# Colab for roop-unleashed - Gradio version\n",
"https://github.com/C0untFloyd/roop-unleashed\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "CanIXgLJgaOj"
},
"source": [
"Install CUDA 12.6 on Google Cloud Compute\n",
"(currently unnecessary because the latest 12.x should be already installed)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "96GE4UgYg3Ej"
},
"outputs": [],
"source": [
"# don't run this cell if you know that there is at least Cuda 12.4 installed\n",
"!apt-get -y update\n",
"!apt-get -y install cuda-toolkit-12-6\n",
"import os\n",
"os.environ[\"LD_LIBRARY_PATH\"] += \":\" + \"/usr/local/cuda-12/lib64\"\n",
"os.environ[\"LD_LIBRARY_PATH\"] += \":\" + \"/usr/local/cuda-12.6/lib64\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0ZYRNb0AWLLW"
},
"source": [
"Installing & preparing requirements"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "t1yPuhdySqCq"
},
"outputs": [],
"source": [
"!git clone https://github.com/C0untFloyd/roop-unleashed.git\n",
"%cd roop-unleashed\n",
"!mv config_colab.yaml config.yaml\n",
"!pip install -r requirements.txt"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "u_4JQiSlV9Fi"
},
"source": [
"Running roop-unleashed with default config"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Is6U2huqSzLE"
},
"outputs": [],
"source": [
"!python run.py"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "UdQ1VHdI8lCf"
},
"source": [
"### Download generated images folder\n",
"(only needed if you want to zip the generated output)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 17
},
"id": "oYjWveAmw10X",
"outputId": "5b4c3650-f951-434a-c650-5525a8a70c1e"
},
"outputs": [
{
"data": {
"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 ",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": "download(\"download_789eab11-93d2-4880-adf3-6aceee0cc5f9\", \"fake_output.zip.zip\", 80125)",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"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": {
"accelerator": "GPU",
"colab": {
"collapsed_sections": [
"UdQ1VHdI8lCf"
],
"gpuType": "T4",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|