addons icon indicating copy to clipboard operation
addons copied to clipboard

Deformable Convolutional Op Support

Open rootkitchao opened this issue 5 years ago • 20 comments

System information

  • TensorFlow version (you are using):2.0 alpha
  • TensorFlow Addons version:0,21
  • Is it in the tf.contrib (if so, where):no
  • Are you willing to contribute it (yes/no):yes,if i know how to do that
  • Are you willing to maintain it going forward? (yes/no):yes

Describe the feature and the current behavior/state. Deformable Convolutional Network(https://arxiv.org/pdf/1703.06211.pdf,https://arxiv.org/pdf/1703.06211.pdf) has achieved good results in the du detection task.But the current version of Tensorflow does not seem to implement deformable convolution operations.The efficiency of some third-party implementations of deformable convolution operations is lower than that of the mxnet version(https://github.com/msracver/Deformable-ConvNets).I hope that Tensorflow can add native deformable convolution operations in future versions. Thanks. Will this change the current api? How? Yes,Add a new op Who will benefit with this feature? Any one want to use tensorflow for object detection. Any Other info.

rootkitchao avatar Apr 16 '19 12:04 rootkitchao

Here's a python only implementation of v1 for Keras which can be ported to TF-Keras. This repository is the official implementation with CUDA code; it's written using MXNet but it can be ported over to TensorFlow.

Here are the papers:

  1. Deformable Convolutional Networks
  2. Deformable ConvNets v2

I can start working on this if needed. I'll get the python implementation for v2 up and running first, followed by the proper CUDA/C++ implementation.

Squadrick avatar May 04 '19 08:05 Squadrick

Here's a python only implementation of v1 for Keras which can be ported to TF-Keras. This repository is the official implementation with CUDA code; it's written using MXNet but it can be ported over to TensorFlow. Here are the papers:

Deformable Convolutional Networks Deformable ConvNets v2

I can start working on this if needed. I'll get the python implementation for v2 up and running first, followed by the proper CUDA/C++ implementation.

Thanks for reply.And here is a Mask RCNN implemented by Tensorflow that may help test.

rootkitchao avatar May 04 '19 10:05 rootkitchao

@rootkitchao Welcome, William. I think you can go first because you seems willing to contribute the codes, right?

Are you willing to contribute it (yes/no):yes,if i know how to do that

Sorry for the delay, and thank @Squadrick for the reference paper and implementation :-)

facaiy avatar May 16 '19 05:05 facaiy

@rootkitchao Any update? I can work on this if you aren't.

Squadrick avatar May 29 '19 07:05 Squadrick

Using native CUDA for deform conv is dependant on #118 .

Squadrick avatar Jun 12 '19 06:06 Squadrick

I tried to look into it, but it is too hard for me to do as I don't have experience in CUDA.

I wonder how hard would it be to port this implementation (tf1.4) to tf2.0 : https://github.com/Zardinality/TF-deformable-conv

This is the first version of the paper, but ideally it would be nice to have deformable-conv V2 : https://arxiv.org/abs/1811.11168 For which there is an implementation for pytorch, as cited by @Squadrick

Thank you

jlhervy avatar Nov 20 '19 16:11 jlhervy

@Squadrick you mentioned you'd implement DCN v2 in TF 2 : is this something you're having progress with ?

vlordier avatar Dec 03 '19 14:12 vlordier

@vlordier Nope, haven't found the time to get around to this. Feel free to open a PR if you decide to work on this.

Squadrick avatar Dec 03 '19 14:12 Squadrick

/cc @smallsunsun1

bhack avatar Feb 05 '20 22:02 bhack

/cc @smallsunsun1

I implemented a Deformable Conv2D V2 And DeformablePsROIAlign operation In both cpu and gpu according to mmdetection https://github.com/open-mmlab/mmdetection. My implenmentation is https://github.com/smallsunsun1/custom_ops/tree/master/deformable_conv2d_ops_new , which support tf2.0 and built by CMake.

smallsunsun1 avatar Feb 06 '20 02:02 smallsunsun1

@smallsunsun1 Do you want to officially PR your impl on TF addons?

bhack avatar Feb 06 '20 15:02 bhack

@bhack Maybe I can have a try, but I haven't PR before, it may task some time==

smallsunsun1 avatar Feb 07 '20 02:02 smallsunsun1

@bhack Maybe I can have a try, but I haven't PR before, it may task some time==

Please let us know if there is anyway we can help. We have some documentation to get you started.

TFA pull requests: https://github.com/tensorflow/addons/blob/master/CONTRIBUTING.md#pull-requests Getting started with contributions: https://github.com/gabrieldemarmiesse/getting_started_open_source

seanpmorgan avatar Feb 07 '20 02:02 seanpmorgan

@seanpmorgan I clone the addons repo, tested my deformable_conv2d impl in local, building passed in tensorflow2.0 and cuda10.0, noticed the lastest branch is target in tensorflow2.1 and cuda10.1. But I can't have a cuda10.1 environment to test the code. Is there any problem if I push a request

smallsunsun1 avatar Feb 08 '20 13:02 smallsunsun1

@seanpmorgan I clone the addons repo, tested my deformable_conv2d impl in local, building passed in tensorflow2.0 and cuda10.0, noticed the lastest branch is target in tensorflow2.1 and cuda10.1. But I can't have a cuda10.1 environment to test the code. Is there any problem if I push a request

Not at all. We have CI testing that will run it on GPU for you (So even if you didn't have a GPU you could still test it.) We welcome WIP PRs so feel free to start the PR and we can go from there.

seanpmorgan avatar Feb 08 '20 15:02 seanpmorgan

already open a PR https://github.com/tensorflow/addons/pull/1129, support DeformableConv2d ,DeformablepsROIalign and EquiConv

smallsunsun1 avatar Feb 22 '20 06:02 smallsunsun1

Do you have any news about the progress of this PR and deformable convolutions in TensorFlow?

alexattia avatar Oct 02 '20 14:10 alexattia

I've created new PR since the previous PR is stale and contains the unknown license code. I'd like to make my PR reviewed before it gets stale ;-). https://github.com/tensorflow/addons/pull/2196

Licht-T avatar Oct 30 '20 10:10 Licht-T

Hello. I hope you are good. There is no implementation of deformable convolution in tensorflow2. Could someone please help me? There is a deform conv class where you can use it in tensorflow2 but you can not use it in tensorflow model? How can I make this class to be usable in models?

@aAmohammadrezaaA The state of deformable convolution in tensorflow 2 is tearful. There were several different merge requests with different implementations. I tried in the past some of them and all were quite good and working. However both tensorflow team and tf-addons team have little time to do good PR and integration it to the framework. The best advice right now is to try different framework if you want to have a good support of deformable convolutions.

Cospel avatar Jun 20 '22 08:06 Cospel

TensorFlow Addons is transitioning to a minimal maintenance and release mode. New features will not be added to this repository. For more information, please see our public messaging on this decision: TensorFlow Addons Wind Down

Please consider sending feature requests / contributions to other repositories in the TF community with a similar charters to TFA: Keras Keras-CV Keras-NLP

seanpmorgan avatar Mar 01 '23 03:03 seanpmorgan