diff --git a/colab.ipynb b/colab.ipynb new file mode 100644 index 0000000..871f710 --- /dev/null +++ b/colab.ipynb @@ -0,0 +1,728 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "DFL_UpToDate.ipynb", + "version": "0.3.2", + "provenance": [], + "collapsed_sections": [ + "JuVn21kt40Gw", + "6jHv35sm-Qiy", + "tUNVcbujhm00", + "WTuyUxgdLA13", + "avAcSL_uvtq_", + "f7GNQ7kZx7Ha" + ] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "accelerator": "GPU" + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "0cKdTCuv4tXh", + "colab_type": "text" + }, + "source": [ + "# Welcome to DFL-Colab!\n", + "\n", + "This is an adapted version of the DFL for Google Colab.\n", + "\n", + "Version 2.5\n", + "\n", + "# Overview\n", + "* Extractor works in full functionality.\n", + "* Training can work without preview.\n", + "* Converter works in full functionality.\n", + "* You can import/export workspace with your Google Drive.\n", + "* Import/export and another manipulations with workspace you can do in \"Manage workspace\" block\n", + "* Google Colab machine active for 12 hours. DFL-Colab makes a backup of your workspace in training mode, after 11 hours from the start of the session.\n", + "* Google does not like long-term heavy calculations. Therefore, for training more than two sessions in a row, use two Google accounts. It is recommended to split your training over 2 accounts, but you can use one Google Drive account to store your workspace.\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "JuVn21kt40Gw", + "colab_type": "text" + }, + "source": [ + "# Clone Github repository and install requirements\n", + "\n", + "* Clone Github repository or pull updates\n", + "* Requirements install is automatically" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "JG-f2WqT4fLK", + "colab_type": "code", + "cellView": "both", + "colab": {} + }, + "source": [ + "#@title Clone or pull DeepFaceLab from Github\n", + "\n", + "Mode = \"clone\" #@param [\"clone\", \"pull\"]\n", + "\n", + "from pathlib import Path\n", + "if (Mode == \"clone\"):\n", + " !git clone https://github.com/faceshiftlabs/DeepFaceLab.git\n", + "else:\n", + " %cd /content/DeepFaceLab\n", + " !git pull\n", + "\n", + "!pip install -r /content/DeepFaceLab/requirements-colab.txt\n", + "!pip install --upgrade scikit-image\n", + "\n", + "if not Path(\"/content/workspace\").exists():\n", + " !wget -q --no-check-certificate -r 'https://docs.google.com/uc?export=download&id=1hTH2h6l_4kKrczA8EkN6GyuXx4lzmCnK' -O pretrain_CelebA.zip\n", + " !mkdir /content/pretrain\n", + " !unzip -q /content/pretrain_CelebA.zip -d /content/pretrain/\n", + " !rm /content/pretrain_CelebA.zip\n", + "\n", + "print(\"Done!\")" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "hqwOlJG4MdLC", + "colab_type": "text" + }, + "source": [ + "#Manage workspace\n", + "\n", + "\n", + "\n", + "* You can import/export workspace or individual data, like model files with Google Drive\n", + "* Also, you can use HFS (HTTP Fileserver) for directly import/export you workspace from your computer\n", + "* You can clear all workspace or delete part of it\n", + "\n" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "z4w_sUzgOQmL", + "colab_type": "code", + "cellView": "form", + "outputId": "9bfe6ad8-9f60-4707-9874-c2567784e5bc", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 236 + } + }, + "source": [ + "#@title Import from Drive\n", + "\n", + "Mode = \"workspace\" #@param [\"workspace\", \"data_src\", \"data_dst\", \"data_src aligned\", \"data_dst aligned\", \"models\"]\n", + "Archive_name = \"workspace.zip\" #@param {type:\"string\"}\n", + "\n", + "#Mount Google Drive as folder\n", + "from google.colab import drive\n", + "drive.mount('/content/drive', force_remount=True)\n", + "\n", + "def zip_and_copy(path, mode):\n", + " unzip_cmd=\" -q \"+Archive_name\n", + " \n", + " %cd $path\n", + " copy_cmd = \"/content/drive/My\\ Drive/\"+Archive_name+\" \"+path\n", + " !cp $copy_cmd\n", + " !unzip $unzip_cmd \n", + " !rm $Archive_name\n", + "\n", + "if Mode == \"workspace\":\n", + " zip_and_copy(\"/content\", \"workspace\")\n", + "elif Mode == \"data_src\":\n", + " zip_and_copy(\"/content/workspace\", \"data_src\")\n", + "elif Mode == \"data_dst\":\n", + " zip_and_copy(\"/content/workspace\", \"data_dst\")\n", + "elif Mode == \"data_src aligned\":\n", + " zip_and_copy(\"/content/workspace/data_src\", \"aligned\")\n", + "elif Mode == \"data_dst aligned\":\n", + " zip_and_copy(\"/content/workspace/data_dst\", \"aligned\")\n", + "elif Mode == \"models\":\n", + " zip_and_copy(\"/content/workspace\", \"model\")\n", + " \n", + "print(\"Done!\")\n", + "\n" + ], + "execution_count": 0, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdocs.test%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.photos.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fpeopleapi.readonly&response_type=code\n", + "\n", + "Enter your authorization code:\n", + "··········\n", + "Mounted at /content/drive\n", + "/content\n", + "Done!\n", + "Mounted at /content/drive\n", + "/content\n", + "replace workspace/data_src/aligned/02319.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: N\n", + "Done!\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "0Y3WfuwoNXqC", + "colab_type": "code", + "cellView": "form", + "colab": {} + }, + "source": [ + "#@title Export to Drive { form-width: \"30%\" }\n", + "Mode = \"workspace\" #@param [\"workspace\", \"data_src\", \"data_dst\", \"data_src aligned\", \"data_dst aligned\", \"merged\", \"models\"]\n", + "Archive_name = \"workspace.zip\" #@param {type:\"string\"}\n", + "\n", + "#Mount Google Drive as folder\n", + "from google.colab import drive\n", + "drive.mount('/content/drive', force_remount=True)\n", + "\n", + "def zip_and_copy(path, mode):\n", + " zip_cmd=\"-r -q \"+Archive_name+\" \"\n", + " \n", + " %cd $path\n", + " zip_cmd+=mode\n", + " !zip $zip_cmd\n", + " copy_cmd = \" \"+Archive_name+\" /content/drive/My\\ Drive/\"\n", + " !cp $copy_cmd\n", + " !rm $Archive_name\n", + "\n", + "if Mode == \"workspace\":\n", + " zip_and_copy(\"/content\", \"workspace\")\n", + "elif Mode == \"data_src\":\n", + " zip_and_copy(\"/content/workspace\", \"data_src\")\n", + "elif Mode == \"data_dst\":\n", + " zip_and_copy(\"/content/workspace\", \"data_dst\")\n", + "elif Mode == \"data_src aligned\":\n", + " zip_and_copy(\"/content/workspace/data_src\", \"aligned\")\n", + "elif Mode == \"data_dst aligned\":\n", + " zip_and_copy(\"/content/workspace/data_dst\", \"aligned\")\n", + "elif Mode == \"merged\":\n", + " zip_and_copy(\"/content/workspace/data_dst\", \"merged\")\n", + "elif Mode == \"models\":\n", + " zip_and_copy(\"/content/workspace\", \"model\")\n", + " \n", + "print(\"Done!\")\n" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "0hIvJtxwTGcb", + "colab_type": "code", + "colab": {} + }, + "source": [ + "#@title Import from URL{ form-width: \"30%\", display-mode: \"form\" }\n", + "URL = \"http://\" #@param {type:\"string\"}\n", + "Mode = \"unzip to content\" #@param [\"unzip to content\", \"unzip to content/workspace\", \"unzip to content/workspace/data_src\", \"unzip to content/workspace/data_src/aligned\", \"unzip to content/workspace/data_dst\", \"unzip to content/workspace/data_dst/aligned\", \"unzip to content/workspace/model\", \"download to content/workspace\"]\n", + "\n", + "import urllib\n", + "from pathlib import Path\n", + "\n", + "def unzip(zip_path, dest_path):\n", + "\n", + " \n", + " unzip_cmd = \" unzip -q \" + zip_path + \" -d \"+dest_path\n", + " !$unzip_cmd \n", + " rm_cmd = \"rm \"+dest_path + url_path.name\n", + " !$rm_cmd\n", + " print(\"Unziped!\")\n", + " \n", + "\n", + "if Mode == \"unzip to content\":\n", + " dest_path = \"/content/\"\n", + "elif Mode == \"unzip to content/workspace\":\n", + " dest_path = \"/content/workspace/\"\n", + "elif Mode == \"unzip to content/workspace/data_src\":\n", + " dest_path = \"/content/workspace/data_src/\"\n", + "elif Mode == \"unzip to content/workspace/data_src/aligned\":\n", + " dest_path = \"/content/workspace/data_src/aligned/\"\n", + "elif Mode == \"unzip to content/workspace/data_dst\":\n", + " dest_path = \"/content/workspace/data_dst/\"\n", + "elif Mode == \"unzip to content/workspace/data_dst/aligned\":\n", + " dest_path = \"/content/workspace/data_dst/aligned/\"\n", + "elif Mode == \"unzip to content/workspace/model\":\n", + " dest_path = \"/content/workspace/model/\"\n", + "elif Mode == \"download to content/workspace\":\n", + " dest_path = \"/content/workspace/\"\n", + "\n", + "if not Path(\"/content/workspace\").exists():\n", + " cmd = \"mkdir /content/workspace; mkdir /content/workspace/data_src; mkdir /content/workspace/data_src/aligned; mkdir /content/workspace/data_dst; mkdir /content/workspace/data_dst/aligned; mkdir /content/workspace/model\"\n", + " !$cmd\n", + "\n", + "url_path = Path(URL)\n", + "urllib.request.urlretrieve ( URL, dest_path + url_path.name )\n", + "\n", + "if (url_path.suffix == \".zip\") and (Mode!=\"download to content/workspace\"):\n", + " unzip(dest_path + url_path.name, dest_path)\n", + "\n", + " \n", + "print(\"Done!\")" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "7V1sc7rxNKLO", + "colab_type": "code", + "cellView": "form", + "colab": {} + }, + "source": [ + "#@title Export to URL\n", + "URL = \"http://\" #@param {type:\"string\"}\n", + "Mode = \"upload workspace\" #@param [\"upload workspace\", \"upload data_src\", \"upload data_dst\", \"upload data_src aligned\", \"upload data_dst aligned\", \"upload merged\", \"upload model\"]\n", + "\n", + "cmd_zip = \"zip -r -q \"\n", + "\n", + "def run_cmd(zip_path, curl_url):\n", + " cmd_zip = \"zip -r -q \"+zip_path\n", + " cmd_curl = \"curl --silent -F \"+curl_url+\" -D out.txt > /dev/null\"\n", + " !$cmd_zip\n", + " !$cmd_curl\n", + "\n", + "\n", + "if Mode == \"upload workspace\":\n", + " %cd \"/content\"\n", + " run_cmd(\"workspace.zip workspace/\",\"'data=@/content/workspace.zip' \"+URL)\n", + "elif Mode == \"upload data_src\":\n", + " %cd \"/content/workspace\"\n", + " run_cmd(\"data_src.zip data_src/\", \"'data=@/content/workspace/data_src.zip' \"+URL)\n", + "elif Mode == \"upload data_dst\":\n", + " %cd \"/content/workspace\"\n", + " run_cmd(\"data_dst.zip data_dst/\", \"'data=@/content/workspace/data_dst.zip' \"+URL)\n", + "elif Mode == \"upload data_src aligned\":\n", + " %cd \"/content/workspace\"\n", + " run_cmd(\"data_src_aligned.zip data_src/aligned\", \"'data=@/content/workspace/data_src_aligned.zip' \"+URL )\n", + "elif Mode == \"upload data_dst aligned\":\n", + " %cd \"/content/workspace\"\n", + " run_cmd(\"data_dst_aligned.zip data_dst/aligned/\", \"'data=@/content/workspace/data_dst_aligned.zip' \"+URL)\n", + "elif Mode == \"upload merged\":\n", + " %cd \"/content/workspace/data_dst\"\n", + " run_cmd(\"merged.zip merged/\",\"'data=@/content/workspace/data_dst/merged.zip' \"+URL )\n", + "elif Mode == \"upload model\":\n", + " %cd \"/content/workspace\"\n", + " run_cmd(\"model.zip model/\", \"'data=@/content/workspace/model.zip' \"+URL)\n", + " \n", + " \n", + "!rm *.zip\n", + "\n", + "%cd \"/content\"\n", + "print(\"Done!\")" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "Ta6ue_UGMkki", + "colab_type": "code", + "cellView": "form", + "colab": {} + }, + "source": [ + "#@title Delete and recreate\n", + "Mode = \"Delete and recreate workspace\" #@param [\"Delete and recreate workspace\", \"Delete models\", \"Delete data_src\", \"Delete data_src aligned\", \"Delete data_src video\", \"Delete data_dst\", \"Delete data_dst aligned\", \"Delete merged frames\"]\n", + "\n", + "%cd \"/content\" \n", + "\n", + "if Mode == \"Delete and recreate workspace\":\n", + " cmd = \"rm -r /content/workspace ; mkdir /content/workspace; mkdir /content/workspace/data_src; mkdir /content/workspace/data_src/aligned; mkdir /content/workspace/data_dst; mkdir /content/workspace/data_dst/aligned; mkdir /content/workspace/model\" \n", + "elif Mode == \"Delete models\":\n", + " cmd = \"rm -r /content/workspace/model/*\"\n", + "elif Mode == \"Delete data_src\":\n", + " cmd = \"rm /content/workspace/data_src/*.png || rm -r /content/workspace/data_src/*.jpg\"\n", + "elif Mode == \"Delete data_src aligned\":\n", + " cmd = \"rm -r /content/workspace/data_src/aligned/*\"\n", + "elif Mode == \"Delete data_src video\":\n", + " cmd = \"rm -r /content/workspace/data_src.*\"\n", + "elif Mode == \"Delete data_dst\":\n", + " cmd = \"rm /content/workspace/data_dst/*.png || rm /content/workspace/data_dst/*.jpg\"\n", + "elif Mode == \"Delete data_dst aligned\":\n", + " cmd = \"rm -r /content/workspace/data_dst/aligned/*\"\n", + "elif Mode == \"Delete merged frames\":\n", + " cmd = \"rm -r /content/workspace/data_dst/merged\"\n", + " \n", + "!$cmd\n", + "print(\"Done!\")" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "tUNVcbujhm00", + "colab_type": "text" + }, + "source": [ + "# Extract and sorting\n", + "* Extract frames for SRC or DST video.\n", + "* Denoise SRC or DST video. \"Factor\" param set intesity of denoising\n", + "* Detect and align faces with one of detectors. (S3FD - recommended). If you need, you can get frames with debug landmarks.\n", + "* Export workspace to Google Drive after extract and sort it manually (Last block of Notebook)\n" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "qwJEbz5Nhot0", + "colab_type": "code", + "cellView": "form", + "colab": {} + }, + "source": [ + "#@title Extract frames\n", + "Video = \"data_src\" #@param [\"data_src\", \"data_dst\"]\n", + "\n", + "%cd \"/content\"\n", + "\n", + "cmd = \"DeepFaceLab/main.py videoed extract-video\"\n", + "\n", + "if Video == \"data_dst\":\n", + " cmd+= \" --input-file workspace/data_dst.* --output-dir workspace/data_dst/\"\n", + "else:\n", + " cmd+= \" --input-file workspace/data_src.* --output-dir workspace/data_src/\"\n", + " \n", + "!python $cmd" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "bFmPo0s2lTil", + "colab_type": "code", + "cellView": "form", + "colab": {} + }, + "source": [ + "#@title Denoise frames\n", + "Data = \"data_src\" #@param [\"data_src\", \"data_dst\"]\n", + "Factor = 1 #@param {type:\"slider\", min:1, max:20, step:1}\n", + "\n", + "cmd = \"DeepFaceLab/main.py videoed denoise-image-sequence --input-dir workspace/\"+Data+\" --factor \"+str(Factor)\n", + "\n", + "%cd \"/content\"\n", + "!python $cmd" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "nmq0Sj2bmq7d", + "colab_type": "code", + "cellView": "form", + "colab": {} + }, + "source": [ + "#@title Detect faces\n", + "Data = \"data_src\" #@param [\"data_src\", \"data_dst\"]\n", + "Detector = \"S3FD\" #@param [\"S3FD\", \"MT\"]\n", + "Debug = False #@param {type:\"boolean\"}\n", + "\n", + "detect_type = \"s3fd\"\n", + "if Detector == \"S3FD\":\n", + " detect_type = \"s3fd\"\n", + "elif Detector == \"MT\":\n", + " detect_type = \"mt\"\n", + "\n", + "folder = \"workspace/\"+Data\n", + "folder_align = folder+\"/aligned\"\n", + "debug_folder = folder_align+\"/debug\"\n", + "\n", + "cmd = \"DeepFaceLab/main.py extract --input-dir \"+folder+\" --output-dir \"+folder_align\n", + "\n", + "if Debug:\n", + " cmd+= \" --debug-dir \"+debug_folder\n", + "\n", + "cmd+=\" --detector \"+detect_type\n", + " \n", + "%cd \"/content\"\n", + "!python $cmd" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "TRNxUFE6p6Eu", + "colab_type": "code", + "cellView": "form", + "colab": {} + }, + "source": [ + "#@title Sort aligned\n", + "Data = \"data_src\" #@param [\"data_src\", \"data_dst\"]\n", + "sort_type = \"hist\" #@param [\"hist\", \"hist-dissim\", \"face-yaw\", \"face-pitch\", \"blur\", \"final\"]\n", + "\n", + "cmd = \"DeepFaceLab/main.py sort --input-dir workspace/\"+Data+\"/aligned --by \"+sort_type\n", + "\n", + "%cd \"/content\"\n", + "!python $cmd" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "WTuyUxgdLA13", + "colab_type": "text" + }, + "source": [ + "# Train model\n", + "\n", + "* Choose your model type, but SAE is recommend for everyone\n", + "* Set model options on output field\n", + "* You can see preview manually, if go to model folder in filemanager and double click on preview.jpg file\n", + "* Your workspace will be archived and upload to mounted Drive after 11 hours from start session\n", + "* If you select \"Backup_every_hour\" option, your workspace will be backed up every hour.\n", + "* Also, you can export your workspace manually in \"Manage workspace\" block" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "Z0Kya-PJLDhv", + "colab_type": "code", + "cellView": "both", + "outputId": "db06ff5b-4aae-4d4b-bad0-9c980782ba3b", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "source": [ + "#@title Training\n", + "Model = \"SAE\" #@param [\"SAE\", \"H128\", \"LIAEF128\", \"DF\", \"DEV_FANSEG\", \"RecycleGAN\"]\n", + "Backup_every_hour = True #@param {type:\"boolean\"}\n", + "\n", + "%cd \"/content\"\n", + "\n", + "#Mount Google Drive as folder\n", + "from google.colab import drive\n", + "drive.mount('/content/drive')\n", + "\n", + "import psutil, os, time\n", + "\n", + "p = psutil.Process(os.getpid())\n", + "uptime = time.time() - p.create_time()\n", + "\n", + "if (Backup_every_hour):\n", + " if not os.path.exists('workspace.zip'):\n", + " print(\"Creating workspace archive ...\")\n", + " !zip -r -q workspace.zip workspace\n", + " print(\"Archive created!\")\n", + " else:\n", + " print(\"Archive exist!\")\n", + "\n", + "if (Backup_every_hour):\n", + " print(\"Time to end session: \"+str(round((43200-uptime)/3600))+\" hours\")\n", + " backup_time = str(3600)\n", + " backup_cmd = \" --execute-program -\"+backup_time+\" \\\"import os; os.system('zip -r -q workspace.zip workspace/model'); os.system('cp /content/workspace.zip /content/drive/My\\ Drive/'); print(' Backuped!') \\\"\" \n", + "elif (round(39600-uptime) > 0):\n", + " print(\"Time to backup: \"+str(round((39600-uptime)/3600))+\" hours\")\n", + " backup_time = str(round(39600-uptime))\n", + " backup_cmd = \" --execute-program \"+backup_time+\" \\\"import os; os.system('zip -r -q workspace.zip workspace'); os.system('cp /content/workspace.zip /content/drive/My\\ Drive/'); print(' Backuped!') \\\"\" \n", + "else:\n", + " print(\"Session expires in less than an hour.\")\n", + " backup_cmd = \"\"\n", + " \n", + "cmd = \"DeepFaceLab/main.py train --training-data-src-dir workspace/data_src/aligned --training-data-dst-dir workspace/data_dst/aligned --pretraining-data-dir pretrain/aligned --model-dir workspace/model --model \"+Model\n", + " \n", + "if (backup_cmd != \"\"):\n", + " train_cmd = (cmd+backup_cmd)\n", + "else:\n", + " train_cmd = (cmd)\n", + "\n", + "!python $train_cmd" + ], + "execution_count": 0, + "outputs": [ + { + "output_type": "stream", + "text": [ + "/content\n", + "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n", + "Creating workspace archive ...\n", + "Archive created!\n", + "Time to end session: 12 hours\n", + "Running trainer.\n", + "\n", + "Loading model...\n", + "Press enter in 2 seconds to override model settings.\n", + "Enable autobackup? (y/n ?:help skip:n) : /usr/lib/python3.6/multiprocessing/semaphore_tracker.py:143: UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown\n", + " len(cache))\n", + "\n", + "n\n", + "Write preview history? (y/n ?:help skip:n) : \n", + "n\n", + "Target iteration (skip:unlimited/default) : \n", + "0\n", + "Batch_size (?:help skip:16) : 10\n", + "Enable ping-pong? (y/n ?:help skip:False) : ?\n", + "Cycles batch size between 1 and chosen batch size, simulating super convergence\n", + "Enable ping-pong? (y/n ?:help skip:False) : y\n", + "Ping-pong iteration (skip:1000/default) : \n", + "1000\n", + "Feed faces to network sorted by yaw? (y/n ?:help skip:y): \n", + "y\n", + "Flip faces randomly? (y/n ?:help skip:y) : ?\n", + "Predicted face will look more naturally without this option, but src faceset should cover all face directions as dst faceset.\n", + "Flip faces randomly? (y/n ?:help skip:y) : n\n", + "Optimizer mode? ( 1,2,3 ?:help skip:1) : \n", + "1\n", + "Use pixel loss? (y/n, ?:help skip: n ) : \n", + "n\n", + "Face style power ( 0.0 .. 100.0 ?:help skip:0.00) : \n", + "0.0\n", + "Background style power ( 0.0 .. 100.0 ?:help skip:0.00) : \n", + "0.0\n", + "Apply random color transfer to src faceset? (0) None, (1) LCT, (2) RCT, (3) RCT-c, (4) RCT-p, (5) RCT-pc, (6) mRTC, (7) mRTC-c, (8) mRTC-p, (9) mRTC-pc ?:help skip:False) : 0\n", + "Enable gradient clipping? (y/n, ?:help skip:y) : \n", + "y\n", + "Using TensorFlow backend.\n", + "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", + "Instructions for updating:\n", + "Colocations handled automatically by placer.\n", + "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n", + "Instructions for updating:\n", + "Use tf.cast instead.\n", + "Loading: 100% 4895/4895 [00:08<00:00, 562.57it/s]\n", + "Sorting: 100% 64/64 [00:00<00:00, 624.66it/s]\n", + "Loading: 0it [00:00, ?it/s]\n", + "Sorting: 100% 64/64 [00:00<00:00, 586103.62it/s]\n", + "========= Model Summary ==========\n", + "== ==\n", + "== Model name: SAE ==\n", + "== ==\n", + "== Current iteration: 202787 ==\n", + "== ==\n", + "==------- Model Options --------==\n", + "== ==\n", + "== batch_size: 10 ==\n", + "== sort_by_yaw: True ==\n", + "== random_flip: False ==\n", + "== resolution: 192 ==\n", + "== face_type: f ==\n", + "== learn_mask: True ==\n", + "== optimizer_mode: 1 ==\n", + "== archi: df ==\n", + "== ae_dims: 512 ==\n", + "== e_ch_dims: 42 ==\n", + "== d_ch_dims: 21 ==\n", + "== multiscale_decoder: True ==\n", + "== ca_weights: True ==\n", + "== pixel_loss: False ==\n", + "== face_style_power: 0.0 ==\n", + "== bg_style_power: 0.0 ==\n", + "== apply_random_ct: 0 ==\n", + "== clipgrad: True ==\n", + "== batch_cap: 10 ==\n", + "== ping_pong: True ==\n", + "== paddle: ping ==\n", + "== ping_pong_iter: 1000 ==\n", + "== ==\n", + "==--------- Running On ---------==\n", + "== ==\n", + "== Device index: 0 ==\n", + "== Name: Tesla T4 ==\n", + "== VRAM: 15.00GB ==\n", + "== ==\n", + "==================================\n", + "Starting. Press \"Enter\" to stop training and save model.\n", + "Process Process-2:\n", + "Traceback (most recent call last):\n", + " File \"/usr/lib/python3.6/multiprocessing/process.py\", line 258, in _bootstrap\n", + " self.run()\n", + " File \"/usr/lib/python3.6/multiprocessing/process.py\", line 93, in run\n", + " self._target(*self._args, **self._kwargs)\n", + " File \"/content/DeepFaceLab/utils/iter_utils.py\", line 39, in process_func\n", + " gen_data = next (self.generator_func)\n", + " File \"/content/DeepFaceLab/samplelib/SampleGeneratorFace.py\", line 85, in batch_func\n", + " raise ValueError('Not enough training data. Gather more faces!')\n", + "ValueError: Not enough training data. Gather more faces!\n", + "/usr/lib/python3.6/multiprocessing/semaphore_tracker.py:143: UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown\n", + " len(cache))\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "avAcSL_uvtq_", + "colab_type": "text" + }, + "source": [ + "# Convert frames" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "A3Y8K22Sv9Gn", + "colab_type": "code", + "cellView": "form", + "colab": {} + }, + "source": [ + "#@title Convert\n", + "Model = \"SAE\" #@param [\"SAE\", \"H128\", \"LIAEF128\", \"DF\", \"RecycleGAN\"]\n", + "\n", + "cmd = \"DeepFaceLab/main.py convert --input-dir workspace/data_dst --output-dir workspace/data_dst/merged --aligned-dir workspace/data_dst/aligned --model-dir workspace/model --model \"+Model\n", + "\n", + "%cd \"/content\"\n", + "!python $cmd" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "JNeGfiZpxlnz", + "colab_type": "code", + "cellView": "form", + "colab": {} + }, + "source": [ + "#@title Get result video and copy to Drive \n", + "\n", + "!python DeepFaceLab/main.py videoed video-from-sequence --input-dir workspace/data_dst/merged --output-file workspace/result.mp4 --reference-file workspace/data_dst.mp4\n", + "!cp /content/workspace/result.mp4 /content/drive/My\\ Drive/" + ], + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file