{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "G9BdiCppV6AS" }, "source": [ "# Video tutorial link > https://youtu.be/OI1LEN-SgLM\n", "# Testing video and images and more : https://www.patreon.com/posts/1-click-deepfake-83785289\n", "## SECourses : https://www.youtube.com/SECourses\n", "## GitHub instructions : https://github.com/FurkanGozukara/Stable-Diffusion/blob/main/Tutorials/1-Click-DeepFake-Tutorial.md\n", "# RunPod Roop DeepFake Auto installer: https://www.patreon.com/posts/auto-installer-84511510" ] }, { "cell_type": "markdown", "metadata": { "id": "ni6edG-8MUNg" }, "source": [ "**If you want to use the latest version remove `!git checkout 312208a41102ba86d2454ae8efc9d3f0b786a6e7`**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "t1yPuhdySqCq" }, "outputs": [], "source": [ "!git clone https://github.com/Ysb321/vid_roooop roop\n", "%cd roop\n", "#Tested and updated 23 August 2023 commit\n", "#!git checkout da1ef285f1d43bd0cc8b9cdb9a0f80f7ae793a97\n", "!pip install onnxruntime-gpu && pip install -r requirements.txt" ] }, { "cell_type": "markdown", "metadata": { "id": "Jul-_i9xMmV2" }, "source": [ "**You will see processing message at the end of below printed messages e.g. Processing: 43% 136/318 00:38<00:24, 7.47frame/s**\n", "\n", "**Make sure to upload root roop folder not inside the sub roop folder and don't forget to change image and video file names**\n", "\n", "**1 is best quality big video size, 100 worst quality low video size**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Nh3RaH1iRKed", "outputId": "4bace9cd-ddcb-4a3e-92d9-213a126f6cff" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Mounted at /content/drive\n" ] } ], "source": [ "from google.colab import drive\n", "import os\n", "from os import path\n", "drive.mount('/content/drive')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "Is6U2huqSzLE" }, "outputs": [], "source": [ "%cd \"/content/roop\"\n", "!python run.py -s \"face2.png\" -t \"brad org.mp4\" -o \"face_changed_video_v2.mp4\" --keep-frames --keep-fps --temp-frame-quality 1 --output-video-quality 1 --execution-provider cuda" ] }, { "cell_type": "markdown", "metadata": { "id": "VJpNWHq1qdjT" }, "source": [ "**Below code will do also face restoration to improve quality significantly but it will take longer**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "_j18G_uPqc37" }, "outputs": [], "source": [ "%cd \"/content/roop\"\n", "!python run.py -s \"/content/sample_data/download.jpg\" -t \"/content/sample_data/5b88a002-34f8-4e9c-96b8-0747795ea129.png\" -o \"/content/drive/MyDrive/imgs/immgg/\" --keep-frames --keep-fps --temp-frame-quality 1 --output-video-quality 1 --execution-provider cuda --frame-processor face_swapper face_enhancer --reference-face-position 1" ] }, { "cell_type": "markdown", "metadata": { "id": "jr-63BTn8UEs" }, "source": [ "### All options are displayed below\n", "Append any of them to the above commands before executing\n", "```\n", "python run.py [options]\n", "\n", "-h, --help show this help message and exit\n", "-s SOURCE_PATH, --source SOURCE_PATH select an source image\n", "-t TARGET_PATH, --target TARGET_PATH select an target image or video\n", "-o OUTPUT_PATH, --output OUTPUT_PATH select output file or directory\n", "--frame-processor FRAME_PROCESSOR [FRAME_PROCESSOR ...] frame processors (choices: face_swapper, face_enhancer, ...)\n", "--keep-fps keep target fps\n", "--keep-frames keep temporary frames\n", "--skip-audio skip target audio\n", "--many-faces process every face\n", "--reference-face-position REFERENCE_FACE_POSITION position of the reference face\n", "--reference-frame-number REFERENCE_FRAME_NUMBER number of the reference frame\n", "--similar-face-distance SIMILAR_FACE_DISTANCE face distance used for recognition\n", "--temp-frame-format {jpg,png} image format used for frame extraction\n", "--temp-frame-quality [0-100] image quality used for frame extraction\n", "--output-video-encoder {libx264,libx265,libvpx-vp9,h264_nvenc,hevc_nvenc} encoder used for the output video\n", "--output-video-quality [0-100] quality used for the output video\n", "--max-memory MAX_MEMORY maximum amount of RAM in GB\n", "--execution-provider {cpu} [{cpu} ...] available execution provider (choices: cpu, ...)\n", "--execution-threads EXECUTION_THREADS number of execution threads\n", "-v, --version show program's version number and exit\n", " ```" ] }, { "cell_type": "markdown", "metadata": { "id": "UdQ1VHdI8lCf" }, "source": [ "### Download generated images folder" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 17 }, "id": "oYjWveAmw10X", "outputId": "a8b591fe-7c43-4a72-a7b9-f4111aa62e2a" }, "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": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "download(\"download_5b4ec731-e629-435c-9d30-4ddfb2b4fba7\", \"video3.zip.zip\", 863967701)" ], "text/plain": [ "" ] }, "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/video3'\n", "\n", "# Set the zip file name\n", "zip_filename = 'video3.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": { "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 0 }