diff --git a/.gitignore b/.gitignore
index fd548c0..5b6e4b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -135,4 +135,8 @@ checkpoints/
*.zip
*.avi
*.pdf
-*.pptx
\ No newline at end of file
+*.pptx
+
+*.pth
+*.onnx
+wandb/
\ No newline at end of file
diff --git a/MultiSpecific.ipynb b/MultiSpecific.ipynb
index b7b0fd6..ef13d1c 100644
--- a/MultiSpecific.ipynb
+++ b/MultiSpecific.ipynb
@@ -1 +1 @@
-{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"MultiSpecific.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyNw8SfPWhG77cf/e7YZd178"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"},"accelerator":"GPU"},"cells":[{"cell_type":"markdown","metadata":{"id":"7_gtFoV8BuRx"},"source":["This is an example of SimSwap on processing video with multiple faces with designated sources.\n","\n","Code path: https://github.com/neuralchen/SimSwap\n","Paper path: https://arxiv.org/pdf/2106.06340v1.pdf."]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"0Y1RfpzsCAl9","executionInfo":{"status":"ok","timestamp":1625380781426,"user_tz":-480,"elapsed":586,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"2a897b34-72f1-4515-ac6f-2f0e2d4ea4f7"},"source":["## make sure you are using a runtime with GPU\n","## you can check at Runtime/Change runtime type in the top bar.\n","!nvidia-smi"],"execution_count":1,"outputs":[{"output_type":"stream","text":["Sun Jul 4 06:39:39 2021 \n","+-----------------------------------------------------------------------------+\n","| NVIDIA-SMI 465.27 Driver Version: 460.32.03 CUDA Version: 11.2 |\n","|-------------------------------+----------------------+----------------------+\n","| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n","| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n","| | | MIG M. |\n","|===============================+======================+======================|\n","| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n","| N/A 45C P8 9W / 70W | 0MiB / 15109MiB | 0% Default |\n","| | | N/A |\n","+-------------------------------+----------------------+----------------------+\n"," \n","+-----------------------------------------------------------------------------+\n","| Processes: |\n","| GPU GI CI PID Type Process name GPU Memory |\n","| ID ID Usage |\n","|=============================================================================|\n","| No running processes found |\n","+-----------------------------------------------------------------------------+\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"0Qzzx2UpDkqw"},"source":["All file changes make by this notebook are temporary. \n","You can try to mount your own google drive to store files if you wang.\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"VA_4CeWZCHLP","executionInfo":{"status":"ok","timestamp":1625380786661,"user_tz":-480,"elapsed":4693,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"d0665552-be92-45b0-aab2-f84c619a51fb"},"source":["!git clone https://github.com/neuralchen/SimSwap\n","!cd SimSwap && git pull"],"execution_count":2,"outputs":[{"output_type":"stream","text":["Cloning into 'SimSwap'...\n","remote: Enumerating objects: 667, done.\u001b[K\n","remote: Counting objects: 100% (48/48), done.\u001b[K\n","remote: Compressing objects: 100% (35/35), done.\u001b[K\n","remote: Total 667 (delta 19), reused 28 (delta 13), pack-reused 619\u001b[K\n","Receiving objects: 100% (667/667), 132.14 MiB | 44.44 MiB/s, done.\n","Resolving deltas: 100% (292/292), done.\n","Already up to date.\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"Y5K4au_UCkKn","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1625380797906,"user_tz":-480,"elapsed":11253,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"7429f153-bc6d-48c2-eb3c-21f1f02fede9"},"source":["!pip install insightface==0.2.1 onnxruntime moviepy\n","!pip install googledrivedownloader\n","!pip install imageio==2.4.1"],"execution_count":3,"outputs":[{"output_type":"stream","text":["Collecting insightface==0.2.1\n"," Downloading https://files.pythonhosted.org/packages/ee/1e/6395bbe0db665f187c8e49266cda54fcf661f182192370d409423e4943e4/insightface-0.2.1-py2.py3-none-any.whl\n","Collecting onnxruntime\n","\u001b[?25l Downloading https://files.pythonhosted.org/packages/f9/76/3d0f8bb2776961c7335693df06eccf8d099e48fa6fb552c7546867192603/onnxruntime-1.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5MB)\n","\u001b[K |████████████████████████████████| 4.5MB 37.5MB/s \n","\u001b[?25hRequirement already satisfied: moviepy in /usr/local/lib/python3.7/dist-packages (0.2.3.5)\n","Requirement already satisfied: scikit-learn in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (0.22.2.post1)\n","Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (2.23.0)\n","Collecting onnx\n","\u001b[?25l Downloading https://files.pythonhosted.org/packages/3f/9b/54c950d3256e27f970a83cd0504efb183a24312702deed0179453316dbd0/onnx-1.9.0-cp37-cp37m-manylinux2010_x86_64.whl (12.2MB)\n","\u001b[K |████████████████████████████████| 12.2MB 32.2MB/s \n","\u001b[?25hRequirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (3.2.2)\n","Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (7.1.2)\n","Requirement already satisfied: scikit-image in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (0.16.2)\n","Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (4.1.2.30)\n","Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (4.41.1)\n","Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.4.1)\n","Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.19.5)\n","Requirement already satisfied: easydict in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.9)\n","Requirement already satisfied: flatbuffers in /usr/local/lib/python3.7/dist-packages (from onnxruntime) (1.12)\n","Requirement already satisfied: protobuf in /usr/local/lib/python3.7/dist-packages (from onnxruntime) (3.12.4)\n","Requirement already satisfied: imageio<3.0,>=2.1.2 in /usr/local/lib/python3.7/dist-packages (from moviepy) (2.4.1)\n","Requirement already satisfied: decorator<5.0,>=4.0.2 in /usr/local/lib/python3.7/dist-packages (from moviepy) (4.4.2)\n","Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.7/dist-packages (from scikit-learn->insightface==0.2.1) (1.0.1)\n","Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (3.0.4)\n","Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (1.24.3)\n","Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (2021.5.30)\n","Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (2.10)\n","Requirement already satisfied: typing-extensions>=3.6.2.1 in /usr/local/lib/python3.7/dist-packages (from onnx->insightface==0.2.1) (3.7.4.3)\n","Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from onnx->insightface==0.2.1) (1.15.0)\n","Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (2.8.1)\n","Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (0.10.0)\n","Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (2.4.7)\n","Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (1.3.1)\n","Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->insightface==0.2.1) (2.5.1)\n","Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->insightface==0.2.1) (1.1.1)\n","Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from protobuf->onnxruntime) (57.0.0)\n","Installing collected packages: onnx, insightface, onnxruntime\n","Successfully installed insightface-0.2.1 onnx-1.9.0 onnxruntime-1.8.0\n","Requirement already satisfied: googledrivedownloader in /usr/local/lib/python3.7/dist-packages (0.4)\n","Requirement already satisfied: imageio==2.4.1 in /usr/local/lib/python3.7/dist-packages (2.4.1)\n","Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from imageio==2.4.1) (1.19.5)\n","Requirement already satisfied: pillow in /usr/local/lib/python3.7/dist-packages (from imageio==2.4.1) (7.1.2)\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gQ7ZoIbLFCye","executionInfo":{"status":"ok","timestamp":1625380798405,"user_tz":-480,"elapsed":533,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"8448a0a3-a19e-44c2-a044-f4d3f9152e91"},"source":["import os\n","os.chdir(\"SimSwap\")\n","!ls"],"execution_count":4,"outputs":[{"output_type":"stream","text":[" crop_224\t simswaplogo\n"," data\t\t test_one_image.py\n"," demo_file\t test_video_swapmulti.py\n"," docs\t\t test_video_swap_multispecific.py\n"," insightface_func test_video_swapsingle.py\n"," LICENSE\t test_video_swapspecific.py\n"," models\t\t test_wholeimage_swapmulti.py\n"," options\t test_wholeimage_swap_multispecific.py\n"," output\t\t test_wholeimage_swapsingle.py\n"," README.md\t test_wholeimage_swapspecific.py\n","'SimSwap colab.ipynb' util\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"ZvGp-p0nOmKE","executionInfo":{"status":"ok","timestamp":1625380798407,"user_tz":-480,"elapsed":17,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}}},"source":["## You can upload filed manually\n","# from google.colab import drive\n","# drive.mount('/content/gdrive')"],"execution_count":5,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gLti1J0pEFjJ","executionInfo":{"status":"ok","timestamp":1625380813268,"user_tz":-480,"elapsed":14876,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"99dc9306-9b9a-475d-cc7d-a3f423bd1e81"},"source":["from google_drive_downloader import GoogleDriveDownloader\n","\n","### it seems that google drive link may not be permenant, you can find this ID from our open url.\n","# GoogleDriveDownloader.download_file_from_google_drive(file_id='1TLNdIufzwesDbyr_nVTR7Zrx9oRHLM_N',\n","# dest_path='./arcface_model/arcface_checkpoint.tar')\n","# GoogleDriveDownloader.download_file_from_google_drive(file_id='1PXkRiBUYbu1xWpQyDEJvGKeqqUFthJcI',\n","# dest_path='./checkpoints.zip')\n","\n","!wget -P ./arcface_model https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar\n","!wget https://github.com/neuralchen/SimSwap/releases/download/1.0/checkpoints.zip\n","!unzip ./checkpoints.zip -d ./checkpoints"],"execution_count":6,"outputs":[{"output_type":"stream","text":["--2021-07-04 06:39:56-- https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar\n","Resolving github.com (github.com)... 140.82.114.3\n","Connecting to github.com (github.com)|140.82.114.3|:443... connected.\n","HTTP request sent, awaiting response... 302 Found\n","Location: https://github-releases.githubusercontent.com/374891081/e17b9d00-dcb8-11eb-8c4f-1412bcea78a6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063956Z&X-Amz-Expires=300&X-Amz-Signature=b6d431c65405e894ddc994061c5fe8fe87db4e71e702513aec01f398a1004825&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Darcface_checkpoint.tar&response-content-type=application%2Foctet-stream [following]\n","--2021-07-04 06:39:56-- https://github-releases.githubusercontent.com/374891081/e17b9d00-dcb8-11eb-8c4f-1412bcea78a6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063956Z&X-Amz-Expires=300&X-Amz-Signature=b6d431c65405e894ddc994061c5fe8fe87db4e71e702513aec01f398a1004825&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Darcface_checkpoint.tar&response-content-type=application%2Foctet-stream\n","Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n","Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 766871429 (731M) [application/octet-stream]\n","Saving to: ‘./arcface_model/arcface_checkpoint.tar’\n","\n","arcface_checkpoint. 100%[===================>] 731.34M 64.4MB/s in 11s \n","\n","2021-07-04 06:40:07 (68.4 MB/s) - ‘./arcface_model/arcface_checkpoint.tar’ saved [766871429/766871429]\n","\n","--2021-07-04 06:40:07-- https://github.com/neuralchen/SimSwap/releases/download/1.0/checkpoints.zip\n","Resolving github.com (github.com)... 140.82.113.3\n","Connecting to github.com (github.com)|140.82.113.3|:443... connected.\n","HTTP request sent, awaiting response... 302 Found\n","Location: https://github-releases.githubusercontent.com/374891081/a8dac400-dcb6-11eb-933f-977cd7f5f554?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063831Z&X-Amz-Expires=300&X-Amz-Signature=3fd2850d03abb9301bf5ba5969d82eb73cb0b940b85e45de2e1e34f1ba2eaf09&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Dcheckpoints.zip&response-content-type=application%2Foctet-stream [following]\n","--2021-07-04 06:40:07-- https://github-releases.githubusercontent.com/374891081/a8dac400-dcb6-11eb-933f-977cd7f5f554?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063831Z&X-Amz-Expires=300&X-Amz-Signature=3fd2850d03abb9301bf5ba5969d82eb73cb0b940b85e45de2e1e34f1ba2eaf09&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Dcheckpoints.zip&response-content-type=application%2Foctet-stream\n","Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n","Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 256461775 (245M) [application/octet-stream]\n","Saving to: ‘checkpoints.zip’\n","\n","checkpoints.zip 100%[===================>] 244.58M 219MB/s in 1.1s \n","\n","2021-07-04 06:40:08 (219 MB/s) - ‘checkpoints.zip’ saved [256461775/256461775]\n","\n","Archive: ./checkpoints.zip\n"," creating: ./checkpoints/people/\n"," inflating: ./checkpoints/people/iter.txt \n"," inflating: ./checkpoints/people/latest_net_D1.pth \n"," inflating: ./checkpoints/people/latest_net_D2.pth \n"," inflating: ./checkpoints/people/latest_net_G.pth \n"," inflating: ./checkpoints/people/loss_log.txt \n"," inflating: ./checkpoints/people/opt.txt \n"," creating: ./checkpoints/people/web/\n"," creating: ./checkpoints/people/web/images/\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"fJ9DYRrCPIUL","executionInfo":{"status":"ok","timestamp":1625380821122,"user_tz":-480,"elapsed":7869,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"a3d1d841-440c-4244-8045-cb0ce3cc81fd"},"source":["!wget --no-check-certificate \"https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKDcV3nwMJulRGhbtHdkheehR5TArc52UjudUYNXAEvKCii2O5LAmzGCGK6IfleocxuDeoKxDZkNzDRSt4ZUlEt8GlSOpCXAFEkBwaZimtWGDRbpIGpb_pz9Nq5jATBQpezBS6G_UtspWTkgrXHHxhviV2nWy8APPx134zOZrUIbkSF6xnsqzs3uZ_SEX_m9Rey0ykpx9w\" -O antelope.zip\n","!unzip ./antelope.zip -d ./insightface_func/models/"],"execution_count":7,"outputs":[{"output_type":"stream","text":["--2021-07-04 06:40:11-- https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKDcV3nwMJulRGhbtHdkheehR5TArc52UjudUYNXAEvKCii2O5LAmzGCGK6IfleocxuDeoKxDZkNzDRSt4ZUlEt8GlSOpCXAFEkBwaZimtWGDRbpIGpb_pz9Nq5jATBQpezBS6G_UtspWTkgrXHHxhviV2nWy8APPx134zOZrUIbkSF6xnsqzs3uZ_SEX_m9Rey0ykpx9w\n","Resolving sh23tw.dm.files.1drv.com (sh23tw.dm.files.1drv.com)... 13.107.42.12\n","Connecting to sh23tw.dm.files.1drv.com (sh23tw.dm.files.1drv.com)|13.107.42.12|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 248024513 (237M) [application/zip]\n","Saving to: ‘antelope.zip’\n","\n","antelope.zip 100%[===================>] 236.53M 52.4MB/s in 4.7s \n","\n","2021-07-04 06:40:16 (49.9 MB/s) - ‘antelope.zip’ saved [248024513/248024513]\n","\n","Archive: ./antelope.zip\n"," creating: ./insightface_func/models/antelope/\n"," inflating: ./insightface_func/models/antelope/glintr100.onnx \n"," inflating: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx \n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"PfSsND36EMvn","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1625380827902,"user_tz":-480,"elapsed":6811,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"8130e97d-b4a0-4988-85fb-e2bc3e755259"},"source":["import cv2\n","import torch\n","import fractions\n","import numpy as np\n","from PIL import Image\n","import torch.nn.functional as F\n","from torchvision import transforms\n","from models.models import create_model\n","from options.test_options import TestOptions\n","from insightface_func.face_detect_crop_multi import Face_detect_crop\n","from util.videoswap_multispecific import video_swap\n","import os\n","import glob"],"execution_count":8,"outputs":[{"output_type":"stream","text":["Imageio: 'ffmpeg-linux64-v3.3.1' was not found on your computer; downloading it now.\n","Try 1. Download from https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg-linux64-v3.3.1 (43.8 MB)\n","Downloading: 8192/45929032 bytes (0.0%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b3432448/45929032 bytes (7.5%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b7036928/45929032 bytes (15.3%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b10641408/45929032 bytes (23.2%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b14278656/45929032 bytes (31.1%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b18104320/45929032 bytes (39.4%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b21954560/45929032 bytes (47.8%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b25780224/45929032 bytes (56.1%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b29736960/45929032 bytes (64.7%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b33488896/45929032 bytes (72.9%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b37093376/45929032 bytes (80.8%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b40689664/45929032 bytes (88.6%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b44392448/45929032 bytes (96.7%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b45929032/45929032 bytes (100.0%)\n"," Done\n","File saved as /root/.imageio/ffmpeg/ffmpeg-linux64-v3.3.1.\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"rxSbZ2EDNDlf","executionInfo":{"status":"ok","timestamp":1625380827903,"user_tz":-480,"elapsed":12,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}}},"source":["def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0\n","\n","transformer = transforms.Compose([\n"," transforms.ToTensor(),\n"," #transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n"," ])\n","\n","transformer_Arcface = transforms.Compose([\n"," transforms.ToTensor(),\n"," transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n"," ])\n"],"execution_count":9,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ye8iS0UVPMRg","executionInfo":{"status":"ok","timestamp":1625380828574,"user_tz":-480,"elapsed":680,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"cb5a4b02-b1d0-4ff8-f542-5c1b3c9703d9"},"source":["!ls ./checkpoints"],"execution_count":10,"outputs":[{"output_type":"stream","text":["people\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"wwJOwR9LNKRz","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1625380828576,"user_tz":-480,"elapsed":13,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"0f92f785-4d9c-4130-b24d-76871b2dafba"},"source":["opt = TestOptions()\n","opt.initialize()\n","opt.parser.add_argument('-f') ## dummy arg to avoid bug\n","opt = opt.parse()\n","opt.multisepcific_dir = './demo_file/multispecific' ## or replace it with folder from your own google drive\n"," ## and remember to follow the dir structure in usage.md\n","opt.video_path = './demo_file/multi_people_1080p.mp4' ## or replace it with video from your own google drive\n","opt.output_path = './output/multi_test_multispecific.mp4'\n","opt.temp_path = './tmp'\n","opt.Arc_path = './arcface_model/arcface_checkpoint.tar'\n","opt.name = 'people'\n","opt.isTrain = False\n","\n","crop_size = 224\n"],"execution_count":11,"outputs":[{"output_type":"stream","text":["------------ Options -------------\n","Arc_path: models/BEST_checkpoint.tar\n","aspect_ratio: 1.0\n","batchSize: 8\n","checkpoints_dir: ./checkpoints\n","cluster_path: features_clustered_010.npy\n","data_type: 32\n","dataroot: ./datasets/cityscapes/\n","display_winsize: 512\n","engine: None\n","export_onnx: None\n","f: /root/.local/share/jupyter/runtime/kernel-19937219-895d-4d02-9a72-5cfa0e889adf.json\n","feat_num: 3\n","fineSize: 512\n","fp16: False\n","gpu_ids: [0]\n","how_many: 50\n","id_thres: 0.03\n","image_size: 224\n","input_nc: 3\n","instance_feat: False\n","isTrain: False\n","label_feat: False\n","label_nc: 0\n","latent_size: 512\n","loadSize: 1024\n","load_features: False\n","local_rank: 0\n","max_dataset_size: inf\n","model: pix2pixHD\n","multisepcific_dir: ./demo_file/multispecific\n","nThreads: 2\n","n_blocks_global: 6\n","n_blocks_local: 3\n","n_clusters: 10\n","n_downsample_E: 4\n","n_downsample_global: 3\n","n_local_enhancers: 1\n","name: people\n","nef: 16\n","netG: global\n","ngf: 64\n","niter_fix_global: 0\n","no_flip: False\n","no_instance: False\n","no_simswaplogo: False\n","norm: batch\n","norm_G: spectralspadesyncbatch3x3\n","ntest: inf\n","onnx: None\n","output_nc: 3\n","output_path: ./output/\n","phase: test\n","pic_a_path: ./crop_224/gdg.jpg\n","pic_b_path: ./crop_224/zrf.jpg\n","pic_specific_path: ./crop_224/zrf.jpg\n","resize_or_crop: scale_width\n","results_dir: ./results/\n","semantic_nc: 3\n","serial_batches: False\n","temp_path: ./temp_results\n","tf_log: False\n","use_dropout: False\n","use_encoded_image: False\n","verbose: False\n","video_path: ./demo_file/multi_people_1080p.mp4\n","which_epoch: latest\n","-------------- End ----------------\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"UFt8zQrAMq9F","executionInfo":{"status":"ok","timestamp":1625381428564,"user_tz":-480,"elapsed":599996,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"46188013-3f6d-4174-9959-d1fd203dcc0d"},"source":["pic_specific = opt.pic_specific_path\n","crop_size = 224\n","multisepcific_dir = opt.multisepcific_dir\n","\n","torch.nn.Module.dump_patches = True\n","model = create_model(opt)\n","model.eval()\n","\n","app = Face_detect_crop(name='antelope', root='./insightface_func/models')\n","app.prepare(ctx_id= 0, det_thresh=0.6, det_size=(640,640))\n","# The specific person to be swapped(source)\n","source_specific_id_nonorm_list = []\n","source_path = os.path.join(multisepcific_dir,'SRC_*')\n","source_specific_images_path = sorted(glob.glob(source_path))\n","\n","for source_specific_image_path in source_specific_images_path:\n"," specific_person_whole = cv2.imread(source_specific_image_path)\n"," specific_person_align_crop, _ = app.get(specific_person_whole,crop_size)\n"," specific_person_align_crop_pil = Image.fromarray(cv2.cvtColor(specific_person_align_crop[0],cv2.COLOR_BGR2RGB)) \n"," specific_person = transformer_Arcface(specific_person_align_crop_pil)\n"," specific_person = specific_person.view(-1, specific_person.shape[0], specific_person.shape[1], specific_person.shape[2])\n"," # convert numpy to tensor\n"," specific_person = specific_person.cuda()\n"," #create latent id\n"," specific_person_downsample = F.interpolate(specific_person, scale_factor=0.5)\n"," specific_person_id_nonorm = model.netArc(specific_person_downsample)\n"," source_specific_id_nonorm_list.append(specific_person_id_nonorm.clone())\n","\n","# The person who provides id information (list)\n","target_id_norm_list = []\n","target_path = os.path.join(multisepcific_dir,'DST_*')\n","target_images_path = sorted(glob.glob(target_path))\n","\n","for target_image_path in target_images_path:\n"," img_a_whole = cv2.imread(target_image_path)\n"," img_a_align_crop, _ = app.get(img_a_whole,crop_size)\n"," img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0],cv2.COLOR_BGR2RGB)) \n"," img_a = transformer_Arcface(img_a_align_crop_pil)\n"," img_id = img_a.view(-1, img_a.shape[0], img_a.shape[1], img_a.shape[2])\n"," # convert numpy to tensor\n"," img_id = img_id.cuda()\n"," #create latent id\n"," img_id_downsample = F.interpolate(img_id, scale_factor=0.5)\n"," latend_id = model.netArc(img_id_downsample)\n"," latend_id = F.normalize(latend_id, p=2, dim=1)\n"," target_id_norm_list.append(latend_id.clone())\n"," \n","assert len(target_id_norm_list) == len(source_specific_id_nonorm_list), \"The number of images in source and target directory must be same !!!\"\n","video_swap(opt.video_path, target_id_norm_list,source_specific_id_nonorm_list, opt.id_thres, \\\n"," model, app, opt.output_path,temp_results_dir=opt.temp_path,no_simswaplogo=opt.no_simswaplogo)"],"execution_count":12,"outputs":[{"output_type":"stream","text":["input mean and std: 127.5 127.5\n","find model: ./insightface_func/models/antelope/glintr100.onnx recognition\n","find model: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx detection\n","set det-size: (640, 640)\n"],"name":"stdout"},{"output_type":"stream","text":["\r 0%| | 0/594 [00:00, ?it/s]"],"name":"stderr"},{"output_type":"stream","text":["(142, 366, 4)\n"],"name":"stdout"},{"output_type":"stream","text":["100%|██████████| 594/594 [08:28<00:00, 1.17it/s]\n"],"name":"stderr"},{"output_type":"stream","text":["[MoviePy] >>>> Building video ./output/multi_test_multispecific.mp4\n","[MoviePy] Writing audio in multi_test_multispecificTEMP_MPY_wvf_snd.mp3\n"],"name":"stdout"},{"output_type":"stream","text":["100%|██████████| 438/438 [00:00<00:00, 832.16it/s]"],"name":"stderr"},{"output_type":"stream","text":["[MoviePy] Done.\n","[MoviePy] Writing video ./output/multi_test_multispecific.mp4\n"],"name":"stdout"},{"output_type":"stream","text":["\n","100%|██████████| 595/595 [00:53<00:00, 11.11it/s]\n"],"name":"stderr"},{"output_type":"stream","text":["[MoviePy] Done.\n","[MoviePy] >>>> Video ready: ./output/multi_test_multispecific.mp4 \n","\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"Rty2GsyZZrI6"},"source":[],"execution_count":null,"outputs":[]}]}
\ No newline at end of file
+{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"MultiSpecific.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyNw8SfPWhG77cf/e7YZd178"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"},"accelerator":"GPU"},"cells":[{"cell_type":"markdown","metadata":{"id":"7_gtFoV8BuRx"},"source":["This is an example of SimSwap on processing video with multiple faces with designated sources.\n","\n","Code path: https://github.com/neuralchen/SimSwap\n","Paper path: https://arxiv.org/pdf/2106.06340v1.pdf."]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"0Y1RfpzsCAl9","executionInfo":{"status":"ok","timestamp":1625380781426,"user_tz":-480,"elapsed":586,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"2a897b34-72f1-4515-ac6f-2f0e2d4ea4f7"},"source":["## make sure you are using a runtime with GPU\n","## you can check at Runtime/Change runtime type in the top bar.\n","!nvidia-smi"],"execution_count":1,"outputs":[{"output_type":"stream","text":["Sun Jul 4 06:39:39 2021 \n","+-----------------------------------------------------------------------------+\n","| NVIDIA-SMI 465.27 Driver Version: 460.32.03 CUDA Version: 11.2 |\n","|-------------------------------+----------------------+----------------------+\n","| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n","| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n","| | | MIG M. |\n","|===============================+======================+======================|\n","| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n","| N/A 45C P8 9W / 70W | 0MiB / 15109MiB | 0% Default |\n","| | | N/A |\n","+-------------------------------+----------------------+----------------------+\n"," \n","+-----------------------------------------------------------------------------+\n","| Processes: |\n","| GPU GI CI PID Type Process name GPU Memory |\n","| ID ID Usage |\n","|=============================================================================|\n","| No running processes found |\n","+-----------------------------------------------------------------------------+\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"0Qzzx2UpDkqw"},"source":["All file changes make by this notebook are temporary. \n","You can try to mount your own google drive to store files if you wang.\n"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"VA_4CeWZCHLP","executionInfo":{"status":"ok","timestamp":1625380786661,"user_tz":-480,"elapsed":4693,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"d0665552-be92-45b0-aab2-f84c619a51fb"},"source":["!git clone https://github.com/neuralchen/SimSwap\n","!cd SimSwap && git pull"],"execution_count":2,"outputs":[{"output_type":"stream","text":["Cloning into 'SimSwap'...\n","remote: Enumerating objects: 667, done.\u001b[K\n","remote: Counting objects: 100% (48/48), done.\u001b[K\n","remote: Compressing objects: 100% (35/35), done.\u001b[K\n","remote: Total 667 (delta 19), reused 28 (delta 13), pack-reused 619\u001b[K\n","Receiving objects: 100% (667/667), 132.14 MiB | 44.44 MiB/s, done.\n","Resolving deltas: 100% (292/292), done.\n","Already up to date.\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"Y5K4au_UCkKn","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1625380797906,"user_tz":-480,"elapsed":11253,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"7429f153-bc6d-48c2-eb3c-21f1f02fede9"},"source":["!pip install insightface==0.2.1 onnxruntime moviepy\n","!pip install googledrivedownloader\n","!pip install imageio==2.4.1"],"execution_count":3,"outputs":[{"output_type":"stream","text":["Collecting insightface==0.2.1\n"," Downloading https://files.pythonhosted.org/packages/ee/1e/6395bbe0db665f187c8e49266cda54fcf661f182192370d409423e4943e4/insightface-0.2.1-py2.py3-none-any.whl\n","Collecting onnxruntime\n","\u001b[?25l Downloading https://files.pythonhosted.org/packages/f9/76/3d0f8bb2776961c7335693df06eccf8d099e48fa6fb552c7546867192603/onnxruntime-1.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5MB)\n","\u001b[K |████████████████████████████████| 4.5MB 37.5MB/s \n","\u001b[?25hRequirement already satisfied: moviepy in /usr/local/lib/python3.7/dist-packages (0.2.3.5)\n","Requirement already satisfied: scikit-learn in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (0.22.2.post1)\n","Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (2.23.0)\n","Collecting onnx\n","\u001b[?25l Downloading https://files.pythonhosted.org/packages/3f/9b/54c950d3256e27f970a83cd0504efb183a24312702deed0179453316dbd0/onnx-1.9.0-cp37-cp37m-manylinux2010_x86_64.whl (12.2MB)\n","\u001b[K |████████████████████████████████| 12.2MB 32.2MB/s \n","\u001b[?25hRequirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (3.2.2)\n","Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (7.1.2)\n","Requirement already satisfied: scikit-image in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (0.16.2)\n","Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (4.1.2.30)\n","Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (4.41.1)\n","Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.4.1)\n","Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.19.5)\n","Requirement already satisfied: easydict in /usr/local/lib/python3.7/dist-packages (from insightface==0.2.1) (1.9)\n","Requirement already satisfied: flatbuffers in /usr/local/lib/python3.7/dist-packages (from onnxruntime) (1.12)\n","Requirement already satisfied: protobuf in /usr/local/lib/python3.7/dist-packages (from onnxruntime) (3.12.4)\n","Requirement already satisfied: imageio<3.0,>=2.1.2 in /usr/local/lib/python3.7/dist-packages (from moviepy) (2.4.1)\n","Requirement already satisfied: decorator<5.0,>=4.0.2 in /usr/local/lib/python3.7/dist-packages (from moviepy) (4.4.2)\n","Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.7/dist-packages (from scikit-learn->insightface==0.2.1) (1.0.1)\n","Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (3.0.4)\n","Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (1.24.3)\n","Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (2021.5.30)\n","Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->insightface==0.2.1) (2.10)\n","Requirement already satisfied: typing-extensions>=3.6.2.1 in /usr/local/lib/python3.7/dist-packages (from onnx->insightface==0.2.1) (3.7.4.3)\n","Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from onnx->insightface==0.2.1) (1.15.0)\n","Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (2.8.1)\n","Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (0.10.0)\n","Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (2.4.7)\n","Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->insightface==0.2.1) (1.3.1)\n","Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->insightface==0.2.1) (2.5.1)\n","Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->insightface==0.2.1) (1.1.1)\n","Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from protobuf->onnxruntime) (57.0.0)\n","Installing collected packages: onnx, insightface, onnxruntime\n","Successfully installed insightface-0.2.1 onnx-1.9.0 onnxruntime-1.8.0\n","Requirement already satisfied: googledrivedownloader in /usr/local/lib/python3.7/dist-packages (0.4)\n","Requirement already satisfied: imageio==2.4.1 in /usr/local/lib/python3.7/dist-packages (2.4.1)\n","Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from imageio==2.4.1) (1.19.5)\n","Requirement already satisfied: pillow in /usr/local/lib/python3.7/dist-packages (from imageio==2.4.1) (7.1.2)\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gQ7ZoIbLFCye","executionInfo":{"status":"ok","timestamp":1625380798405,"user_tz":-480,"elapsed":533,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"8448a0a3-a19e-44c2-a044-f4d3f9152e91"},"source":["import os\n","os.chdir(\"SimSwap\")\n","!ls"],"execution_count":4,"outputs":[{"output_type":"stream","text":[" crop_224\t simswaplogo\n"," data\t\t test_one_image.py\n"," demo_file\t test_video_swapmulti.py\n"," docs\t\t test_video_swap_multispecific.py\n"," insightface_func test_video_swapsingle.py\n"," LICENSE\t test_video_swapspecific.py\n"," models\t\t test_wholeimage_swapmulti.py\n"," options\t test_wholeimage_swap_multispecific.py\n"," output\t\t test_wholeimage_swapsingle.py\n"," README.md\t test_wholeimage_swapspecific.py\n","'SimSwap colab.ipynb' util\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"ZvGp-p0nOmKE","executionInfo":{"status":"ok","timestamp":1625380798407,"user_tz":-480,"elapsed":17,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}}},"source":["## You can upload filed manually\n","# from google.colab import drive\n","# drive.mount('/content/gdrive')"],"execution_count":5,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"gLti1J0pEFjJ","executionInfo":{"status":"ok","timestamp":1625380813268,"user_tz":-480,"elapsed":14876,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"99dc9306-9b9a-475d-cc7d-a3f423bd1e81"},"source":["from google_drive_downloader import GoogleDriveDownloader\n","\n","### it seems that google drive link may not be permenant, you can find this ID from our open url.\n","# GoogleDriveDownloader.download_file_from_google_drive(file_id='1TLNdIufzwesDbyr_nVTR7Zrx9oRHLM_N',\n","# dest_path='./arcface_model/arcface_checkpoint.tar')\n","# GoogleDriveDownloader.download_file_from_google_drive(file_id='1PXkRiBUYbu1xWpQyDEJvGKeqqUFthJcI',\n","# dest_path='./checkpoints.zip')\n","\n","!wget -P ./arcface_model https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar\n","!wget https://github.com/neuralchen/SimSwap/releases/download/1.0/checkpoints.zip\n","!unzip ./checkpoints.zip -d ./checkpoints\n","!wget -P ./parsing_model/checkpoint https://github.com/neuralchen/SimSwap/releases/download/1.0/79999_iter.pth"],"execution_count":6,"outputs":[{"output_type":"stream","text":["--2021-07-04 06:39:56-- https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar\n","Resolving github.com (github.com)... 140.82.114.3\n","Connecting to github.com (github.com)|140.82.114.3|:443... connected.\n","HTTP request sent, awaiting response... 302 Found\n","Location: https://github-releases.githubusercontent.com/374891081/e17b9d00-dcb8-11eb-8c4f-1412bcea78a6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063956Z&X-Amz-Expires=300&X-Amz-Signature=b6d431c65405e894ddc994061c5fe8fe87db4e71e702513aec01f398a1004825&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Darcface_checkpoint.tar&response-content-type=application%2Foctet-stream [following]\n","--2021-07-04 06:39:56-- https://github-releases.githubusercontent.com/374891081/e17b9d00-dcb8-11eb-8c4f-1412bcea78a6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063956Z&X-Amz-Expires=300&X-Amz-Signature=b6d431c65405e894ddc994061c5fe8fe87db4e71e702513aec01f398a1004825&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Darcface_checkpoint.tar&response-content-type=application%2Foctet-stream\n","Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n","Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 766871429 (731M) [application/octet-stream]\n","Saving to: ‘./arcface_model/arcface_checkpoint.tar’\n","\n","arcface_checkpoint. 100%[===================>] 731.34M 64.4MB/s in 11s \n","\n","2021-07-04 06:40:07 (68.4 MB/s) - ‘./arcface_model/arcface_checkpoint.tar’ saved [766871429/766871429]\n","\n","--2021-07-04 06:40:07-- https://github.com/neuralchen/SimSwap/releases/download/1.0/checkpoints.zip\n","Resolving github.com (github.com)... 140.82.113.3\n","Connecting to github.com (github.com)|140.82.113.3|:443... connected.\n","HTTP request sent, awaiting response... 302 Found\n","Location: https://github-releases.githubusercontent.com/374891081/a8dac400-dcb6-11eb-933f-977cd7f5f554?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063831Z&X-Amz-Expires=300&X-Amz-Signature=3fd2850d03abb9301bf5ba5969d82eb73cb0b940b85e45de2e1e34f1ba2eaf09&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Dcheckpoints.zip&response-content-type=application%2Foctet-stream [following]\n","--2021-07-04 06:40:07-- https://github-releases.githubusercontent.com/374891081/a8dac400-dcb6-11eb-933f-977cd7f5f554?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210704%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210704T063831Z&X-Amz-Expires=300&X-Amz-Signature=3fd2850d03abb9301bf5ba5969d82eb73cb0b940b85e45de2e1e34f1ba2eaf09&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=374891081&response-content-disposition=attachment%3B%20filename%3Dcheckpoints.zip&response-content-type=application%2Foctet-stream\n","Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.108.154, 185.199.109.154, 185.199.110.154, ...\n","Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.108.154|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 256461775 (245M) [application/octet-stream]\n","Saving to: ‘checkpoints.zip’\n","\n","checkpoints.zip 100%[===================>] 244.58M 219MB/s in 1.1s \n","\n","2021-07-04 06:40:08 (219 MB/s) - ‘checkpoints.zip’ saved [256461775/256461775]\n","\n","Archive: ./checkpoints.zip\n"," creating: ./checkpoints/people/\n"," inflating: ./checkpoints/people/iter.txt \n"," inflating: ./checkpoints/people/latest_net_D1.pth \n"," inflating: ./checkpoints/people/latest_net_D2.pth \n"," inflating: ./checkpoints/people/latest_net_G.pth \n"," inflating: ./checkpoints/people/loss_log.txt \n"," inflating: ./checkpoints/people/opt.txt \n"," creating: ./checkpoints/people/web/\n"," creating: ./checkpoints/people/web/images/\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"fJ9DYRrCPIUL","executionInfo":{"status":"ok","timestamp":1625380821122,"user_tz":-480,"elapsed":7869,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"a3d1d841-440c-4244-8045-cb0ce3cc81fd"},"source":["!wget --no-check-certificate \"https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKDcV3nwMJulRGhbtHdkheehR5TArc52UjudUYNXAEvKCii2O5LAmzGCGK6IfleocxuDeoKxDZkNzDRSt4ZUlEt8GlSOpCXAFEkBwaZimtWGDRbpIGpb_pz9Nq5jATBQpezBS6G_UtspWTkgrXHHxhviV2nWy8APPx134zOZrUIbkSF6xnsqzs3uZ_SEX_m9Rey0ykpx9w\" -O antelope.zip\n","!unzip ./antelope.zip -d ./insightface_func/models/"],"execution_count":7,"outputs":[{"output_type":"stream","text":["--2021-07-04 06:40:11-- https://sh23tw.dm.files.1drv.com/y4mmGiIkNVigkSwOKDcV3nwMJulRGhbtHdkheehR5TArc52UjudUYNXAEvKCii2O5LAmzGCGK6IfleocxuDeoKxDZkNzDRSt4ZUlEt8GlSOpCXAFEkBwaZimtWGDRbpIGpb_pz9Nq5jATBQpezBS6G_UtspWTkgrXHHxhviV2nWy8APPx134zOZrUIbkSF6xnsqzs3uZ_SEX_m9Rey0ykpx9w\n","Resolving sh23tw.dm.files.1drv.com (sh23tw.dm.files.1drv.com)... 13.107.42.12\n","Connecting to sh23tw.dm.files.1drv.com (sh23tw.dm.files.1drv.com)|13.107.42.12|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 248024513 (237M) [application/zip]\n","Saving to: ‘antelope.zip’\n","\n","antelope.zip 100%[===================>] 236.53M 52.4MB/s in 4.7s \n","\n","2021-07-04 06:40:16 (49.9 MB/s) - ‘antelope.zip’ saved [248024513/248024513]\n","\n","Archive: ./antelope.zip\n"," creating: ./insightface_func/models/antelope/\n"," inflating: ./insightface_func/models/antelope/glintr100.onnx \n"," inflating: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx \n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"PfSsND36EMvn","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1625380827902,"user_tz":-480,"elapsed":6811,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"8130e97d-b4a0-4988-85fb-e2bc3e755259"},"source":["import cv2\n","import torch\n","import fractions\n","import numpy as np\n","from PIL import Image\n","import torch.nn.functional as F\n","from torchvision import transforms\n","from models.models import create_model\n","from options.test_options import TestOptions\n","from insightface_func.face_detect_crop_multi import Face_detect_crop\n","from util.videoswap_multispecific import video_swap\n","import os\n","import glob"],"execution_count":8,"outputs":[{"output_type":"stream","text":["Imageio: 'ffmpeg-linux64-v3.3.1' was not found on your computer; downloading it now.\n","Try 1. Download from https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg-linux64-v3.3.1 (43.8 MB)\n","Downloading: 8192/45929032 bytes (0.0%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b3432448/45929032 bytes (7.5%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b7036928/45929032 bytes (15.3%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b10641408/45929032 bytes (23.2%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b14278656/45929032 bytes (31.1%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b18104320/45929032 bytes (39.4%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b21954560/45929032 bytes (47.8%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b25780224/45929032 bytes (56.1%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b29736960/45929032 bytes (64.7%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b33488896/45929032 bytes (72.9%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b37093376/45929032 bytes (80.8%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b40689664/45929032 bytes (88.6%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b44392448/45929032 bytes (96.7%)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b45929032/45929032 bytes (100.0%)\n"," Done\n","File saved as /root/.imageio/ffmpeg/ffmpeg-linux64-v3.3.1.\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"rxSbZ2EDNDlf","executionInfo":{"status":"ok","timestamp":1625380827903,"user_tz":-480,"elapsed":12,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}}},"source":["def lcm(a, b): return abs(a * b) / fractions.gcd(a, b) if a and b else 0\n","\n","transformer = transforms.Compose([\n"," transforms.ToTensor(),\n"," #transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n"," ])\n","\n","transformer_Arcface = transforms.Compose([\n"," transforms.ToTensor(),\n"," transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])\n"," ])\n"],"execution_count":9,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ye8iS0UVPMRg","executionInfo":{"status":"ok","timestamp":1625380828574,"user_tz":-480,"elapsed":680,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"cb5a4b02-b1d0-4ff8-f542-5c1b3c9703d9"},"source":["!ls ./checkpoints"],"execution_count":10,"outputs":[{"output_type":"stream","text":["people\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"wwJOwR9LNKRz","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1625380828576,"user_tz":-480,"elapsed":13,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"0f92f785-4d9c-4130-b24d-76871b2dafba"},"source":["opt = TestOptions()\n","opt.initialize()\n","opt.parser.add_argument('-f') ## dummy arg to avoid bug\n","opt = opt.parse()\n","opt.multisepcific_dir = './demo_file/multispecific' ## or replace it with folder from your own google drive\n"," ## and remember to follow the dir structure in usage.md\n","opt.video_path = './demo_file/multi_people_1080p.mp4' ## or replace it with video from your own google drive\n","opt.output_path = './output/multi_test_multispecific.mp4'\n","opt.temp_path = './tmp'\n","opt.Arc_path = './arcface_model/arcface_checkpoint.tar'\n","opt.name = 'people'\n","opt.isTrain = False\n","opt.use_mask = True ## new feature up-to-date\n","\n","crop_size = opt.crop_size\n"],"execution_count":11,"outputs":[{"output_type":"stream","text":["------------ Options -------------\n","Arc_path: models/BEST_checkpoint.tar\n","aspect_ratio: 1.0\n","batchSize: 8\n","checkpoints_dir: ./checkpoints\n","cluster_path: features_clustered_010.npy\n","data_type: 32\n","dataroot: ./datasets/cityscapes/\n","display_winsize: 512\n","engine: None\n","export_onnx: None\n","f: /root/.local/share/jupyter/runtime/kernel-19937219-895d-4d02-9a72-5cfa0e889adf.json\n","feat_num: 3\n","fineSize: 512\n","fp16: False\n","gpu_ids: [0]\n","how_many: 50\n","id_thres: 0.03\n","image_size: 224\n","input_nc: 3\n","instance_feat: False\n","isTrain: False\n","label_feat: False\n","label_nc: 0\n","latent_size: 512\n","loadSize: 1024\n","load_features: False\n","local_rank: 0\n","max_dataset_size: inf\n","model: pix2pixHD\n","multisepcific_dir: ./demo_file/multispecific\n","nThreads: 2\n","n_blocks_global: 6\n","n_blocks_local: 3\n","n_clusters: 10\n","n_downsample_E: 4\n","n_downsample_global: 3\n","n_local_enhancers: 1\n","name: people\n","nef: 16\n","netG: global\n","ngf: 64\n","niter_fix_global: 0\n","no_flip: False\n","no_instance: False\n","no_simswaplogo: False\n","norm: batch\n","norm_G: spectralspadesyncbatch3x3\n","ntest: inf\n","onnx: None\n","output_nc: 3\n","output_path: ./output/\n","phase: test\n","pic_a_path: ./crop_224/gdg.jpg\n","pic_b_path: ./crop_224/zrf.jpg\n","pic_specific_path: ./crop_224/zrf.jpg\n","resize_or_crop: scale_width\n","results_dir: ./results/\n","semantic_nc: 3\n","serial_batches: False\n","temp_path: ./temp_results\n","tf_log: False\n","use_dropout: False\n","use_encoded_image: False\n","verbose: False\n","video_path: ./demo_file/multi_people_1080p.mp4\n","which_epoch: latest\n","-------------- End ----------------\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"UFt8zQrAMq9F","executionInfo":{"status":"ok","timestamp":1625381428564,"user_tz":-480,"elapsed":599996,"user":{"displayName":"José Lampreia","photoUrl":"","userId":"16015278604201270582"}},"outputId":"46188013-3f6d-4174-9959-d1fd203dcc0d"},"source":["pic_specific = opt.pic_specific_path\n","crop_size = opt.crop_size\n","multisepcific_dir = opt.multisepcific_dir\n","\n","torch.nn.Module.dump_patches = True\n","model = create_model(opt)\n","model.eval()\n","\n","app = Face_detect_crop(name='antelope', root='./insightface_func/models')\n","app.prepare(ctx_id= 0, det_thresh=0.6, det_size=(640,640))\n","# The specific person to be swapped(source)\n","source_specific_id_nonorm_list = []\n","source_path = os.path.join(multisepcific_dir,'SRC_*')\n","source_specific_images_path = sorted(glob.glob(source_path))\n","\n","with torch.no_grad():\n"," for source_specific_image_path in source_specific_images_path:\n"," specific_person_whole = cv2.imread(source_specific_image_path)\n"," specific_person_align_crop, _ = app.get(specific_person_whole,crop_size)\n"," specific_person_align_crop_pil = Image.fromarray(cv2.cvtColor(specific_person_align_crop[0],cv2.COLOR_BGR2RGB)) \n"," specific_person = transformer_Arcface(specific_person_align_crop_pil)\n"," specific_person = specific_person.view(-1, specific_person.shape[0], specific_person.shape[1], specific_person.shape [2])\n"," # convert numpy to tensor\n"," specific_person = specific_person.cuda()\n"," #create latent id\n"," specific_person_downsample = F.interpolate(specific_person, size=(112,112))\n"," specific_person_id_nonorm = model.netArc(specific_person_downsample)\n"," source_specific_id_nonorm_list.append(specific_person_id_nonorm.clone())\n","\n"," # The person who provides id information (list)\n"," target_id_norm_list = []\n"," target_path = os.path.join(multisepcific_dir,'DST_*')\n"," target_images_path = sorted(glob.glob(target_path))\n","\n"," for target_image_path in target_images_path:\n"," img_a_whole = cv2.imread(target_image_path)\n"," img_a_align_crop, _ = app.get(img_a_whole,crop_size)\n"," img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0],cv2.COLOR_BGR2RGB)) \n"," img_a = transformer_Arcface(img_a_align_crop_pil)\n"," img_id = img_a.view(-1, img_a.shape[0], img_a.shape[1], img_a.shape[2])\n"," # convert numpy to tensor\n"," img_id = img_id.cuda()\n"," #create latent id\n"," img_id_downsample = F.interpolate(img_id, size=(112,112))\n"," latend_id = model.netArc(img_id_downsample)\n"," latend_id = F.normalize(latend_id, p=2, dim=1)\n"," target_id_norm_list.append(latend_id.clone())\n"," \n"," assert len(target_id_norm_list) == len(source_specific_id_nonorm_list), \"The number of images in source and target directory must be same !!!\"\n"," video_swap(opt.video_path, target_id_norm_list,source_specific_id_nonorm_list, opt.id_thres, \\\n"," model, app, opt.output_path,temp_results_dir=opt.temp_path,no_simswaplogo=opt.no_simswaplogo,use_mask=opt.use_mask)"],"execution_count":12,"outputs":[{"output_type":"stream","text":["input mean and std: 127.5 127.5\n","find model: ./insightface_func/models/antelope/glintr100.onnx recognition\n","find model: ./insightface_func/models/antelope/scrfd_10g_bnkps.onnx detection\n","set det-size: (640, 640)\n"],"name":"stdout"},{"output_type":"stream","text":["\r 0%| | 0/594 [00:00, ?it/s]"],"name":"stderr"},{"output_type":"stream","text":["(142, 366, 4)\n"],"name":"stdout"},{"output_type":"stream","text":["100%|██████████| 594/594 [08:28<00:00, 1.17it/s]\n"],"name":"stderr"},{"output_type":"stream","text":["[MoviePy] >>>> Building video ./output/multi_test_multispecific.mp4\n","[MoviePy] Writing audio in multi_test_multispecificTEMP_MPY_wvf_snd.mp3\n"],"name":"stdout"},{"output_type":"stream","text":["100%|██████████| 438/438 [00:00<00:00, 832.16it/s]"],"name":"stderr"},{"output_type":"stream","text":["[MoviePy] Done.\n","[MoviePy] Writing video ./output/multi_test_multispecific.mp4\n"],"name":"stdout"},{"output_type":"stream","text":["\n","100%|██████████| 595/595 [00:53<00:00, 11.11it/s]\n"],"name":"stderr"},{"output_type":"stream","text":["[MoviePy] Done.\n","[MoviePy] >>>> Video ready: ./output/multi_test_multispecific.mp4 \n","\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"Rty2GsyZZrI6"},"source":[],"execution_count":null,"outputs":[]}]}
\ No newline at end of file
diff --git a/README.md b/README.md
index f01c43c..d7842c5 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,14 @@
## Proceedings of the 28th ACM International Conference on Multimedia
**The official repository with Pytorch**
-*Our method can realize **arbitrary face swapping** on images and videos with **one single trained model**.*
+**Our method can realize **arbitrary face swapping** on images and videos with **one single trained model**.**
-Currently, only the test code is available. Training scripts are coming soon
+Training and test code are now available!
+[ ](https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/train.ipynb)
+
+We are working with our incoming paper SimSwap++, keeping expecting!
+
+The high resolution version of ***SimSwap-HQ*** is supported!
[](https://github.com/neuralchen/SimSwap)
@@ -16,16 +21,34 @@ Our paper can be downloaded from [[Arxiv]](https://arxiv.org/pdf/2106.06340v1.pd
## Attention
***This project is for technical and academic use only. Please do not apply it to illegal and unethical scenarios.***
+***In the event of violation of the legal and ethical requirements of the user's country or region, this code repository is exempt from liability***
+
+***Please do not ignore the content at the end of this README!***
+
+If you find this project useful, please star it. It is the greatest appreciation of our work.
+
## Top News
-**`2021-07-04`**: A new Colab performing **multi specific** face video swapping has been added. You can check it out [here](https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/MultiSpecific.ipynb)
-**`2021-07-03`**: We add the scripts for **multi specific** face swapping, please go to [Inference for image or video face swapping](./docs/guidance/usage.md) for details.
+**`2022-04-21`**: For resource limited users, we provide the cropped VGGFace2-224 dataset [[Google Driver] VGGFace2-224 (10.8G)](https://drive.google.com/file/d/19pWvdEHS-CEG6tW3PdxdtZ5QEymVjImc/view?usp=sharing) [[Baidu Driver] ](https://pan.baidu.com/s/1OiwLJHVBSYB4AY2vEcfN0A) [Password: lrod].
-**`2021-07-02`**: We add the scripts for designating a **specific** person in arbitrary video or image to change face, please go to [Inference for image or video face swapping](./docs/guidance/usage.md) for details.
+**`2022-04-20`**: Training scripts are now available. We highly recommend that you guys train the simswap model with our released high quality dataset [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ).
-**`2021-07-02`**: We have added a hyper parameter to allow users to choose whether to add the simswap logo as a watermark, please go to the section "About watermark of simswap logo" of [Inference for image or video face swapping](./docs/guidance/usage.md) for details.
+**`2021-11-24`**: We have trained a beta version of ***SimSwap-HQ*** on [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) and open sourced the checkpoint of this model (if you think the Simswap 512 is cool, please star our [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) repo). Please don’t forget to go to [Preparation](./docs/guidance/preparation.md) and [Inference for image or video face swapping](./docs/guidance/usage.md) to check the latest set up.
-**`2021-06-20`**: We release the scripts for arbitrary video and image processing, and a colab demo.
+**`2021-11-23`**: The google drive link of [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) is released.
+
+**`2021-11-17`**: We released a high resolution face dataset [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ) and the method to generate this dataset. This dataset is for research purpose.
+
+**`2021-08-30`**: Docker has been supported, please refer [here](https://replicate.ai/neuralchen/simswap-image) for details.
+
+**`2021-08-17`**: We have updated the [Preparation](./docs/guidance/preparation.md), The main change is that the gpu version of onnx is now installed by default, Now the time to process a video is greatly reduced.
+
+**`2021-07-19`**: ***Obvious border abruptness has been resolved***. We add the ability to using mask and upgrade the old algorithm for better visual effect, please go to [Inference for image or video face swapping](./docs/guidance/usage.md) for details. Please don’t forget to go to [Preparation](./docs/guidance/preparation.md) to check the latest set up. (Thanks for the help from [@woctezuma](https://github.com/woctezuma) and [@instant-high](https://github.com/instant-high))
+
+## The first open source high resolution dataset for face swapping!!!
+## High Resolution Dataset [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ)
+
+[](https://github.com/NNNNAI/VGGFace2-HQ)
## Dependencies
- python3.6+
@@ -38,14 +61,51 @@ Our paper can be downloaded from [[Arxiv]](https://arxiv.org/pdf/2106.06340v1.pd
- moviepy
- insightface
-## Usage
+## Training
+
+[Preparation](./docs/guidance/preparation.md)
+
+The training script is slightly different from the original version, e.g., we replace the patch discriminator with the projected discriminator, which saves a lot of hardware overhead and achieves slightly better results.
+
+In order to ensure the normal training, the batch size must be greater than 1.
+
+Friendly reminder, due to the difference in training settings, the user-trained model will have subtle differences in visual effects from the pre-trained model we provide.
+
+- Train 224 models with VGGFace2 224*224 [[Google Driver] VGGFace2-224 (10.8G)](https://drive.google.com/file/d/19pWvdEHS-CEG6tW3PdxdtZ5QEymVjImc/view?usp=sharing) [[Baidu Driver] ](https://pan.baidu.com/s/1OiwLJHVBSYB4AY2vEcfN0A) [Password: lrod]
+
+For faster convergence and better results, a large batch size (more than 16) is recommended!
+
+***We recommend training more than 400K iterations (batch size is 16), 600K~800K will be better, more iterations will not be recommended.***
+
+
+```
+python train.py --name simswap224_test --batchSize 8 --gpu_ids 0 --dataset /path/to/VGGFace2HQ --Gdeep False
+```
+
+[Colab demo for training 224 model](https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/train.ipynb)
+
+For faster convergence and better results, a large batch size (more than 16) is recommended!
+
+- Train 512 models with VGGFace2-HQ 512*512 [VGGFace2-HQ](https://github.com/NNNNAI/VGGFace2-HQ).
+```
+python train.py --name simswap512_test --batchSize 16 --gpu_ids 0 --dataset /path/to/VGGFace2HQ --Gdeep True
+```
+
+
+
+## Inference with a pretrained SimSwap model
[Preparation](./docs/guidance/preparation.md)
[Inference for image or video face swapping](./docs/guidance/usage.md)
[Colab demo](https://colab.research.google.com/github/neuralchen/SimSwap/blob/main/SimSwap%20colab.ipynb)
-Training: **coming soon**
+
+
+
+
+
### About watermark of simswap logo
-The above example command line is to add the simswap logo as the watermark by default. After our discussion, we have added a hyper parameter to control whether to remove watermark.
+The above example command lines are to add the simswap logo as the watermark by default. After our discussion, we have added a hyper parameter to control whether to remove watermark.
The usage of removing the watermark is to add an argument: "***--no_simswaplogo***" to the command line, take the command line of "Swap all faces within one image" as an example, the following command line can get the result without watermark:
```
-python test_wholeimage_swapmulti.py --no_simswaplogo --isTrain false --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path ./demo_file/Iron_man.jpg --pic_b_path ./demo_file/multi_people.jpg --output_path ./output/
+python test_wholeimage_swapmulti.py --no_simswaplogo --crop_size 224 --use_mask --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path ./demo_file/Iron_man.jpg --pic_b_path ./demo_file/multi_people.jpg --output_path ./output/
```
+### About using mask for better result
+We provide two methods to paste the face back to the original image after changing the face: Using mask or using bounding box. At present, the effect of using mask is the best. All the above code examples are using mask. If you want to use the bounding box, you only need to remove the --use_mask in the code example.
+Difference between using mask and not using mask can be found [here](https://imgsli.com/NjE3OTA).
-
-
-
-Difference between single face swapping and all face swapping are shown below.
+### Difference between single face swapping and all face swapping are shown below.
+
+
+
### Parameters
| Parameters | Function |
| :---- | :---- |
@@ -95,6 +109,7 @@ Difference between single face swapping and all face swapping are shown below.
| --temp_path | Path to store intermediate files |
| --output_path | Path of directory to store the face swapping result |
| --no_simswaplogo |The hyper parameter to control whether to remove watermark |
+| --use_mask |The hyper parameter to control whether to use face parsing for the better visual effects(I recommend to use)|
### Note
-We expect users to have GPU with at least 6G memory. For those who do not, we will provide Colab Notebook implementation in the future.
+We expect users to have GPU with at least 3G memory.the For those who do not, we will provide Colab Notebook implementation in the future.
diff --git a/docs/img/1.png b/docs/img/1.png
deleted file mode 100644
index fbb9a0e..0000000
Binary files a/docs/img/1.png and /dev/null differ
diff --git a/docs/img/2.png b/docs/img/2.png
deleted file mode 100644
index 94e6ff7..0000000
Binary files a/docs/img/2.png and /dev/null differ
diff --git a/docs/img/HRGT_201009539_201009571.webp b/docs/img/HRGT_201009539_201009571.webp
deleted file mode 100644
index ebaf772..0000000
Binary files a/docs/img/HRGT_201009539_201009571.webp and /dev/null differ
diff --git a/docs/img/HRGT_201010607_201010639.webp b/docs/img/HRGT_201010607_201010639.webp
deleted file mode 100644
index 8effc98..0000000
Binary files a/docs/img/HRGT_201010607_201010639.webp and /dev/null differ
diff --git a/docs/img/HRGT_201011587_201011619.webp b/docs/img/HRGT_201011587_201011619.webp
deleted file mode 100644
index 5922a29..0000000
Binary files a/docs/img/HRGT_201011587_201011619.webp and /dev/null differ
diff --git a/docs/img/HRGT_201108607_201108655.webp b/docs/img/HRGT_201108607_201108655.webp
deleted file mode 100644
index 4ad3cda..0000000
Binary files a/docs/img/HRGT_201108607_201108655.webp and /dev/null differ
diff --git a/docs/img/HRGT_201109091_201109123.webp b/docs/img/HRGT_201109091_201109123.webp
deleted file mode 100644
index 40d59f2..0000000
Binary files a/docs/img/HRGT_201109091_201109123.webp and /dev/null differ
diff --git a/docs/img/HRGT_201110059_201110091.webp b/docs/img/HRGT_201110059_201110091.webp
deleted file mode 100644
index 049d592..0000000
Binary files a/docs/img/HRGT_201110059_201110091.webp and /dev/null differ
diff --git a/docs/img/LRGT_201009539_201009571.webp b/docs/img/LRGT_201009539_201009571.webp
deleted file mode 100644
index 66a9ff7..0000000
Binary files a/docs/img/LRGT_201009539_201009571.webp and /dev/null differ
diff --git a/docs/img/LRGT_201010607_201010639.webp b/docs/img/LRGT_201010607_201010639.webp
deleted file mode 100644
index 7848f33..0000000
Binary files a/docs/img/LRGT_201010607_201010639.webp and /dev/null differ
diff --git a/docs/img/LRGT_201011587_201011619.webp b/docs/img/LRGT_201011587_201011619.webp
deleted file mode 100644
index 6dcc9fe..0000000
Binary files a/docs/img/LRGT_201011587_201011619.webp and /dev/null differ
diff --git a/docs/img/LRGT_201108607_201108655.webp b/docs/img/LRGT_201108607_201108655.webp
deleted file mode 100644
index 73de61e..0000000
Binary files a/docs/img/LRGT_201108607_201108655.webp and /dev/null differ
diff --git a/docs/img/LRGT_201109091_201109123.webp b/docs/img/LRGT_201109091_201109123.webp
deleted file mode 100644
index 33b83c3..0000000
Binary files a/docs/img/LRGT_201109091_201109123.webp and /dev/null differ
diff --git a/docs/img/girl2-RGB.png b/docs/img/girl2-RGB.png
new file mode 100644
index 0000000..7dfee55
Binary files /dev/null and b/docs/img/girl2-RGB.png differ
diff --git a/docs/img/girl2.gif b/docs/img/girl2.gif
new file mode 100644
index 0000000..fc5c5e0
Binary files /dev/null and b/docs/img/girl2.gif differ
diff --git a/docs/img/id/Iron_man.jpg b/docs/img/id/Iron_man.jpg
new file mode 100644
index 0000000..77a0f20
Binary files /dev/null and b/docs/img/id/Iron_man.jpg differ
diff --git a/docs/img/id/wuyifan.png b/docs/img/id/wuyifan.png
new file mode 100644
index 0000000..f2c2e8a
Binary files /dev/null and b/docs/img/id/wuyifan.png differ
diff --git a/docs/img/id/zhoujielun.jpg b/docs/img/id/zhoujielun.jpg
index 6e5da6c..795d14b 100644
Binary files a/docs/img/id/zhoujielun.jpg and b/docs/img/id/zhoujielun.jpg differ
diff --git a/docs/img/mama_mask_short.webp b/docs/img/mama_mask_short.webp
new file mode 100644
index 0000000..cc7c210
Binary files /dev/null and b/docs/img/mama_mask_short.webp differ
diff --git a/docs/img/mama_mask_wuyifan_short.webp b/docs/img/mama_mask_wuyifan_short.webp
new file mode 100644
index 0000000..c423572
Binary files /dev/null and b/docs/img/mama_mask_wuyifan_short.webp differ
diff --git a/docs/img/result_whole_swap_multispecific_512.jpg b/docs/img/result_whole_swap_multispecific_512.jpg
new file mode 100644
index 0000000..37560d3
Binary files /dev/null and b/docs/img/result_whole_swap_multispecific_512.jpg differ
diff --git a/docs/img/vggface2_hq_compare.png b/docs/img/vggface2_hq_compare.png
new file mode 100644
index 0000000..4f0b427
Binary files /dev/null and b/docs/img/vggface2_hq_compare.png differ
diff --git a/docs/index.html b/docs/index.html
index c5387cf..2b48b1a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -150,19 +150,19 @@
+
+
@@ -172,11 +172,23 @@
+
+
+