This is an official pytorch implementation of Fast Fourier Convolution.

Overview

Fast Fourier Convolution (FFC) for Image Classification

This is the official code of Fast Fourier Convolution for image classification on ImageNet.

Main Results

Results on ImageNet

Method GFLOPs #Params Top-1 Acc
ResNet-50 4.1 25.6 76.3
FFC-ResNet-50 4.2 26.1 77.6
FFC-ResNet-50 (+LFU) 4.3 26.7 77.8

Quick starts

Requirements

  • pip install -r requirements.txt

Data preparation

You can follow the Pytorch implementation: https://github.com/pytorch/examples/tree/master/imagenet

Training

To train a model, run main.py with the desired model architecture and other super-paremeters:

python main.py -a ffc_resnet50 --lfu [imagenet-folder with train and val folders]

We use "lfu" to control whether to use Local Fourier Unit (LFU). Default: False.

Testing

python main.py -a ffc_resnet50 --lfu --resume PATH/TO/CHECKPOINT [imagenet-folder with train and val folders]

Citation

If you find this work or code is helpful in your research, please cite:

@InProceedings{Chi_2020_FFC,
  author = {Chi, Lu and Jiang, Borui and Mu, Yadong},
  title = {Fast Fourier Convolution},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020}
}
Comments
  • Missing license file

    Missing license file

    Hi. First of all, thanks a lot for contributing your work to the community. I noticed that this repo does't include a license file, so it's difficult to know the conditions for rightful use of it. Could you confirm under what conditions can your code be used and preferrably add a license file?

    opened by cvejarano 2
  • BasicBlock implementation

    BasicBlock implementation

    Hello, the forward method of BasicBlock says:

    x = self.conv1(x)
    x_l, x_g = self.conv2(x)
    x_l, x_g = self.se_block(x)
    

    Is this correct? x_l and x_g are overwritten by the se_block. Shouldn't it be like this?

    x = self.conv1(x)
    x = self.conv2(x)
    x_l, x_g = self.se_block(x)
    

    Thanks!

    opened by javirk 2
  • now can process input of arbitrary size

    now can process input of arbitrary size

    Before there was a bug that the input had to be square (B,C,N,N). The reason was in incorrect split size. Now it is possible to process input of arbitrary size (B,C,N,M).

    opened by LexaNagiBator228 0
  • Input channel mismatch

    Input channel mismatch

    Using ffc() to directly replace nn.Conv2d() will report an error: RuntimeError: Given groups=1, weight of size [5, 3, 3, 3], expected input[3, 6, 64, 64] to have 3 channels, but got 6 channels instead

    opened by huameinan219 3
  • TensorFlow 2 implementation

    TensorFlow 2 implementation

    For anyone who might need TensorFlow 2.x implementation of Fast Fourier Convolution (FFC) there is an unofficial port of this project: https://github.com/uladzislau-varabei/ffc-tf2.

    In case you have ideas on how to improve it or found a bug just let me know.

    opened by uladzislau-varabei 0
  • Pretrained models doesn't match code

    Pretrained models doesn't match code

    Hi! Greatly appreciate your work! It seems that pretrained weights that you provided in issue #1 doesn't match the code:

    • layers are named differently
    • there is size mismatch in some layers, f.e. size mismatch for layer3.3.conv2.ffc.convl2l.weight: copying a param with shape torch.Size([192, 192, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]).

    Can you please check it out?

    opened by dreminm 0
  • Implementation on EfficientNet

    Implementation on EfficientNet

    Please share implementation on anyone reasonably deep EfficienNet or EfficientNet_v2. I tried to follow method of ResNet but getting channel mismatching error.

    opened by kashyappiyush1998 0
  • Can not find torch.rfft in pytorch1.9

    Can not find torch.rfft in pytorch1.9

    Hi, I am using Pytorch 1.9 and I can not find this function torch.rfft. https://github.com/pkumivision/FFC/blob/ac66fd7ded8e1358de18c31590b141f20988fcd3/model_zoo/ffc.py#L54

    It seems like Pytorch 1.9 has moved this function into sth else: https://pytorch.org/docs/1.9.0/generated/torch.fft.rfft.html

    But I do not see their input arguments similar anymore, can u update this block to be compatible with the new Pytorch version ?

    opened by phongnhhn92 1
Owner
pkumi
pkumi
Unofficial implementation of Google's FNet: Mixing Tokens with Fourier Transforms

FNet: Mixing Tokens with Fourier Transforms Pytorch implementation of Fnet : Mixing Tokens with Fourier Transforms. Citation: @misc{leethorp2021fnet,

Rishikesh (ऋषिकेश) 218 Jan 5, 2023
PyTorch implementation of "Conformer: Convolution-augmented Transformer for Speech Recognition" (INTERSPEECH 2020)

PyTorch implementation of Conformer: Convolution-augmented Transformer for Speech Recognition. Transformer models are good at capturing content-based

Soohwan Kim 565 Jan 4, 2023
🍀 Pytorch implementation of various Attention Mechanisms, MLP, Re-parameter, Convolution, which is helpful to further understand papers.⭐⭐⭐

?? Pytorch implementation of various Attention Mechanisms, MLP, Re-parameter, Convolution, which is helpful to further understand papers.⭐⭐⭐

xmu-xiaoma66 7.7k Jan 5, 2023
PyTorch implementation of the R2Plus1D convolution based ResNet architecture described in the paper "A Closer Look at Spatiotemporal Convolutions for Action Recognition"

R2Plus1D-PyTorch PyTorch implementation of the R2Plus1D convolution based ResNet architecture described in the paper "A Closer Look at Spatiotemporal

Irhum Shafkat 342 Dec 16, 2022
PyTorch implementation of Deformable Convolution

Deformable Convolutional Networks in PyTorch This repo is an implementation of Deformable Convolution. Ported from author's MXNet implementation. Buil

null 411 Dec 16, 2022
PyTorch implementation of Deformable Convolution

PyTorch implementation of Deformable Convolution !!!Warning: There is some issues in this implementation and this repo is not maintained any more, ple

Wei Ouyang 893 Dec 18, 2022
An implementation of Video Frame Interpolation via Adaptive Separable Convolution using PyTorch

This work has now been superseded by: https://github.com/sniklaus/revisiting-sepconv sepconv-slomo This is a reference implementation of Video Frame I

Simon Niklaus 984 Dec 16, 2022
Implementations of orthogonal and semi-orthogonal convolutions in the Fourier domain with applications to adversarial robustness

Orthogonalizing Convolutional Layers with the Cayley Transform This repository contains implementations and source code to reproduce experiments for t

CMU Locus Lab 36 Dec 30, 2022
RDA: Robust Domain Adaptation via Fourier Adversarial Attacking

RDA: Robust Domain Adaptation via Fourier Adversarial Attacking Updates 08/2021: check out our domain adaptation for video segmentation paper Domain A

null 17 Nov 30, 2022
Projecting interval uncertainty through the discrete Fourier transform

Projecting interval uncertainty through the discrete Fourier transform This repo

null 1 Mar 2, 2022
official code for dynamic convolution decomposition

Revisiting Dynamic Convolution via Matrix Decomposition (ICLR 2021) A pytorch implementation of DCD. If you use this code in your research please cons

Yunsheng Li 110 Nov 23, 2022
[ICCV2021] Official code for "Channel-wise Topology Refinement Graph Convolution for Skeleton-Based Action Recognition"

CTR-GCN This repo is the official implementation for Channel-wise Topology Refinement Graph Convolution for Skeleton-Based Action Recognition. The pap

Yuxin Chen 148 Dec 16, 2022
PyTorch reimplementation of the paper Involution: Inverting the Inherence of Convolution for Visual Recognition [CVPR 2021].

Involution: Inverting the Inherence of Convolution for Visual Recognition Unofficial PyTorch reimplementation of the paper Involution: Inverting the I

Christoph Reich 100 Dec 1, 2022
Super-Fast-Adversarial-Training - A PyTorch Implementation code for developing super fast adversarial training

Super-Fast-Adversarial-Training This is a PyTorch Implementation code for develo

LBK 26 Dec 2, 2022
Implementation of the "PSTNet: Point Spatio-Temporal Convolution on Point Cloud Sequences" paper.

PSTNet: Point Spatio-Temporal Convolution on Point Cloud Sequences Introduction Point cloud sequences are irregular and unordered in the spatial dimen

Hehe Fan 63 Dec 9, 2022
Implementation for Simple Spectral Graph Convolution in ICLR 2021

Simple Spectral Graph Convolutional Overview This repo contains an example implementation of the Simple Spectral Graph Convolutional (S^2GC) model. Th

allenhaozhu 64 Dec 31, 2022
MXNet implementation for: Drop an Octave: Reducing Spatial Redundancy in Convolutional Neural Networks with Octave Convolution

Octave Convolution MXNet implementation for: Drop an Octave: Reducing Spatial Redundancy in Convolutional Neural Networks with Octave Convolution Imag

Meta Research 549 Dec 28, 2022
Tensorflow Implementation for "Pre-trained Deep Convolution Neural Network Model With Attention for Speech Emotion Recognition"

Tensorflow Implementation for "Pre-trained Deep Convolution Neural Network Model With Attention for Speech Emotion Recognition" Pre-trained Deep Convo

Ankush Malaker 5 Nov 11, 2022
Official PyTorch implementation for FastDPM, a fast sampling algorithm for diffusion probabilistic models

Official PyTorch implementation for "On Fast Sampling of Diffusion Probabilistic Models". FastDPM generation on CIFAR-10, CelebA, and LSUN datasets. S

Zhifeng Kong 68 Dec 26, 2022