Giter Site home page Giter Site logo

hae's Introduction

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

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

  • Linux
  • NVIDIA GPU + CUDA CuDNN (CPU may be possible with some modifications, but is not inherently supported)
  • Python 3

Installation

  • Clone this repo:
git clone https://github.com/lingxiao-li/HAE.git
cd HAE
  • Dependencies:
    We recommend running this repository using Anaconda. All dependencies for defining the environment are provided in /HAE/hae/environment/hae_env.yaml.

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 The Euclidean Space is Evil: Hyperbolic Attribute Editing for Few-shot Image Generation:

@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}
}

hae's People

Contributors

lingxiao-li avatar

Stargazers

Suyu Liu avatar Hao Qi avatar Jacob A Rose avatar Guanqi Ding avatar  avatar Zizheng Pan avatar ChunLiang Wu avatar Kangshuo Li avatar  avatar EZhang avatar Larry He avatar

Watchers

Kostas Georgiou avatar  avatar

Forkers

yizhang025

hae's Issues

Code error when using pre-trained model for inferrence

First, thanks for providing the source code for comparison!
However, when I run the inference.py with the pre-trained models and instructions you provided, the code does not run successfully. I need the generated images by HAE for comparative experiments, could you provide clearer instructions for the inference? If I reproduce your results successfully, I will cite your paper in my work.

VGGFace dataset

Hello, I am very interested in your research and want to execute your program. However, when using the VGG Face dataset, I don’t know how to obtain it. I saw it from the link you gave. But the file format is .npy or .zip. I don't know how to use it. If you have a format with ".jpg" , can you share it. Or tell me how I can get it. Thank you so much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.