In this demo, we train a DCGAN using a human face dataset, CelebA dataset, and use the trained model to synthesize human faces.
The following shows fake faces synthesized using the GoTorch version (left) and the PyTorch counterpart (right). You can watch the detailed animation here.
Training loss of GoTorch:
Training loss of PyTorch:
From the Web page CelebA
dataset, we can choose to
download the ZIP archive img_align_celeba.zip from Google Drive or Baidu
Drive.
The following command unzip the archive and creates a tarball train.tgz of the
images shuffled in a random order.
unzip img_align_celeba.zip
tar czf train.tgz img_align_celebaNOTE: If you work on macOS, you must install GNU tar. Go's standard package doesn't recognize macOS's BSD tar format.
brew install gnu-tar # Use gtar instead tar in the above command.Please follow the CONTRIBUTING.md guide to build.
go install ./...The dcgan binary will be installed at $GOPATH/bin directory.
The following command runs the sample program.
$GOPATH/bin/dcgan -data=$SOMEPATH/train.tgz 2>&1 | tee gotorch-dcgan.logThe training program periodically generates image samples and saves to pickle files. We provide a script to transform the saved pickle files into PNG format.
python visualize_pickle.py --load_gotorch=1 --save_image=1And the script could also generate an animation to visualize
the training progress of generated fake images.
ffmpeg is needed to save the animation to mp4 format.
python visualize_pickle.py --load_gotorch=1 --save_video=1To see the training loss curve:
python plot_loss.py --load_gotorch=1

