Home

Awesome

The Euclidean Space is Evil: Hyperbolic Attribute Editing for Few-shot Image Generation (ICCV 2023)

<a href="https://arxiv.org/abs/2211.12347"><img src="https://img.shields.io/badge/arXiv-2203.08422-b31b1b.svg" height=22.5></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" height=22.5></a>

image

Few-shot image generation is a challenging task since it aims to generate diverse new images for an unseen category with only a few images. Existing methods suffer from the trade-off between the quality and diversity of generated images. To tackle this problem, we propose Hyperbolic Attribute Editing (HAE), a simple yet effective method. Unlike other methods that work in Euclidean space, HAE captures the hierarchy among images using data from seen categories in hyperbolic space. Given a well-trained HAE, images of unseen categories can be generated by moving the latent code of a given image toward any meaningful directions in the Poincaré disk with a fixing radius. Most importantly, the hyperbolic space allows us to control the semantic diversity of the generated images by setting different radii in the disk. Extensive experiments and visualizations demonstrate that HAE is capable of not only generating images with promising quality and diversity using limited data but achieving a highly controllable and interpretable editing process.

image

Description

Official implementation of HAE for few-shot image generation. Our code is modified from pSp.

Getting Started

Prerequisites

Installation

git clone https://github.com/lingxiao-li/HAE.git
cd HAE

Pre-trained Models

Then download the pre-trained models we provide from Google Drive

Then put the pre-trained models under /HAE/hae/pretrained_models

Training

Preparing your Data

Related datasets can be downloaded at: https://github.com/bcmi/Awesome-Few-Shot-Image-Generation

After downloading the pre-trained models and datasets, change the corresponding path at /Codes/hae/configs/paths_config.py

Train

Go to the path to HAE:

cd /PATH_TO/HAE/hae

Then you can train the model using:

python scripts/train.py \
--dataset_type=flowers_encode_eva \
--psp_checkpoint_path=/PATH_TO/psp_flowers.pt \
--exp_dir=OUTPUT_PATH \
--feature_size=512 \
--workers=8 \
--batch_size=8 \
--test_batch_size=8 \
--test_workers=8 \
--val_interval=80000 \
--save_interval=5000 \
--encoder_type=GradualStyleEncoder \
--start_from_latent_avg \
--lpips_lambda=1 \
--l2_lambda=1 \
--image_interval=1000 \
--hyperbolic_lambda=0.3 \
--reverse_lambda=1

Inference

Inference the images using:

python scripts/inference.py \
--exp_dir=OUTPUT_PATH \
--checkpoint_path=/PATH_TO/hae_flowers.pt \
--data_path=PATH_TO/flowers_eva/test \
--test_batch_size=4 \
--test_workers=4

image

Visualization

Please see the comments in the notebook:

Interpolation & Perturbation.ipynb and UMAP_Visualization.ipynb

image

Citation

If you use this code for your research, please cite our paper <a href="https://arxiv.org/abs/2211.12347">The Euclidean Space is Evil: Hyperbolic Attribute Editing for Few-shot Image Generation</a>:

@InProceedings{Li_2023_HAE,
    author    = {Li, Lingxiao and Zhang, Yi and Wang, Shuhui},
    title     = {The Euclidean Space is Evil: Hyperbolic Attribute Editing for Few-shot Image Generation},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
    month     = {October},
    year      = {2023},
    pages     = {22714-22724}
}