• Stars
    star
    654
  • Rank 68,429 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PyTorch implementation of Deformable ConvNets v2 (Modulated Deformable Convolution)

PyTorch implementation of Deformable ConvNets v2

This repository contains code for Deformable ConvNets v2 (Modulated Deformable Convolution) based on Deformable ConvNets v2: More Deformable, Better Results implemented in PyTorch. This implementation of deformable convolution based on ChunhuanLin/deform_conv_pytorch, thanks to ChunhuanLin.

TODO

  • Initialize weight of modulated deformable convolution based on paper
  • Learning rates of offset and modulation are set to different values from other layers
  • Results of ScaledMNIST experiments
  • Support different stride
  • Support deformable group
  • DeepLab + DCNv2
  • Results of VOC segmentation experiments

Requirements

  • Python 3.6
  • PyTorch 1.0

Usage

Replace regular convolution (following model's conv2) with modulated deformable convolution:

class ConvNet(nn.Module):
  def __init__(self):
    self.relu = nn.ReLU(inplace=True)
    self.pool = nn.MaxPool2d((2, 2))
    self.avg_pool = nn.AdaptiveAvgPool2d(1)

    self.conv1 = nn.Conv2d(3, 32, 3, padding=1)
    self.bn1 = nn.BatchNorm2d(32)
    self.conv2 = nn.DeformConv2d(32, 64, 3, padding=1, modulation=True)
    self.bn2 = nn.BatchNorm2d(64)

    self.fc = nn.Linear(64, 10)

  def forward(self, x):
    x = self.relu(self.bn1(self.conv1(x)))
    x = self.pool(x)
    x = self.relu(self.bn2(self.conv2(x)))

    x = self.avg_pool(x)
    x = x.view(x.shape[0], -1)
    x = self.fc(x)

    return x

Training

ScaledMNIST

ScaledMNIST is randomly scaled MNIST.

Use modulated deformable convolution at conv3~4:

python train.py --arch ScaledMNISTNet --deform True --modulation True --min-deform-layer 3

Use deformable convolution at conv3~4:

python train.py --arch ScaledMNISTNet --deform True --modulation False --min-deform-layer 3

Use only regular convolution:

python train.py --arch ScaledMNISTNet --deform False --modulation False

Results

ScaledMNIST

Model Accuracy (%) Loss
w/o DCN 97.22 0.113
w/ DCN @conv4 98.60 0.049
w/ DCN @conv3~4 98.95 0.035
w/ DCNv2 @conv4 98.45 0.058
w/ DCNv2 @conv3~4 99.21 0.027

More Repositories

1

pytorch-nested-unet

PyTorch implementation of UNet++ (Nested U-Net).
Python
709
star
2

keras-arcface

Keras implementation of ArcFace, CosFace, and SphereFace
Python
271
star
3

pytorch-adacos

PyTorch implementation of AdaCos
Python
204
star
4

pytorch-auto-augment

PyTorch implementation of AutoAugment.
Python
148
star
5

pytorch-res2net

PyTorch implementation of Res2Net
Python
105
star
6

kaggle-aptos2019-blindness-detection

11th place solution for APTOS 2019 Blindness Detection on Kaggle (https://www.kaggle.com/c/aptos2019-blindness-detection).
Python
42
star
7

keras-cosine-annealing

Keras implementation of Cosine Annealing Scheduler
Python
41
star
8

pytorch-ricap

PyTorch implementation of RICAP (Random Image Cropping And Patching)
Python
37
star
9

keras-auto-augment

Keras implementation of AutoAugment.
Python
34
star
10

kaggle-pku-autonomous-driving

Part of 5th place solution for Peking University/Baidu - Autonomous Driving on Kaggle (https://www.kaggle.com/c/pku-autonomous-driving).
Python
21
star
11

pytorch-lars

PyTorch implementation of LARS (Layer-wise Adaptive Rate Scaling)
Python
16
star
12

tf-dark-pose

This is an unofficial TensorFlow implementation of DARK Pose (Distribution Aware Coordinate Representation for Human Pose Estimation).
Python
2
star
13

pytorch-scale-aware-triplet

PyTorch implementation of Scale-Aware Triplet Networks
Python
2
star
14

kaggle-carvana-image-masking-challenge

48th solution for Carvana image masking challenge on Kaggle (https://www.kaggle.com/c/carvana-image-masking-challenge).
Python
1
star
15

chainer-m2det

Chainer implementation of M2Det.
Python
1
star