Journal: ACM Transaction on Graphics, Volume 39, Issue 6, Article No.224, November 2020
Conference: ACM SIGGRAPH Asia 2020
[arXiv] | [Paper] | [Fast-Forward] | [Video] | [BibTex]
Abstract We propose Neural Crossbreed, a feed-forward neural network that can learn a semantic change of input images in a latent space to create the morphing effect. Because the network learns a semantic change, a sequence of meaningful intermediate images can be generated without requiring the user to specify explicit correspondences. In addition, the semantic change learning makes it possible to perform the morphing between the images that contain objects with significantly different poses or camera views. Furthermore, just as in conventional morphing techniques, our morphing network can handle shape and appearance transitions separately by disentangling the content and the style transfer for rich usability. We prepare a training dataset for morphing using a pre-trained BigGAN, which generates an intermediate image by interpolating two latent vectors at an intended morphing value. This is the first attempt to address image morphing using a pre-trained generative model in order to learn semantic transformation. The experiments show that Neural Crossbreed produces high quality morphed images, overcoming various limitations associated with conventional approaches. In addition, Neural Crossbreed can be further extended for diverse applications such as multi-image morphing, appearance transfer, and video frame interpolation.
Click on the picture above to view the video.
Click on the picture above to view the video.
Our result video has been chosen for SIGGRAPH Asia 2020 Techncial Papers Trailer (https://youtu.be/Q45KT0lGd7A?t=64).
Python 3.7.4
PyTorch 1.2.0
TensorBoard
PyYAML 5.1.2
tqdm 4.41.1
PyTorch pretrained BigGAN 0.1.1
NLTK 3.4.5
scikit-image 0.16.2
Clone this repository.
git clone https://github.com/sanghunpark/neural_crossbreed.git
cd neural_crossbreed/
For Conda users:
conda create -n neural_crossbreed python=3.7.4 conda activate neural_crossbreed
Install PyTorch 1.2.0+ and torchvision from PyTorch
Install other dependencies from the requirement file.
pip install -r requirements.txt
For Docker users:
A nvidia-docker is required.
Build the Docker image from Dockerfile
docker build -t neural_crossbreed .
docker run --gpus all --rm -v $(pwd):/workspace -it neural_crossbreed:latest
Download the pre-trained dog model from the link, save it in ./train_dir/nc_final/
.
To generate morphed images using the pre-trained dog model, run following command:
python test.py --config=./config.yaml
--ngpu=1
--gpu_1st=0
--input_a=./sample_images/dog5.png
--input_b=./sample_images/dog3.png
--niter=5
Generated images will be placed under ./test_outdir/out_***.png
.
You can obtain the disentangled transition results by adding --disentangled
and --tau
. For example,
python test.py --config=./config.yaml
--ngpu=1
--gpu_1st=0
--input_a=./sample_images/dog5.png
--input_b=./sample_images/dog3.png
--niter=5
--disentangled
--tau=0.3
To train Neural Crossbreed from scratch, run the following command.
python train.py --config=./config.yaml
--ngpu=[NUM_GPUs]
--gpu_1st=[1ST_GPU_ID]
You can specify the GPU usage with the argument --ngpu
and --gpu_1st
. For instance, --ngpu=2
and --gpu_1st=3
will run the training process on GPU3 and GPU4. If you don't use these arguments, it will use all visible GPUs by running:
CUDA_AVAILABLE_DEVICES=0,1,... python train.py --config=./config.yaml
The training configuration such as path, model, and hyperparamters can be further customized with ./config.yaml
. Please see refer to ./config.yaml
.
In particular, to resume training, replace the checkpoint path in the ./config.yaml
file with the latest checkpoint.
# path
...
checkpoints: [MODEL_DIR]/[YOUR_CHECKPOINT].pt
...
If a checkpoint file exists in the path, training will resume at the point where a previous training run left off. Otherwise, the network will be trained from scratch.
When your model training is complete, replace the checkpoint path in the ./config.yaml
file with the latest checkpoint and run the test.py. (Testing)
If you find this work useful, please cite our paper:
@article{park2020neural,
title={Neural crossbreed: neural based image metamorphosis},
author={Park, Sanghun and Seo, Kwanggyoon and Noh, Junyong},
journal={ACM Transactions on Graphics (TOG)},
volume={39},
number={6},
pages={1--15},
year={2020},
publisher={ACM New York, NY, USA}
}
This repository contains pieces of code from the following repositories: