Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Deformable Convolution operation. #1586

Merged
merged 9 commits into from
Dec 4, 2019
Merged

Commits on Dec 1, 2019

  1. Add Deformable Convolution operation.

    This adds the deformable convolution operation, as described in Deformable Convolutional Networks (https://arxiv.org/abs/1703.06211).
    
    - The code is based on https://github.com/open-mmlab/mmdetection/blob/master/mmdet/ops/dcn/src/deform_conv_cuda.cpp ; the whole code was modified and refactored to remove redundancies and increase clarity, and to adapt it to torchvision.
    
    - The CPU part is a direct copy of the CUDA code; it might make sense to do follow-up adjustments in the CPU code to simplify it / optimize it, or to reuse functionality between CPU and CUDA..
    
    - We also add tests (with a non-trivial set of parameters); they can be made more robust by randomizing the parameters and executing multiple times.
    Pedro Freire authored and pedrofreire committed Dec 1, 2019
    Configuration menu
    Copy the full SHA
    acb507b View commit details
    Browse the repository at this point in the history
  2. Update DeformConv to be more consistent w/ Conv2d

    * rename some variables and arguments to match Conv2d;
    * add optional bias;
    * add weight, offset and bias as module parameters;
    * remove the n_parallel_imgs parameter;
    * Fix __repr__;
    * etc..
    
    Initialization of weight and bias is the same as in Conv2d, and
    initialization of offsets to zero is the same as in the paper.
    
    This also includes some other small unrelated fixes/improvements.
    Pedro Freire authored and pedrofreire committed Dec 1, 2019
    Configuration menu
    Copy the full SHA
    f7c4984 View commit details
    Browse the repository at this point in the history
  3. Apply clang-format in DeformConv files.

    Pedro Freire authored and pedrofreire committed Dec 1, 2019
    Configuration menu
    Copy the full SHA
    a05f3f5 View commit details
    Browse the repository at this point in the history
  4. Import Optional type annotation

    Pedro Freire authored and pedrofreire committed Dec 1, 2019
    Configuration menu
    Copy the full SHA
    65749cc View commit details
    Browse the repository at this point in the history
  5. Remove offset param from DeformConv2d module

    - We pass the offset in the forward of DeformConv2d, instead of having
    an internal parameter. This adds some complexity to creating the module
    (e.g. now you have to worry about the output size, to create the
    offset), but it gives more flexibility.
    - We also use make_tuple for tuple creation, in an attempt to fix error
    w/ older compilers.
    Pedro Freire authored and pedrofreire committed Dec 1, 2019
    Configuration menu
    Copy the full SHA
    4e2dadf View commit details
    Browse the repository at this point in the history
  6. Replace abs by std::abs

    Old gcc versions were giving wrong results here, because they would
    resolve abs as int -> int, thus causing undesired truncation. Replacing
    abs by std::abs should allow for correct overloading of abs as float -> float.
    pedrofreire committed Dec 1, 2019
    Configuration menu
    Copy the full SHA
    a6092be View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    3d90f2c View commit details
    Browse the repository at this point in the history
  8. Reorder weight and offset args in deform_conv2d

    We place offset arg before the weight arg, to be more
    consistent with DeformConv2d.forward(input, offset)
    pedrofreire committed Dec 1, 2019
    Configuration menu
    Copy the full SHA
    929eecc View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    5aebed3 View commit details
    Browse the repository at this point in the history