Giter VIP home page Giter VIP logo

involution's Introduction

Involution: Inverting the Inherence of Convolution for Visual Recognition

License: MIT

Unofficial PyTorch reimplementation of the paper Involution: Inverting the Inherence of Convolution for Visual Recognition by Duo Li, Jie Hu, Changhu Wang et al. published at CVPR 2021.

This repository includes a pure PyTorch implementation of a 2D and 3D involution.

Please note that the official implementation provides a more memory efficient CuPy implementation of the 2D involution. Additionally, shikishima-TasakiLab provides a fast and memory efficent CUDA implementation of the 2D Involution.

Installation

The 2D and 3D involution can be easily installed by using pip.

pip install git+https://github.com/ChristophReich1996/Involution

Example Usage

Additional examples, such as strided involutions or transposed convolution like involutions, can be found in the example.py file.

The 2D involution can be used as a nn.Module as follows:

import torch
from involution import Involution2d

involution = Involution2d(in_channels=32, out_channels=64)
output = involution(torch.rand(1, 32, 128, 128))

The 2D involution takes the following parameters.

Parameter Description Type
in_channels Number of input channels int
out_channels Number of output channels int
sigma_mapping Non-linear mapping as introduced in the paper. If none BN + ReLU is utilized (default=None) Optional[nn.Module]
kernel_size Kernel size to be used (default=(7, 7)) Union[int, Tuple[int, int]]
stride Stride factor to be utilized (default=(1, 1)) Union[int, Tuple[int, int]]
groups Number of groups to be employed (default=1) int
reduce_ratio Reduce ration of involution channels (default=1) int
dilation Dilation in unfold to be employed (default=(1, 1)) Union[int, Tuple[int, int]]
padding Padding to be used in unfold operation (default=(3, 3)) Union[int, Tuple[int, int]]
bias If true bias is utilized in each convolution layer (default=False) bool
force_shape_match If true potential shape mismatch is solved by performing avg pool (default=False) bool
**kwargs Unused additional key word arguments Any

The 3D involution can be used as a nn.Module as follows:

import torch
from involution import Involution3d

involution = Involution3d(in_channels=8, out_channels=16)
output = involution(torch.rand(1, 8, 32, 32, 32))

The 3D involution takes the following parameters.

Parameter Description Type
in_channels Number of input channels int
out_channels Number of output channels int
sigma_mapping Non-linear mapping as introduced in the paper. If none BN + ReLU is utilized Optional[nn.Module]
kernel_size Kernel size to be used (default=(7, 7, 7)) Union[int, Tuple[int, int, int]]
stride Stride factor to be utilized (default=(1, 1, 1)) Union[int, Tuple[int, int, int]]
groups Number of groups to be employed (default=1) int
reduce_ratio Reduce ration of involution channels (default=1) int
dilation Dilation in unfold to be employed (default=(1, 1, 1)) Union[int, Tuple[int, int, int]]
padding Padding to be used in unfold operation (default=(3, 3, 3)) Union[int, Tuple[int, int, int]]
bias If true bias is utilized in each convolution layer (default=False) bool
force_shape_match If true potential shape mismatch is solved by performing avg pool (default=False) bool
**kwargs Unused additional key word arguments Any

Reference

@inproceedings{Li2021,
    author = {Li, Duo and Hu, Jie and Wang, Changhu and Li, Xiangtai and She, Qi and Zhu, Lei and Zhang, Tong and Chen, Qifeng},
    title = {Involution: Inverting the Inherence of Convolution for Visual Recognition},
    booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month = {June},
    year = {2021}
}

involution's People

Contributors

christophreich1996 avatar shikishima-tasakilab avatar deh40 avatar memmelma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.