File size: 7,471 Bytes
7116cec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "fC7QoKePuJWu"
      },
      "source": [
        "#Training Demo\n",
        "This is a simple example for training the SimSwap 224*224 with VGGFace2-224.\n",
        "\n",
        "Code path: https://github.com/neuralchen/SimSwap\n",
        "If you like the SimSwap project, please star it!\n",
        "Paper path: https://arxiv.org/pdf/2106.06340v1.pdf or https://dl.acm.org/doi/10.1145/3394171.3413630"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "id": "J8WrNaQHuUGC"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Fri Apr 22 12:19:42 2022       \n",
            "+-----------------------------------------------------------------------------+\n",
            "| NVIDIA-SMI 456.71       Driver Version: 456.71       CUDA Version: 11.1     |\n",
            "|-------------------------------+----------------------+----------------------+\n",
            "| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |\n",
            "| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n",
            "|===============================+======================+======================|\n",
            "|   0  TITAN Xp           WDDM  | 00000000:01:00.0  On |                  N/A |\n",
            "| 23%   36C    P8    15W / 250W |   1135MiB / 12288MiB |      4%      Default |\n",
            "+-------------------------------+----------------------+----------------------+\n",
            "                                                                               \n",
            "+-----------------------------------------------------------------------------+\n",
            "| Processes:                                                                  |\n",
            "|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |\n",
            "|        ID   ID                                                   Usage      |\n",
            "|=============================================================================|\n",
            "|    0   N/A  N/A      1232    C+G   Insufficient Permissions        N/A      |\n",
            "|    0   N/A  N/A      1240    C+G   Insufficient Permissions        N/A      |\n",
            "|    0   N/A  N/A      1528    C+G   ...y\\ShellExperienceHost.exe    N/A      |\n",
            "|    0   N/A  N/A      7296    C+G   Insufficient Permissions        N/A      |\n",
            "|    0   N/A  N/A      8280    C+G   C:\\Windows\\explorer.exe         N/A      |\n",
            "|    0   N/A  N/A      9532    C+G   ...artMenuExperienceHost.exe    N/A      |\n",
            "|    0   N/A  N/A      9896    C+G   ...5n1h2txyewy\\SearchApp.exe    N/A      |\n",
            "|    0   N/A  N/A     11040    C+G   ...2txyewy\\TextInputHost.exe    N/A      |\n",
            "|    0   N/A  N/A     11424    C+G   Insufficient Permissions        N/A      |\n",
            "|    0   N/A  N/A     13112    C+G   ...icrosoft VS Code\\Code.exe    N/A      |\n",
            "|    0   N/A  N/A     18720    C+G   ...-2.9.15\\GitHubDesktop.exe    N/A      |\n",
            "|    0   N/A  N/A     22996    C+G   ...bbwe\\Microsoft.Photos.exe    N/A      |\n",
            "|    0   N/A  N/A     23512    C+G   ...me\\Application\\chrome.exe    N/A      |\n",
            "|    0   N/A  N/A     25892    C+G   Insufficient Permissions        N/A      |\n",
            "+-----------------------------------------------------------------------------+\n"
          ]
        }
      ],
      "source": [
        "!nvidia-smi"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Z6BtQIgWuoqt"
      },
      "source": [
        "Installation\n",
        "All file changes made by this notebook are temporary. You can try to mount your own google drive to store files if you want."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wdQJ9d8N8Tnf"
      },
      "source": [
        "#Get Scripts"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "9jZWwt97uvIe"
      },
      "outputs": [],
      "source": [
        "!git clone https://github.com/neuralchen/SimSwap\n",
        "!cd SimSwap && git pull"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ATLrrbso8Y-Y"
      },
      "source": [
        "# Install Blocks"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "rwvbPhtOvZAL"
      },
      "outputs": [],
      "source": [
        "!pip install googledrivedownloader\n",
        "!pip install timm==0.5.4\n",
        "!wget -P SimSwap/arcface_model https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "hleVtHIJ_QUK"
      },
      "source": [
        "#Download the Training Dataset\n",
        "We employ the cropped VGGFace2-224 dataset for this toy training demo.\n",
        "\n",
        "You can download the dataset from our google driver https://drive.google.com/file/d/19pWvdEHS-CEG6tW3PdxdtZ5QEymVjImc/view?usp=sharing\n",
        "\n",
        "***Please check the dataset in dir /content/TrainingData***\n",
        "\n",
        "***If dataset already exists in /content/TrainingData, please do not run blow scripts!***\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "h2tyjBl0Llxp"
      },
      "outputs": [],
      "source": [
        "%mkdir /content/TrainingData\n",
        "!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\n",
        "%cd /content/\n",
        "!tar -xzvf /content/TrainingData/vggface2_crop_arcfacealign_224.tar -C /content/TrainingData\n ",
        "!rm /content/TrainingData/vggface2_crop_arcfacealign_224.tar"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "o5SNDWzA8LjJ"
      },
      "source": [
        "#Trainig\n",
        "Batch size must larger than 1!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "XCxHa4oW507s"
      },
      "outputs": [],
      "source": [
        "%cd /content/SimSwap\n",
        "!ls\n",
        "!python train.py --name simswap224_test --gpu_ids 0 --dataset /content/TrainingData/vggface2_crop_arcfacealign_224 --Gdeep False"
      ]
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "collapsed_sections": [],
      "name": "train.ipynb",
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.8.5"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}