Simple torch.nn.module implementation of Alias-Free-GAN style filter and resample

Overview

Alias-Free-Torch

Simple torch module implementation of Alias-Free GAN.

This repository including

Note: Since this repository is unofficial, filter and upsample could be different with official implementation.

Note: 2d lowpass filter is applying sinc instead of jinc (first order Bessel function of the first kind) in paper

Requirements

Due to torch.kaiser_window and torch.i0 are implemeted after 1.7.0, our repository need torch>=1.7.0.

  • Pytorch>=1.7.0

TODO

  • 2d sinc filter
  • 2d resample
  • devide 1d and 2d modules
  • pip packaging

Test results 1d

Filter sine Filter noise
filtersin filternoise
upsample downsample
up2 down10
up256 down100

Test results 2d

Filter L1 norm sine Filter noise
filter2dsin filter2dnoise
upsample downsample
up2d2 downsample2d2
up2d8 downsample2d4
Activation
act

References

  • Alias-Free GAN
  • adefossez/julius
  • A. V. Oppenheim and R. W. Schafer. Discrete-Time Signal Processing. Pearson, International Edition, 3rd edition, 2010

Acknowledgement

This work is done at MINDsLab Inc.

Thanks to teammates at MINDsLab Inc.

Comments
  •  Batched resampling for the new implementation

    Batched resampling for the new implementation

    Hi, thank you very much for the contribution.

    I think the new implementation of resample.Upsample1d and resample.Downsample1d breaks batched resampling when using groups=C without expanding the filter to match the shape. Perhaps the implementation should be like the below (maybe similar goes to 2d):

    Upsample1d.forward()

        # x: [B,C,T]
        def forward(self, x):
            B, C, T = x.shape
            x = F.pad(x, (self.pad, self.pad), mode='reflect')
            # TConv with filter expanded to C with C groups for depthwise op
            x = self.ratio * F.conv_transpose1d(
                x, self.filter.expand(C, -1, -1), stride=self.stride, groups=C)
            pad_left = self.pad * self.stride + (self.kernel_size -
                                                 self.stride) // 2
            pad_right = self.pad * self.stride + (self.kernel_size - self.stride +
                                                  1) // 2
            x = x[..., pad_left:-pad_right]
    

    LowPassFilter1d.forward()

        #input [B,C,T]
        def forward(self, x):
            B, C, T = x.shape
            if self.padding:
                x = F.pad(x, (self.left_pad, self.right_pad),
                          mode=self.padding_mode)
            # Conv with filter expanded to C with C groups for depthwise op
            out = F.conv1d(x, self.filter.expand(C, -1, -1), stride=self.stride, groups=C) # typo 'groupds' btw
            return out
    

    Could you check the correctness? Thanks again for the implementation!

    opened by L0SG 2
  • torch.speical.i1 typo

    torch.speical.i1 typo

    https://github.com/junjun3518/alias-free-torch/blob/f1fddd52fdd068ee475e82ae60c92e1bc24ffe02/src/alias_free_torch/filter.py#L22

    At this line I believe you wanted torch.special.i1.

    opened by torridgristle 2
  • "if self.pad / self.padding" in LowPassFilter2d

    https://github.com/junjun3518/alias-free-torch/blob/258551410ff7bf02e06ece7c597466dc970fe5c7/src/alias_free_torch/filter.py#L165 https://github.com/junjun3518/alias-free-torch/blob/258551410ff7bf02e06ece7c597466dc970fe5c7/src/alias_free_torch/filter.py#L173

    In LowPassFilter2d it looks like if self.pad: should change to if self.padding:, or self.padding = padding should change to self.pad = padding to match LowPassFilter1d.

    opened by torridgristle 1
  • Padding Bool typo

    Padding Bool typo

    https://github.com/junjun3518/alias-free-torch/blob/258551410ff7bf02e06ece7c597466dc970fe5c7/src/alias_free_torch/filter.py#L73

    padding: bool: True, should be padding: bool = True,

    I'm not sure if this causes an error with every version of PyTorch, but it does with PyTorch 1.12.0+cu113 on Python 3.7.13

    opened by torridgristle 1
  • 2D Filter Jinc appears to be wrong

    2D Filter Jinc appears to be wrong

    Here is a plot of the generated 1D sinc filter kernel. sinc looks right

    Here is a plot of the generated 2D jinc filter kernel. jinc looks wrong

    I'd expect it to look more like a series of rings or ripples, rather than a donut or torus.

    jinc filtered noise fft

    The FFT output for randn noise put through the 2D filter doesn't look right either.

    change jinc to sinc in 2d filter

    Changing filter_ = 2 * cutoff * window * jinc(2 * cutoff * time) to filter_ = 2 * cutoff * window * sinc(2 * cutoff * time) in kaiser_jinc_filter2d makes a more familiar kernel.

    change jinc to sinc in 2d filter fft out

    And the FFT output for randn noise put through this 2D filter looks about how I'd expect.

    opened by torridgristle 3
Releases(v0.0.6)
Owner
이준혁(Junhyeok Lee)
Audio/Speech Deep Learning Researcher @mindslab-ai
이준혁(Junhyeok Lee)
Code for CVPR2021 "Visualizing Adapted Knowledge in Domain Transfer". Visualization for domain adaptation. #explainable-ai

Visualizing Adapted Knowledge in Domain Transfer @inproceedings{hou2021visualizing, title={Visualizing Adapted Knowledge in Domain Transfer}, auth

Yunzhong Hou 80 Dec 25, 2022
MEDS: Enhancing Memory Error Detection for Large-Scale Applications

MEDS: Enhancing Memory Error Detection for Large-Scale Applications Prerequisites cmake and clang Build MEDS supporting compiler $ make Build Using Do

Secomp Lab at Purdue University 34 Dec 14, 2022
A PyTorch implementation of Learning to learn by gradient descent by gradient descent

Intro PyTorch implementation of Learning to learn by gradient descent by gradient descent. Run python main.py TODO Initial implementation Toy data LST

Ilya Kostrikov 300 Dec 11, 2022
Evolution Strategies in PyTorch

Evolution Strategies This is a PyTorch implementation of Evolution Strategies. Requirements Python 3.5, PyTorch = 0.2.0, numpy, gym, universe, cv2 Wh

Andrew Gambardella 333 Nov 14, 2022
Segmentation and Identification of Vertebrae in CT Scans using CNN, k-means Clustering and k-NN

Segmentation and Identification of Vertebrae in CT Scans using CNN, k-means Clustering and k-NN If you use this code for your research, please cite ou

41 Dec 08, 2022
Official implementation of "Intrinsic Dimension, Persistent Homology and Generalization in Neural Networks", NeurIPS 2021.

PHDimGeneralization Official implementation of "Intrinsic Dimension, Persistent Homology and Generalization in Neural Networks", NeurIPS 2021. Overvie

Tolga Birdal 13 Nov 08, 2022
Implemented fully documented Particle Swarm Optimization algorithm (basic model with few advanced features) using Python programming language

Implemented fully documented Particle Swarm Optimization (PSO) algorithm in Python which includes a basic model along with few advanced features such as updating inertia weight, cognitive, social lea

9 Nov 29, 2022
Large scale embeddings on a single machine.

Marius Marius is a system under active development for training embeddings for large-scale graphs on a single machine. Training on large scale graphs

Marius 107 Jan 03, 2023
Multi Task Vision and Language

12-in-1: Multi-Task Vision and Language Representation Learning Please cite the following if you use this code. Code and pre-trained models for 12-in-

Facebook Research 712 Dec 19, 2022
Just-Now - This Is Just Now Login Friendlist Cloner Tools

JUST NOW LOGIN FRIENDLIST CLONER TOOLS Install $ apt update $ apt upgrade $ apt

MAHADI HASAN AFRIDI 21 Mar 09, 2022
A deep learning network built with TensorFlow and Keras to classify gender and estimate age.

Convolutional Neural Network (CNN). This repository contains a source code of a deep learning network built with TensorFlow and Keras to classify gend

Pawel Dziemiach 1 Dec 19, 2021
[CVPR22] Official codebase of Semantic Segmentation by Early Region Proxy.

RegionProxy Figure 2. Performance vs. GFLOPs on ADE20K val split. Semantic Segmentation by Early Region Proxy Yifan Zhang, Bo Pang, Cewu Lu CVPR 2022

Yifan 54 Nov 29, 2022
LBBA-boosted WSOD

LBBA-boosted WSOD Summary Our code is based on ruotianluo/pytorch-faster-rcnn and WSCDN Sincerely thanks for your resources. Newer version of our code

Martin Dong 20 Sep 19, 2022
Source Code for Simulations in the Publication "Can the brain use waves to solve planning problems?"

Code for Simulations in the Publication Can the brain use waves to solve planning problems? Installing Required Python Packages Please use Python vers

EMD Group 2 Jul 01, 2022
[ICCV 2021] Deep Hough Voting for Robust Global Registration

Deep Hough Voting for Robust Global Registration, ICCV, 2021 Project Page | Paper | Video Deep Hough Voting for Robust Global Registration Junha Lee1,

Junha Lee 10 Dec 02, 2022
Official code for "On the Frequency Bias of Generative Models", NeurIPS 2021

Frequency Bias of Generative Models Generator Testbed Discriminator Testbed This repository contains official code for the paper On the Frequency Bias

35 Nov 01, 2022
This repository contains several jupyter notebooks to help users learn to use neon, our deep learning framework

neon_course This repository contains several jupyter notebooks to help users learn to use neon, our deep learning framework. For more information, see

Nervana 92 Jan 03, 2023
Official Code Release for "CLIP-Adapter: Better Vision-Language Models with Feature Adapters"

Official Code Release for "CLIP-Adapter: Better Vision-Language Models with Feature Adapters" Pipeline of CLIP-Adapter CLIP-Adapter is a drop-in modul

peng gao 157 Dec 26, 2022
Contrastive Feature Loss for Image Prediction

Contrastive Feature Loss for Image Prediction We provide a PyTorch implementation of our contrastive feature loss presented in: Contrastive Feature Lo

Alex Andonian 44 Oct 05, 2022
Talk covering the features of skorch

Skorch Talk Skorch - A Union of Scikit-learn and PyTorch Presentation The slides can be downloaded at: download link. Google Colab Part One - MNIST Pa

Thomas J. Fan 3 Oct 20, 2020