Unofficial implementation of Alias-Free Generative Adversarial Networks. (https://arxiv.org/abs/2106.12423) in PyTorch

Overview

alias-free-gan-pytorch

Unofficial implementation of Alias-Free Generative Adversarial Networks. (https://arxiv.org/abs/2106.12423) This implementation contains a lot of my guesses, so I think there are many differences to the official implementations

Usage

First create lmdb datasets:

python prepare_data.py --out LMDB_PATH --n_worker N_WORKER --size SIZE1,SIZE2,SIZE3,... DATASET_PATH

This will convert images to jpeg and pre-resizes it. This implementation does not use progressive growing, but you can create multiple resolution datasets using size arguments with comma separated lists, for the cases that you want to try another resolutions later.

Then you can train model in distributed settings

python train.py --n_gpu N_GPU --conf config/config-t.jsonnet training.batch=BATCH_SIZE path=LMDB_PATH

train.py supports Weights & Biases logging. If you want to use it, add wandb=true arguments to the script.

Sample

Latent translation sample 1 Latent translation sample 2 Latent translation sample 3 Latent translation sample 4 Latent translation sample 5 Latent translation sample 6

Comments
  • Any tips or code for generating images and movies from the checkpoints?

    Any tips or code for generating images and movies from the checkpoints?

    Hi there, thanks so much for this implementation! I know this is probably trivial for more advanced users but could you provide some tips or code to accelerate my ability to generate images and movies. Something like what you did for StyleGAN2/ADA would be amazing.

    opened by MHRosenberg 6
  • Training on 1024 resolution

    Training on 1024 resolution

    Hello, thanks for your great work.

    I tried to train alias-free gan with config-t on the resolution of 1024, by simply editing training.size to 1024 in the config file, but the network seems not converge and the generated result is not good either.

    Do I need to modify some other arguments for training on a larger resolution (e.g. 512, 1024)?

    Thanks!

    opened by piddnad 5
  • Questions on Filter parameters

    Questions on Filter parameters

    Hi, sorry for asking a dumb question. I had a quite hard time (but still failed) to understand the function of filter_parameters in https://github.com/rosinality/alias-free-gan-pytorch/blob/main/model.py#L47

    It would be grateful if you can add some comments or explanations to this part. Moreover, especially if we want to change the input dimensions (instead of 16x16 for now), how should we modify this function?

    Thanks

    opened by MultiPath 4
  • pretrained model

    pretrained model

    Dear Rosinality,

    Thank you for you great implementation.

    Would you mind providing the pretrained models? Maybe for unaligned FFHQ?

    Thank you for your help.

    Best Wishes,

    Alex

    opened by betterze 4
  • Small updates to the Fourier Features

    Small updates to the Fourier Features

    First of all, thanks for taking the time to implement your own version of the alias-free GAN, it's really cool 🙇 I am by no means an expert, but I wanted to propose a couple of changes for the FourierFeature:

    • First of all, you were rotating coord_h and then using the rotated value to rotate coord_w, so I fixed that.

    • Then, I set the coordinates to the range [-1, 1] so when the rotation is applied it will be performed around the center of the image instead of the edge. Here's an example of a few channels of the Fourier features without and with a rotation applied using a [0, 1] range: imageimage And here with a [-1, 1] range: imageimage

    • Finally, I made it so the translation is dependent on the frequency of every signal since otherwise, the shift in the phase will be different at each waveform. Here are 3 signals and the same signals shifted by 1 unit using a frequency-independent translation value: imageimage And here are the same 3 signals when using a frequency-dependent translation: imageimage As you can see, by having a frequency-dependent shift we can keep the 3 signals synced.

    Hopefully, these changes result in a better relationship between the affine transformation of the FourierFeature and the output images 🤞

    opened by pabloppp 4
  • How much GPU memory do I need to train?

    How much GPU memory do I need to train?

    Hi! I wanted to try this GAN, but I don't have enough memory to run it. I have a 1080ti 11gb and used training.batch=1 Is there any way to optimize the network so that it fit?

    opened by andorxornot 3
  • CUDA error: illegal memory access was encountered

    CUDA error: illegal memory access was encountered

    I'm getting the following error in stylegan2/op/fused_act.py at line 66:

    RuntimeError: CUDA error: an illegal memory access was encountered

    Did not use the docker file and I'm running on torch 1.8.1 and I'm running on a 3090

    opened by matigekunstintelligentie 3
  • Internal Representations

    Internal Representations

    Thanks for the great contribution.

    Slightly off-topic, but do you know how they generate the internal representations in Figure 6 in the original paper? ie. what convention do they use to visualise the channels in the feature maps as RGB?

    opened by JonathanRayner 2
  • GPU Scalability Bug (GPU 0 has 4x the vram of all others)

    GPU Scalability Bug (GPU 0 has 4x the vram of all others)

    image I tried running this on multiple GPUs and noticed all the processes allocate memory on GPU number 1. This essentially limits me to a batch size of just 1 when each GPU can support closer to a batch size of 4 on their own.

    opened by Skylion007 2
  • Optimize VRAM usage during training

    Optimize VRAM usage during training

    This PR reduces the VRAM usage of the training loop: fixes #16

    • Allows 4X increase in batchsize with same number of samples on a 1080TI. Instead of taking up 4X the amount of memory as all the other GPUs, now it only takes up an additional 200mb.
    • It moves the inference images to CPU as soon as possible which tells PyTorch immediately frees the underlying GPU memory.
    • It also zeros the gradient of the previous backprop so that the memory of those gradients don't have to co-exist with the second forward pass used for inference.
    • It ensures the gradients of the generator aren't accidentally stored in the accumulated ema weights (they shouldn't be in the current codebase but this is just an extra sanity check / documentation of desired behavior). Overall, this allows me to fix a batch size of 4 on a 1080TI, where as before I could only fit a batch size of 1. This all works with the default number of samples (16).
    opened by Skylion007 1
  • Required GPU Memory

    Required GPU Memory

    @rosinality thank you for always putting out such fantastic work. I have a questions about your training details: How much GPU memory is required, at minimum, to run this implementation of alias free gan? In the paper, the authors mention training on "n NVIDIA DGX-1 with 8 Tesla V100 GPUs", but no mention of how much GPU memory is required. Also, how long did it take you to train?

    opened by obravo7 1
  • Is `conv2d_gradfix` really incompatible with PyTorch > 1.8?

    Is `conv2d_gradfix` really incompatible with PyTorch > 1.8?

    There is a check that doesn't allow to use conv2d_gradfix with PyTorch 1.9.0 (or later): https://github.com/rosinality/alias-free-gan-pytorch/blob/0e9512888128da58e2bc5945384e2212cab38ff5/stylegan2/op/conv2d_gradfix.py#L85 Is there really some specific functionality that only PyTorch 1.7 and 1.8 have, or is it the check outdated?

    opened by elimohl 0
  • Are there still differences to the official implementation?

    Are there still differences to the official implementation?

    README.md says "This implementation contains a lot of my guesses, so I think there are many differences to the official implementations". Is this sentence still accurate?

    opened by elimohl 0
  • Issues regarding the LMDB dataset creating.

    Issues regarding the LMDB dataset creating.

    Traceback (most recent call last): File "train.py", line 404, in conf = load_arg_config(GANConfig) File "/home/user/anaconda3/envs/pytorch/lib/python3.8/site-packages/tensorfn/util/config.py", line 269, in load_arg_config conf = load_config(config_model, args.conf, args.opts, show) File "/home/user/anaconda3/envs/pytorch/lib/python3.8/site-packages/tensorfn/util/config.py", line 257, in load_config conf = config_model(**read_config(config, overrides=overrides)) File "/home/user/anaconda3/envs/pytorch/lib/python3.8/site-packages/tensorfn/util/config.py", line 25, in read_config json_str = _jsonnet.evaluate_file(config_file) AttributeError: 'NoneType' object has no attribute 'evaluate_file'

    data format.

    -Data
    --Images
    ---1.jpg
    |
    |
    |
    ---N.jpg
    
    opened by nile649 1
  • Modify to work successful in config-r

    Modify to work successful in config-r

    After reflecting from the official pytorch code, this project doesn't work in config-r.jsonnet setting. For detail, an error occurs when kernel_size is 1. I found a bug in padding size, so I modify by reflecting the official code.

    opened by jiwoogit 0
  • Train script issue

    Train script issue

    I´ve been trying to run the repo via colab. Everything goes fine until running the train script, then the error below is thrown. Has the repo been recently updated or am I missing some dependency or some other detail to be considered? Any clue how to solve this?

    IndexError Traceback (most recent call last) /usr/local/lib/python3.7/dist-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse) 1682 try: -> 1683 loc, tokens = self.parseImpl(instring, preloc, doActions) 1684 except IndexError: 8 frames IndexError: string index out of range During handling of the above exception, another exception occurred: ParseException Traceback (most recent call last) ParseException: Expected {: ... | {{{"=" | ":" | "+="} - [Suppress:({{{"#" | "//"} - SkipTo:({Suppress:(W:( )) | StringEnd})} | Suppress:(W:( ))})]... -} ConcatenatedValueParser:([{{{{Suppress:({[Suppress:(W:( ,))] {"#" | "//"} - SkipTo:({Suppress:(W:( )) | StringEnd})}) | {Suppress:("include") {Re:('"(?:[^"\\\n]|\\.)"[ \t]') | {{"url" | "file" | "package"} - Suppress:("(") - Re:('"(?:[^"\\\n]|\\.)"[ \t]') - Suppress:(")")} | {"required" - Suppress:("(") - {Re:('"(?:[^"\\\n]|\\.)"[ \t]') | {{"url" | "file" | "package"} - Suppress:("(") - Re:('"(?:[^"\\\n]|\\.)"[ \t]') - Suppress:(")")}} - Suppress:(")")}}} | Re:('[ \t]\$\{[^\}]+\}[ \t]') | : ...} | Forward: {{{{Suppress:("[") -} ListParser:({{ConcatenatedValueParser:([{{{{Suppress:({[Suppress:(W:( ,))] {"#" | "//"} - SkipTo:({Suppress:(W:( )) | StringEnd})}) | {Suppress:("include") {Re:('"(?:[^"\\\n]|\\.)"[ \t]') | {{"url" | "file" | "package"} - Suppress:("(") - Re:('"(?:[^"\\\n]|\\.)"[ \t]') - Suppress:(")")} | {"required" - Suppress:("(") - {Re:('"(?:[^"\\\n]|\\.)"[ \t]') | {{"url" | "file" | "package"} - Suppress:("(") - Re:('"(?:[^"\\\n]|\\.)"[ \t]') - Suppress:(")")}} - Suppress:(")")}}} | Re:('[ \t]\$\{[^\}]+\}[ \t]') | : ...} | : ...} | {{{{{{{{W:(0123...) Suppress:([]...)} {"ns" ^ "nano" ^ "nanos" ^ "nanosecond" ^ "nanoseconds" ^ "us" ^ "micro" ^ "micros" ^ "microsecond" ^ "microseconds" ^ "ms" ^ "milli" ^ "millis" ^ "millisecond" ^ "milliseconds" ^ "s" ^ "second" ^ "seconds" ^ "m" ^ "minute" ^ "minutes" ^ "h" ^ "hour" ^ "hours" ^ "w" ^ "week" ^ "weeks" ^ "d" ^ "day" ^ "days" ^ "mo" ^ "month" ^ "months" ^ "y" ^ "year" ^ "years"}} Supp} | {{{{{{{{W:(0123...) Suppress:([]...)} {"ns" ^ "nano" ^ "nanos" ^ "nanosecond" ^ "nanoseconds" ^ "us" ^ "micro" ^ "micros" ^ "microsecond" ^ "microseconds" ^ "ms" ^ "milli" ^ "millis" ^ "millisecond" ^ "milliseconds" ^ "s" ^ "second" ^ "seconds" ^ "m" ^ "minute" ^ "minutes" ^ "h" ^ "hour" ^ "hours" ^ "w" ^ "week" ^ "weeks" ^ "d" ^ "day" ^ "days" ^ "mo" ^ "month" ^ "months" ^ "y" ^ "year" ^ "years"}} Suppress:(WordEnd)} | Re:('[+-]?(\d*\.\d+|\d+(\.\d+)?)([eE][+\-]?\d+)?(?=$|[ \t]([\$\}\],#\n\r]|//))')} | "true"} | "false"} | "null"} | {{Re:('""".?""""') | Re:('"(?:[^"\\\n]|\\.)"[ \t]*')} | Re:('(... ))})}]...)}}, found end of text (at char 43), (line:1, col:44)

    opened by polimorfo 5
Owner
Kim Seonghyeon
no side-effects
Kim Seonghyeon
Unofficial implementation of "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows" (https://arxiv.org/abs/2103.14030)

Swin-Transformer-Tensorflow A direct translation of the official PyTorch implementation of "Swin Transformer: Hierarchical Vision Transformer using Sh

null 52 Dec 29, 2022
Unofficial Tensorflow-Keras implementation of Fastformer based on paper [Fastformer: Additive Attention Can Be All You Need](https://arxiv.org/abs/2108.09084).

Fastformer-Keras Unofficial Tensorflow-Keras implementation of Fastformer based on paper Fastformer: Additive Attention Can Be All You Need. Tensorflo

Yam Peleg 10 Jan 30, 2022
A PyTorch implementation of EventProp [https://arxiv.org/abs/2009.08378], a method to train Spiking Neural Networks

Spiking Neural Network training with EventProp This is an unofficial PyTorch implemenation of EventProp, a method to compute exact gradients for Spiki

Pedro Savarese 35 Jul 29, 2022
source code for https://arxiv.org/abs/2005.11248 "Accelerating Antimicrobial Discovery with Controllable Deep Generative Models and Molecular Dynamics"

Accelerating Antimicrobial Discovery with Controllable Deep Generative Models and Molecular Dynamics This work will be published in Nature Biomedical

International Business Machines 71 Nov 15, 2022
Alias-Free Generative Adversarial Networks (StyleGAN3) Official PyTorch implementation

Alias-Free Generative Adversarial Networks (StyleGAN3) Official PyTorch implementation

NVIDIA Research Projects 4.8k Jan 9, 2023
Pytorch implementation of Each Part Matters: Local Patterns Facilitate Cross-view Geo-localization https://arxiv.org/abs/2008.11646

[TCSVT] Each Part Matters: Local Patterns Facilitate Cross-view Geo-localization LPN [Paper] NEWs Prerequisites Python 3.6 GPU Memory >= 8G Numpy > 1.

null 46 Dec 14, 2022
[PyTorch] Official implementation of CVPR2021 paper "PointDSC: Robust Point Cloud Registration using Deep Spatial Consistency". https://arxiv.org/abs/2103.05465

PointDSC repository PyTorch implementation of PointDSC for CVPR'2021 paper "PointDSC: Robust Point Cloud Registration using Deep Spatial Consistency",

null 153 Dec 14, 2022
Non-Official Pytorch implementation of "Face Identity Disentanglement via Latent Space Mapping" https://arxiv.org/abs/2005.07728 Using StyleGAN2 instead of StyleGAN

Face Identity Disentanglement via Latent Space Mapping - Implement in pytorch with StyleGAN 2 Description Pytorch implementation of the paper Face Ide

Daniel Roich 58 Dec 24, 2022
Pytorch implementation of Distributed Proximal Policy Optimization: https://arxiv.org/abs/1707.02286

Pytorch-DPPO Pytorch implementation of Distributed Proximal Policy Optimization: https://arxiv.org/abs/1707.02286 Using PPO with clip loss (from https

Alexis David Jacq 163 Dec 26, 2022
PyTorch implementation of Asymmetric Siamese (https://arxiv.org/abs/2204.00613)

Asym-Siam: On the Importance of Asymmetry for Siamese Representation Learning This is a PyTorch implementation of the Asym-Siam paper, CVPR 2022: @inp

Meta Research 89 Dec 18, 2022
Official implementation of the paper Image Generators with Conditionally-Independent Pixel Synthesis https://arxiv.org/abs/2011.13775

CIPS -- Official Pytorch Implementation of the paper Image Generators with Conditionally-Independent Pixel Synthesis Requirements pip install -r requi

Multimodal Lab @ Samsung AI Center Moscow 201 Dec 21, 2022
Official Implementation for "ReStyle: A Residual-Based StyleGAN Encoder via Iterative Refinement" https://arxiv.org/abs/2104.02699

ReStyle: A Residual-Based StyleGAN Encoder via Iterative Refinement Recently, the power of unconditional image synthesis has significantly advanced th

null 967 Jan 4, 2023
This is an official implementation of our CVPR 2021 paper "Bottom-Up Human Pose Estimation Via Disentangled Keypoint Regression" (https://arxiv.org/abs/2104.02300)

Bottom-Up Human Pose Estimation Via Disentangled Keypoint Regression Introduction In this paper, we are interested in the bottom-up paradigm of estima

HRNet 367 Dec 27, 2022
Minimal implementation of PAWS (https://arxiv.org/abs/2104.13963) in TensorFlow.

PAWS-TF ?? Implementation of Semi-Supervised Learning of Visual Features by Non-Parametrically Predicting View Assignments with Support Samples (PAWS)

Sayak Paul 43 Jan 8, 2023
Tensorflow implementation of Semi-supervised Sequence Learning (https://arxiv.org/abs/1511.01432)

Transfer Learning for Text Classification with Tensorflow Tensorflow implementation of Semi-supervised Sequence Learning(https://arxiv.org/abs/1511.01

DONGJUN LEE 82 Oct 22, 2022
This repository contains the code used for Predicting Patient Outcomes with Graph Representation Learning (https://arxiv.org/abs/2101.03940).

Predicting Patient Outcomes with Graph Representation Learning This repository contains the code used for Predicting Patient Outcomes with Graph Repre

Emma Rocheteau 76 Dec 22, 2022
https://arxiv.org/abs/2102.11005

LogME LogME: Practical Assessment of Pre-trained Models for Transfer Learning How to use Just feed the features f and labels y to the function, and yo

THUML: Machine Learning Group @ THSS 149 Dec 19, 2022
Supplementary code for the paper "Meta-Solver for Neural Ordinary Differential Equations" https://arxiv.org/abs/2103.08561

Meta-Solver for Neural Ordinary Differential Equations Towards robust neural ODEs using parametrized solvers. Main idea Each Runge-Kutta (RK) solver w

Julia Gusak 25 Aug 12, 2021