Home

Awesome

[ICCV 2023] LFS-GAN: Lifelong Few-Shot Image Generation

Official PyTorch implementation for ICCV 2023 paper:

LFS-GAN: Lifelong Few-Shot Image Generation
Juwon Seo*, Ji-Su Kang*, and Gyeong-Moon Park<sup> $\dagger$ </sup>

arXiv

Environment

Preparation

Environment

Before running our code, please set up an environment by running commands below:

git clone git@github.com:JJuOn/LFS-GAN.git
cd LFS-GAN
conda env create -f environmenmt.yaml

Dataset

We are providing the training datasets (10-shot) and their full dataset for evaluation.
We recommend you to extract these training sets to ./data directory.

SketchesFemaleSunglassesMaleBabies
10-shotDownloadDownloadDownloadDownloadDownload
FullDownloadDownloadDownloadDownloadDownload

Before running train.py, please process training datasets to be lmdb.

python prepare_data.py --out processed_data/{dataset} --size 256 data/{dataset}

For example, if you want to process Sketches dataset, run the command below:

python prepare_data.py --out processed_data/Sketches --size 256 data/Sketches

Pretrained Checkpoints

Here, we provide a checkpoint of StyleGAN2 pretrained on FFHQ-256.
You can download the model checkpoint via google drive below.

FFHQ-256
Pretrained StyleGAN2Download

Since our code is based on @rosinaltiy's implementation, the checkpoint is only compatibile with this implementation.

We also provide checkpoints of our framework - LFS-GAN on Sketches, Female, Sunglasses, Male, and Babies.

SketchesFemaleSunglassesMaleBabies
Pretrained LFS-GANDownloadDownloadDownloadDownloadDownload

Train

You can train LFS-GAN by running:

python train.py --data_path processed_data/{dataset} --ckpt ffhq.pt --exp lfs-gan \
                --rank 1 --left_use_add --left_use_act --cluster_wise_mode_seeking

The trained checkpoints are saved to ./checkpoints

Evaluation

Before the evaluation of the trained model, you first sample images:

python generate.py --pretrained_ckpt ffhq.pt \
                   --ckpt checkpoints/lfs-gan/{some_checkpoint_name}.pt \
                   --result_path fake_images/lfs-gan/{dataset} \
                   --rank 1 --left_use_act --left_use_add

We also provide the generated images from our pretrained LFS-GAN.
We have samples 5,000 images per task.

SketchesFemaleSunglassesMaleBabies
Fake imagesDownloadDownloadDownloadDownloadDownload

You can measure the generation quality by using pytorch-fid.

python -m pytorch_fid {real_path} fake_images/lfs-gan/{dataset} --device cuda

The {real_path} denotes the path of the full dataset.

You can also measure the generation diversity by running evaluate_b_lpips.py.

python evaluate_b_lpips.py --real_path processed_data/{dataset} --fake_path fake_images/lfs-gan/{dataset}

Acknowledgment

This code is based on stylegan2-pytorch, few-shot-gan-adaptation, CelebAHQ-Gender, and PerceptualSimilarity.

BibTex

@inproceedings{seo2023lfs
  title    = {LFS-GAN: Lifelong Few-Shot Image Generation}
  author   = {Seo, Juwon and Kang, Ji-Su and Park, Gyeong-Moon}
  booktitle= {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)}
  year     = {2023}
}