pytorch-deformable-convolution-v2

Don't feel pain to use Deformable Convolution

https://github.com/developer0hye/pytorch-deformable-convolution-v2

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (5.8%) to scientific vocabulary

Keywords

cnn convolutional-neural-networks dcn dcnv1 dcnv2 deep-learning deformable-convolution deformable-convolutional-networks object-detection pytorch pytorch-deformable-convolution pytorch-deformable-convolution-v2 segmentation
Last synced: 6 months ago · JSON representation ·

Repository

Don't feel pain to use Deformable Convolution

Basic Info
  • Host: GitHub
  • Owner: developer0hye
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: main
  • Homepage:
  • Size: 5.37 MB
Statistics
  • Stars: 341
  • Watchers: 2
  • Forks: 33
  • Open Issues: 1
  • Releases: 0
Topics
cnn convolutional-neural-networks dcn dcnv1 dcnv2 deep-learning deformable-convolution deformable-convolutional-networks object-detection pytorch pytorch-deformable-convolution pytorch-deformable-convolution-v2 segmentation
Created almost 5 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

PyTorch-Deformable-Convolution-v2

Don't feel pain to use Deformable Convolution v2(DCNv2)

If you are curious about how to visualize offset(red point), refer to offset_visualization.py

Usage

```python

from dcn import DeformableConv2d

class Model(nn.Module): ... self.conv = DeformableConv2d(inchannels=32, outchannels=32, kernel_size=3, stride=1, padding=1) ...

```

Experiment

You can simply reproduce the results of my experiment on Google Colab.

Refer to experiment.ipynb!

Task

Scaled-MNIST Handwritten Digit Classification

Model

Simple CNN Model including 5 conv layers

```python class MNISTClassifier(nn.Module): def init(self, deformable=False):

    super(MNISTClassifier, self).__init__()

    self.conv1 = nn.Conv2d(1, 32, kernel_size=3, stride=1, padding=1, bias=True)
    self.conv2 = nn.Conv2d(32, 32, kernel_size=3, stride=1, padding=1, bias=True)
    self.conv3 = nn.Conv2d(32, 32, kernel_size=3, stride=1, padding=1, bias=True)   
    conv = nn.Conv2d if deformable==False else DeformableConv2d
    self.conv4 = conv(32, 32, kernel_size=3, stride=1, padding=1, bias=True)
    self.conv5 = conv(32, 32, kernel_size=3, stride=1, padding=1, bias=True)

    self.pool = nn.MaxPool2d(2)
    self.gap = nn.AdaptiveAvgPool2d((1, 1))
    self.fc = nn.Linear(32, 10)

def forward(self, x):
    x = torch.relu(self.conv1(x))
    x = self.pool(x) # [14, 14]
    x = torch.relu(self.conv2(x))
    x = self.pool(x) # [7, 7]
    x = torch.relu(self.conv3(x))
    x = torch.relu(self.conv4(x))
    x = torch.relu(self.conv5(x))
    x = self.gap(x)
    x = x.flatten(start_dim=1)
    x = self.fc(x)
    return x

```

Training

  • Optimizer: Adam
  • Learning Rate: 1e-3
  • Learning Rate Scheduler: StepLR(step_size=1, gamma=0.7)
  • Batch Size: 64
  • Epochs: 14
  • Augmentation: NONE

Test

In the paper, authors mentioned that the network's ability to model geometric transformation with DCNv2 is considerably enhanced.

I verified it with scale augmentation.

All images in the test set of MNIST dataset are augmented by scale augmentation(x0.5, x0.6, ..., x1.4, x1.5).

Results

|Model|Top-1 Accuracy(%)| |---|---| |w/o DCNv2|90.03%| |w/ DCNv2|92.90%|

References

mxnet implementation

To Do Lists

  • [ ] Support Onnx Conversion

Owner

  • Name: Yonghye Kwon
  • Login: developer0hye
  • Kind: user
  • Location: Seoul, Korea
  • Company: MarkAny

practical

Citation (CITATION.CFF)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Kwon"
  given-names: "Yonghye"
  orcid: "https://orcid.org/my-orcid?orcid=0000-0001-8308-9909"
title: "PyTorch-Deformable-Convolution-v2"
version: 1.0.0
date-released: 2022-04-20
url: "https://github.com/developer0hye/PyTorch-Deformable-Convolution-v2"

GitHub Events

Total
  • Watch event: 22
  • Fork event: 3
Last Year
  • Watch event: 22
  • Fork event: 3