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)
The official implementation of "Rethink Dilated Convolution for Real-time Semantic Segmentation"

RegSeg The official implementation of "Rethink Dilated Convolution for Real-time Semantic Segmentation" Paper: arxiv D block Decoder Setup Install the

Roland 61 Dec 27, 2022
A face dataset generator with out-of-focus blur detection and dynamic interval adjustment.

A face dataset generator with out-of-focus blur detection and dynamic interval adjustment.

Yutian Liu 2 Jan 29, 2022
Hunt down social media accounts by username across social networks

Hunt down social media accounts by username across social networks Installation | Usage | Docker Notes | Contributing Installation # clone the repo $

1 Dec 14, 2021
Self-Supervised Learning for Domain Adaptation on Point-Clouds

Self-Supervised Learning for Domain Adaptation on Point-Clouds Introduction Self-supervised learning (SSL) allows to learn useful representations from

Idan Achituve 66 Dec 20, 2022
Labels4Free: Unsupervised Segmentation using StyleGAN

Labels4Free: Unsupervised Segmentation using StyleGAN ICCV 2021 Figure: Some segmentation masks predicted by Labels4Free Framework on real and synthet

70 Dec 23, 2022
Python code for loading the Aschaffenburg Pose Dataset.

Aschaffenburg Pose Dataset (APD) This repository contains Python code for loading and filtering the Aschaffenburg Pose Dataset. The dataset itself and

1 Nov 26, 2021
DCSL - Generalizable Crowd Counting via Diverse Context Style Learning

DCSL Generalizable Crowd Counting via Diverse Context Style Learning Requirement

3 Jun 13, 2022
PyTorch implementation of Glow

glow-pytorch PyTorch implementation of Glow, Generative Flow with Invertible 1x1 Convolutions (https://arxiv.org/abs/1807.03039) Usage: python train.p

Kim Seonghyeon 433 Dec 27, 2022
Released code for Objects are Different: Flexible Monocular 3D Object Detection, CVPR21

MonoFlex Released code for Objects are Different: Flexible Monocular 3D Object Detection, CVPR21. Work in progress. Installation This repo is tested w

Yunpeng 169 Dec 06, 2022
Code release for "MERLOT Reserve: Neural Script Knowledge through Vision and Language and Sound"

merlot_reserve Code release for "MERLOT Reserve: Neural Script Knowledge through Vision and Language and Sound" MERLOT Reserve (in submission) is a mo

Rowan Zellers 92 Dec 11, 2022
Self-describing JSON-RPC services made easy

ReflectRPC Self-describing JSON-RPC services made easy Contents What is ReflectRPC? Installation Features Datatypes Custom Datatypes Returning Errors

Andreas Heck 31 Jul 16, 2022
[CVPR2021 Oral] FFB6D: A Full Flow Bidirectional Fusion Network for 6D Pose Estimation.

FFB6D This is the official source code for the CVPR2021 Oral work, FFB6D: A Full Flow Biderectional Fusion Network for 6D Pose Estimation. (Arxiv) Tab

Yisheng (Ethan) He 201 Dec 28, 2022
This is an open source library implementing hyperbox-based machine learning algorithms

hyperbox-brain is a Python open source toolbox implementing hyperbox-based machine learning algorithms built on top of scikit-learn and is distributed

Complex Adaptive Systems (CAS) Lab - University of Technology Sydney 21 Dec 14, 2022
This is the repo for the paper `SumGNN: Multi-typed Drug Interaction Prediction via Efficient Knowledge Graph Summarization'. (published in Bioinformatics'21)

SumGNN: Multi-typed Drug Interaction Prediction via Efficient Knowledge Graph Summarization This is the code for our paper ``SumGNN: Multi-typed Drug

Yue Yu 58 Dec 21, 2022
Memory Efficient Attention (O(sqrt(n)) for Jax and PyTorch

Memory Efficient Attention This is unofficial implementation of Self-attention Does Not Need O(n^2) Memory for Jax and PyTorch. Implementation is almo

Amin Rezaei 126 Dec 27, 2022
Implementation of ResMLP, an all MLP solution to image classification, in Pytorch

ResMLP - Pytorch Implementation of ResMLP, an all MLP solution to image classification out of Facebook AI, in Pytorch Install $ pip install res-mlp-py

Phil Wang 178 Dec 02, 2022
code for "Feature Importance-aware Transferable Adversarial Attacks"

Feature Importance-aware Attack(FIA) This repository contains the code for the paper: Feature Importance-aware Transferable Adversarial Attacks (ICCV

Hengchang Guo 44 Nov 24, 2022
This is the code of using DQN to play Sekiro .

Update for using DQN to play sekiro 2021.2.2(English Version) This is the code of using DQN to play Sekiro . I am very glad to tell that I have writen

144 Dec 25, 2022
Self-Supervised Speech Pre-training and Representation Learning Toolkit.

What's New Sep 2021: We host a challenge in AAAI workshop: The 2nd Self-supervised Learning for Audio and Speech Processing! See SUPERB official site

s3prl 1.6k Jan 08, 2023
Provide partial dates and retain the date precision through processing

Prefix date parser This is a helper class to parse dates with varied degrees of precision. For example, a data source might state a date as 2001, 2001

Friedrich Lindenberg 13 Dec 14, 2022