From 7de67fcbebacf88aa34fd3eec464ec4f91005bac Mon Sep 17 00:00:00 2001 From: anothermartz <89461919+anothermartz@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:18:40 +0000 Subject: [PATCH] Fixed step 1 falsely completing --- Easy_Wav2Lip_v8.1_quickfix.ipynb | 289 +++++++++++++++++++++++++++++++ 1 file changed, 289 insertions(+) create mode 100644 Easy_Wav2Lip_v8.1_quickfix.ipynb diff --git a/Easy_Wav2Lip_v8.1_quickfix.ipynb b/Easy_Wav2Lip_v8.1_quickfix.ipynb new file mode 100644 index 0000000..b27035a --- /dev/null +++ b/Easy_Wav2Lip_v8.1_quickfix.ipynb @@ -0,0 +1,289 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "fkoF-mm8CGfB" + }, + "source": [ + "Welcome to my Easy Wav2Lip colab!\n", + "\n", + "My goal is to make lipsyncing with this tool easy, fast and great looking!\n", + "\n", + "Please view the GitHub for instructions: https://github.com/anothermartz/Easy-Wav2Lip/tree/v8#best-practices" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "OZJJ-zPGiiIs", + "cellView": "form" + }, + "outputs": [], + "source": [ + "version = 'v8.1'\n", + "#@title

Step 1: Setup \"Easy-Wav2Lip\"

With one button: it's really that easy!\n", + "#@markdown 👈 Click that little circle play button first - it will ask for Google Drive access:
\n", + "#@markdown > Accept if your files are on Google Drive (recommended).\n", + "#@markdown
Alternatively, you can click deny and upload files manually, but this is slower.\n", + "\n", + "#check if already installed\n", + "import os\n", + "import sys\n", + "if os.path.exists('installed.txt'):\n", + " with open('last_file.txt', 'r') as file:\n", + " last_file = file.readline()\n", + " if last_file == version:\n", + " sys.exit('Easy-Wav2Lip '+version+' has already been run on this instance!')\n", + "\n", + "\n", + "#check GPU is enabled\n", + "print('checking for GPU')\n", + "import torch\n", + "if not torch.cuda.is_available():\n", + " sys.exit('No GPU in runtime. Please go to the \"Runtime\" menu, \"Change runtime type\" and select \"GPU\".')\n", + "\n", + "#prompt to mount google drive\n", + "print('requesting Google Drive access')\n", + "try:\n", + " from google.colab import drive\n", + " drive.mount('/content/drive')\n", + "except:\n", + " print(\"google drive not linked\")\n", + "\n", + "\n", + "#start timer\n", + "import time\n", + "start_time = time.time()\n", + "\n", + "#clone git\n", + "giturl = 'https://github.com/anothermartz/Easy-Wav2Lip.git'\n", + "\n", + "\n", + "!git clone -b {version} {giturl}\n", + "%cd 'Easy-Wav2Lip'\n", + "working_directory = os.getcwd()\n", + "!mkdir 'face_alignment' 'temp'\n", + "\n", + "#install prerequisites\n", + "!pip install -r requirements.txt\n", + "print('installing batch_face')\n", + "import warnings\n", + "warnings.filterwarnings(\"ignore\", category=UserWarning,\n", + " module='torchvision.transforms.functional_tensor')\n", + "!pip install batch_face --quiet\n", + "print('installing gfpgan')\n", + "!pip install gfpgan --quiet\n", + "\n", + "!python install.py\n", + "\n", + "from IPython.display import clear_output\n", + "clear_output()\n", + "print(\"Installation complete, move to Step 2!\")\n", + "\n", + "#end timer\n", + "elapsed_time = time.time() - start_time\n", + "from easy_functions import format_time\n", + "print(f\"Execution time: {format_time(elapsed_time)}\")" + ] + }, + { + "cell_type": "code", + "source": [ + "if not os.path.exists('installed.txt'):\n", + " sys.exit('Step 1 has not been run in this instance! Please run step 1 each time you disconnect from a runtime.')\n", + "time\n", + "############################## user inputs #####################################\n", + "#@markdown

Step 2: Select inputs:

\n", + "\n", + "# @markdown On destktop:

Click the folder icon ( 📁 ) at the left edge of colab, find your file, right click, copy path, paste it below:\n", + "#@markdown

\n", + "# @markdown On mobile:

Tap the hamburger button ( ☰ ) at the top left, click show file browser, find your file, long press on it, copy path, paste below:\n", + "video_file = \"\" #@param {type:\"string\"}\n", + "vocal_file = \"\" #@param {type:\"string\"}\n", + "\n", + "#@markdown > Keep vocal_file blank if your video already has the desired speech audio encoded into it.\n", + "#@markdown # Quality\n", + "quality = \"Improved\" # @param [\"Fast\", \"Improved\", \"Enhanced\", \"Experimental\"]\n", + "#@markdown * Fast: Wav2Lip
\n", + "#@markdown * Improved: Wav2Lip with a feathered mask around the mouth to remove the square around the face
\n", + "#@markdown * Enhanced: Wav2Lip + mask + GFPGAN upscaling done on the face\n", + "#@markdown * Experimental: Test version of applying gfpgan - see [release notes](https://github.com/anothermartz/Easy-Wav2Lip/releases/tag/v7_release)\n", + "#preview_quality = False #@param {type:\"boolean\"} - coming soon!\n", + "output_height = \"full resolution\" #@param [\"half resolution\", \"full resolution\", \"480\"] {allow-input: true}\n", + "use_previous_tracking_data = True #@param {type:\"boolean\"}\n", + "#@markdown Speeds up processing of the same video used multiple times - it should delete the last tracking file automatically when the video is changed but if it's failing after the first video, untick this box.\n", + "\n", + "#@markdown\n", + "#------------------------------*Step 3*----------------------------------------!\n", + "#@markdown

👈 Step 3: Click the little circle play button on this cell!

(Or press ctrl + F10) - Then wait for processing to complete.\n", + "# scale padding with resolution\n", + "#@markdown
\n", + "\n", + "#@markdown ---\n", + "#@markdown
\n", + "\n", + "#@markdown # [Advanced tweaking](https://github.com/anothermartz/Easy-Wav2Lip/tree/v7#advanced-tweaking) (optional) Just ignore all of this if you are new, or click the blue titles for instructions.\n", + "wav2lip_version = \"Wav2Lip\" # @param [\"Wav2Lip\", \"Wav2Lip_GAN\"]\n", + "nosmooth = True #@param {type:\"boolean\"}\n", + "#@markdown ### [Padding:](https://github.com/anothermartz/Easy-Wav2Lip/tree/v7#padding) (Up, Down, Left, Right)
\n", + "U = 0 #@param {type:\"slider\", min:-100, max:100, step:1}\n", + "D = 0 #@param {type:\"slider\", min:-100, max:100, step:1}\n", + "L = 0 #@param {type:\"slider\", min:-100, max:100, step:1}\n", + "R = 0 #@param {type:\"slider\", min:-100, max:100, step:1}\n", + "#@markdown
\n", + "\n", + "#@markdown ### [Mask:](https://github.com/anothermartz/Easy-Wav2Lip/tree/v7#other-options)\n", + "size = 2.5 #@param {type:\"slider\", min:1, max:6, step:0.1}\n", + "feathering = 2 #@param {type:\"slider\", min:0, max:3, step:1}\n", + "mouth_tracking = False #@param {type:\"boolean\"}\n", + "debug_mask = False #@param {type:\"boolean\"}\n", + "\n", + "\n", + "#@markdown # [Other options:](https://github.com/anothermartz/Easy-Wav2Lip/tree/v7#other-options)\n", + "\n", + "batch_process = False #@param {type:\"boolean\"}\n", + "output_suffix = \"_Easy-Wav2Lip\" #@param {type:\"string\"}\n", + "include_settings_in_suffix = False #@param {type:\"boolean\"}\n", + "preview_input = False #@param {type:\"boolean\"}\n", + "preview_settings = False #@param {type:\"boolean\"}\n", + "#@markdown preview_settings processes only one frame so you can see how it looks without doing the whole video\n", + "frame_to_preview = 100 # @param {type:\"integer\"}\n", + "\n", + "\n", + "import configparser\n", + "\n", + "# Create a ConfigParser object\n", + "config = configparser.ConfigParser()\n", + "\n", + "# Put all your variables in a dictionary\n", + "options = {\n", + " 'video_file': video_file,\n", + " 'vocal_file': vocal_file,\n", + " 'quality': quality,\n", + " 'output_height': output_height,\n", + " 'wav2lip_version': wav2lip_version,\n", + " 'use_previous_tracking_data': use_previous_tracking_data,\n", + " 'nosmooth': nosmooth\n", + "}\n", + "padding = {\n", + " 'U': U,\n", + " 'D': D,\n", + " 'L': L,\n", + " 'R': R\n", + "}\n", + "mask = {\n", + " 'size': size,\n", + " 'feathering': feathering,\n", + " 'mouth_tracking': mouth_tracking,\n", + " 'debug_mask': debug_mask\n", + "}\n", + "other = {\n", + " 'batch_process': batch_process,\n", + " 'output_suffix': output_suffix,\n", + " 'include_settings_in_suffix': include_settings_in_suffix,\n", + " 'preview_input': preview_input,\n", + " 'preview_settings': preview_settings,\n", + " 'frame_to_preview': frame_to_preview\n", + "}\n", + "\n", + "\n", + "# Add the dictionary to the ConfigParser object\n", + "config['OPTIONS'] = options\n", + "config['PADDING'] = padding\n", + "config['MASK'] = mask\n", + "config['OTHER'] = other\n", + "\n", + "# Write the data to an INI file\n", + "with open('config.ini', 'w') as f:\n", + " config.write(f)\n", + "\n", + "!python run.py\n", + "\n", + "from easy_functions import show_video\n", + "from IPython.display import Image\n", + "if preview_settings:\n", + " if os.path.isfile(os.path.join('temp','preview.jpg')):\n", + " display(Image(os.path.join('temp','preview.jpg')))\n", + "else:\n", + " if os.path.isfile(os.path.join('temp','output.mp4')):\n", + " print(f\"Loading video preview...\")\n", + " show_video(os.path.join('temp','output.mp4'))" + ], + "metadata": { + "id": "akznIwTZK_o8", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 967 + }, + "outputId": "4306f2fc-ae3f-4516-9574-a22f84be81fe", + "cellView": "form" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Processing penguinz01.mp4 using penguinz01.wav for audio\n", + "imports loaded! \n", + "analysing audio...\n", + "552 frames to process\n", + "detecting face in every frame: 100%|██████████████████████████████| 552/552 [00:14<00:00, 37.77it/s]\n", + "mask size: 2.5, feathering: 3\n", + "Starting...\n", + "Processing Wav2Lip: 100%|█████████████████████████████████████████| 552/552 [00:26<00:00, 20.95it/s]\n", + "converting to final video\n", + "penguinz01 successfully lip synced! It will be found here:\n", + "/content/drive/MyDrive/Projects/penguinz0/penguinz01_Easy-Wav2Lip.mp4\n", + "Execution time: 38s\n", + "Loading video preview...\n" + ] + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "text/html": [ + "\n", + " \n", + " " + ] + }, + "metadata": {} + } + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "provenance": [], + "include_colab_link": true + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file