152 lines
4.2 KiB
Plaintext
152 lines
4.2 KiB
Plaintext
{
|
|
"nbformat": 4,
|
|
"nbformat_minor": 0,
|
|
"metadata": {
|
|
"colab": {
|
|
"name": "train.ipynb",
|
|
"provenance": [],
|
|
"collapsed_sections": []
|
|
},
|
|
"kernelspec": {
|
|
"name": "python3",
|
|
"display_name": "Python 3"
|
|
},
|
|
"language_info": {
|
|
"name": "python"
|
|
},
|
|
"accelerator": "GPU"
|
|
},
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"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"
|
|
],
|
|
"metadata": {
|
|
"id": "fC7QoKePuJWu"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"!nvidia-smi"
|
|
],
|
|
"metadata": {
|
|
"id": "J8WrNaQHuUGC"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": []
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"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."
|
|
],
|
|
"metadata": {
|
|
"id": "Z6BtQIgWuoqt"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"#Get Scripts"
|
|
],
|
|
"metadata": {
|
|
"id": "wdQJ9d8N8Tnf"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"!git clone https://github.com/neuralchen/SimSwap\n",
|
|
"!cd SimSwap && git pull"
|
|
],
|
|
"metadata": {
|
|
"id": "9jZWwt97uvIe"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": []
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"# Install Blocks"
|
|
],
|
|
"metadata": {
|
|
"id": "ATLrrbso8Y-Y"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"!pip install googledrivedownloader\n",
|
|
"!pip install timm\n",
|
|
"!wget -P SimSwap/arcface_model https://github.com/neuralchen/SimSwap/releases/download/1.0/arcface_checkpoint.tar"
|
|
],
|
|
"metadata": {
|
|
"id": "rwvbPhtOvZAL"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": []
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"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"
|
|
],
|
|
"metadata": {
|
|
"id": "hleVtHIJ_QUK"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"!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\n",
|
|
"!rm /content/TrainingData/vggface2_crop_arcfacealign_224.tar"
|
|
],
|
|
"metadata": {
|
|
"id": "h2tyjBl0Llxp"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": []
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"#Trainig\n",
|
|
"Batch size must larger than 1!"
|
|
],
|
|
"metadata": {
|
|
"id": "o5SNDWzA8LjJ"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"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": {
|
|
"id": "XCxHa4oW507s"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": []
|
|
}
|
|
]
|
|
} |