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)
This repo in the implementation of EMNLP'21 paper "SPARQLing Database Queries from Intermediate Question Decompositions" by Irina Saparina, Anton Osokin

SPARQLing Database Queries from Intermediate Question Decompositions This repo is the implementation of the following paper: SPARQLing Database Querie

Yandex Research 20 Dec 19, 2022
Cryptocurrency Prediction with Artificial Intelligence (Deep Learning via LSTM Neural Networks)

Cryptocurrency Prediction with Artificial Intelligence (Deep Learning via LSTM Neural Networks)- Emirhan BULUT

Emirhan BULUT 102 Nov 18, 2022
EXplainable Artificial Intelligence (XAI)

EXplainable Artificial Intelligence (XAI) This repository includes the codes for different projects on eXplainable Artificial Intelligence (XAI) by th

4 Nov 28, 2022
This repository contains the code used to quantitatively evaluate counterfactual examples in the associated paper.

On Quantitative Evaluations of Counterfactuals Install To install required packages with conda, run the following command: conda env create -f requi

Frederik Hvilshøj 1 Jan 16, 2022
Using contrastive learning and OpenAI's CLIP to find good embeddings for images with lossy transformations

The official code for the paper "Inverse Problems Leveraging Pre-trained Contrastive Representations" (to appear in NeurIPS 2021).

Sriram Ravula 26 Dec 10, 2022
Cross-media Structured Common Space for Multimedia Event Extraction (ACL2020)

Cross-media Structured Common Space for Multimedia Event Extraction Table of Contents Overview Requirements Data Quickstart Citation Overview The code

Manling Li 49 Nov 21, 2022
Deep learning toolbox based on PyTorch for hyperspectral data classification.

Deep learning toolbox based on PyTorch for hyperspectral data classification.

Nicolas 304 Dec 28, 2022
Permute Me Softly: Learning Soft Permutations for Graph Representations

Permute Me Softly: Learning Soft Permutations for Graph Representations

Giannis Nikolentzos 7 Jul 10, 2022
Public Implementation of ChIRo from "Learning 3D Representations of Molecular Chirality with Invariance to Bond Rotations"

Learning 3D Representations of Molecular Chirality with Invariance to Bond Rotations This directory contains the model architectures and experimental

35 Dec 05, 2022
One-line your code easily but still with the fun of doing so!

One-liner-iser One-line your code easily but still with the fun of doing so! Have YOU ever wanted to write one-line Python code, but don't have the sa

5 May 04, 2022
Local trajectory planner based on a multilayer graph framework for autonomous race vehicles.

Graph-Based Local Trajectory Planner The graph-based local trajectory planner is python-based and comes with open interfaces as well as debug, visuali

TUM - Institute of Automotive Technology 160 Jan 04, 2023
Code for Two-stage Identifier: "Locate and Label: A Two-stage Identifier for Nested Named Entity Recognition"

Code for Two-stage Identifier: "Locate and Label: A Two-stage Identifier for Nested Named Entity Recognition", accepted at ACL 2021. For details of the model and experiments, please see our paper.

tricktreat 87 Dec 16, 2022
A demonstration of using a live Tensorflow session to create an interactive face-GAN explorer.

Streamlit Demo: The Controllable GAN Face Generator This project highlights Streamlit's new hash_func feature with an app that calls on TensorFlow to

Streamlit 257 Dec 31, 2022
Official PyTorch implementation of Spatial Dependency Networks.

Spatial Dependency Networks: Neural Layers for Improved Generative Image Modeling Đorđe Miladinović   Aleksandar Stanić   Stefan Bauer   Jürgen Schmid

Djordje Miladinovic 34 Jan 19, 2022
Code accompanying the paper "ProxyFL: Decentralized Federated Learning through Proxy Model Sharing"

ProxyFL Code accompanying the paper "ProxyFL: Decentralized Federated Learning through Proxy Model Sharing" Authors: Shivam Kalra*, Junfeng Wen*, Jess

Layer6 Labs 14 Dec 06, 2022
The final project of "Applying AI to EHR Data" of "AI for Healthcare" nanodegree - Udacity.

Patient Selection for Diabetes Drug Testing Project Overview EHR data is becoming a key source of real-world evidence (RWE) for the pharmaceutical ind

Omar Laham 1 Jan 14, 2022
This script runs neural style transfer against the provided content image.

Neural Style Transfer Content Style Output Description: This script runs neural style transfer against the provided content image. The content image m

Martynas Subonis 0 Nov 25, 2021
PyTorch implementation of "Transparency by Design: Closing the Gap Between Performance and Interpretability in Visual Reasoning"

Transparency-by-Design networks (TbD-nets) This repository contains code for replicating the experiments and visualizations from the paper Transparenc

David Mascharka 351 Nov 18, 2022
Code for "Offline Meta-Reinforcement Learning with Advantage Weighting" [ICML 2021]

Offline Meta-Reinforcement Learning with Advantage Weighting (MACAW) MACAW code used for the experiments in the ICML 2021 paper. Installing the enviro

Eric Mitchell 28 Jan 01, 2023
Projecting interval uncertainty through the discrete Fourier transform

Projecting interval uncertainty through the discrete Fourier transform This repo

1 Mar 02, 2022