Files
neuralchen-SimSwap/train.ipynb
T
2022-04-22 12:20:18 +08:00

7.2 KiB

#Training Demo This is a simple example for training the SimSwap 224*224 with VGGFace2-224.

Code path: https://github.com/neuralchen/SimSwap If you like the SimSwap project, please star it! Paper path: https://arxiv.org/pdf/2106.06340v1.pdf or https://dl.acm.org/doi/10.1145/3394171.3413630

In [1]:
!nvidia-smi
Fri Apr 22 12:19:42 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 456.71       Driver Version: 456.71       CUDA Version: 11.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  TITAN Xp           WDDM  | 00000000:01:00.0  On |                  N/A |
| 23%   36C    P8    15W / 250W |   1135MiB / 12288MiB |      4%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1232    C+G   Insufficient Permissions        N/A      |
|    0   N/A  N/A      1240    C+G   Insufficient Permissions        N/A      |
|    0   N/A  N/A      1528    C+G   ...y\ShellExperienceHost.exe    N/A      |
|    0   N/A  N/A      7296    C+G   Insufficient Permissions        N/A      |
|    0   N/A  N/A      8280    C+G   C:\Windows\explorer.exe         N/A      |
|    0   N/A  N/A      9532    C+G   ...artMenuExperienceHost.exe    N/A      |
|    0   N/A  N/A      9896    C+G   ...5n1h2txyewy\SearchApp.exe    N/A      |
|    0   N/A  N/A     11040    C+G   ...2txyewy\TextInputHost.exe    N/A      |
|    0   N/A  N/A     11424    C+G   Insufficient Permissions        N/A      |
|    0   N/A  N/A     13112    C+G   ...icrosoft VS Code\Code.exe    N/A      |
|    0   N/A  N/A     18720    C+G   ...-2.9.15\GitHubDesktop.exe    N/A      |
|    0   N/A  N/A     22996    C+G   ...bbwe\Microsoft.Photos.exe    N/A      |
|    0   N/A  N/A     23512    C+G   ...me\Application\chrome.exe    N/A      |
|    0   N/A  N/A     25892    C+G   Insufficient Permissions        N/A      |
+-----------------------------------------------------------------------------+

Installation All file changes made by this notebook are temporary. You can try to mount your own google drive to store files if you want.

#Get Scripts

In [ ]:
!git clone https://github.com/neuralchen/SimSwap
!cd SimSwap && git pull

Install Blocks

In [ ]:
!pip install googledrivedownloader
!pip install timm
!wget -P SimSwap/arcface_model https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar

#Download the Training Dataset We employ the cropped VGGFace2-224 dataset for this toy training demo.

You can download the dataset from our google driver https://drive.google.com/file/d/19pWvdEHS-CEG6tW3PdxdtZ5QEymVjImc/view?usp=sharing

Please check the dataset in dir /content/TrainingData

If dataset already exists in /content/TrainingData, please do not run blow scripts!

In [ ]:
!wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=19pWvdEHS-CEG6tW3PdxdtZ5QEymVjImc' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=19pWvdEHS-CEG6tW3PdxdtZ5QEymVjImc" -O /content/TrainingData/vggface2_crop_arcfacealign_224.tar && rm -rf /tmp/cookies.txt
%cd /content/
!tar -xzvf /content/TrainingData/vggface2_crop_arcfacealign_224.tar
!rm /content/TrainingData/vggface2_crop_arcfacealign_224.tar

#Trainig Batch size must larger than 1!

In [ ]:
%cd /content/SimSwap
!ls
!python train.py --name simswap224_test --gpu_ids 0 --dataset /content/TrainingData/vggface2_crop_arcfacealign_224 --Gdeep False