{"id":31365737,"url":"https://github.com/developer0hye/pytorch-deformable-convolution-v2","last_synced_at":"2025-09-27T09:58:48.801Z","repository":{"id":37755162,"uuid":"354245948","full_name":"developer0hye/PyTorch-Deformable-Convolution-v2","owner":"developer0hye","description":"Don't feel pain to use Deformable Convolution","archived":false,"fork":false,"pushed_at":"2023-06-07T10:50:02.000Z","size":5634,"stargazers_count":344,"open_issues_count":1,"forks_count":34,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-05T03:46:38.037Z","etag":null,"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"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/developer0hye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.CFF","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-03T09:04:25.000Z","updated_at":"2025-08-16T14:44:14.000Z","dependencies_parsed_at":"2025-04-13T15:09:31.483Z","dependency_job_id":"b9d00880-0995-4e04-90ad-d8ea0e19ccf2","html_url":"https://github.com/developer0hye/PyTorch-Deformable-Convolution-v2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/developer0hye/PyTorch-Deformable-Convolution-v2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developer0hye%2FPyTorch-Deformable-Convolution-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developer0hye%2FPyTorch-Deformable-Convolution-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developer0hye%2FPyTorch-Deformable-Convolution-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developer0hye%2FPyTorch-Deformable-Convolution-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developer0hye","download_url":"https://codeload.github.com/developer0hye/PyTorch-Deformable-Convolution-v2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developer0hye%2FPyTorch-Deformable-Convolution-v2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277213139,"owners_count":25780315,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-27T02:00:08.978Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"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"],"created_at":"2025-09-27T09:58:43.436Z","updated_at":"2025-09-27T09:58:48.794Z","avatar_url":"https://github.com/developer0hye.png","language":"Jupyter Notebook","readme":"# PyTorch-Deformable-Convolution-v2\nDon't feel pain to use Deformable Convolution v2(DCNv2)\n\n![](offset_visualization.gif)\n\nIf you are curious about how to visualize offset(red point), refer to [offset_visualization.py](./offset_visualization.py)\n\n# Usage\n\n```python\n\nfrom dcn import DeformableConv2d\n\nclass Model(nn.Module):\n    ...\n    self.conv = DeformableConv2d(in_channels=32, out_channels=32, kernel_size=3, stride=1, padding=1)\n    ...\n\n```\n\n# Experiment\n\nYou can simply reproduce the results of my experiment on Google Colab.\n\nRefer to experiment.ipynb!\n\n## Task\n\n**Scaled-MNIST** Handwritten Digit Classification\n\n## Model\n\nSimple CNN Model including 5 conv layers\n\n```python\nclass MNISTClassifier(nn.Module):\n    def __init__(self,\n                 deformable=False):\n\n        super(MNISTClassifier, self).__init__()\n        \n        self.conv1 = nn.Conv2d(1, 32, kernel_size=3, stride=1, padding=1, bias=True)\n        self.conv2 = nn.Conv2d(32, 32, kernel_size=3, stride=1, padding=1, bias=True)\n        self.conv3 = nn.Conv2d(32, 32, kernel_size=3, stride=1, padding=1, bias=True)   \n        conv = nn.Conv2d if deformable==False else DeformableConv2d\n        self.conv4 = conv(32, 32, kernel_size=3, stride=1, padding=1, bias=True)\n        self.conv5 = conv(32, 32, kernel_size=3, stride=1, padding=1, bias=True)\n        \n        self.pool = nn.MaxPool2d(2)\n        self.gap = nn.AdaptiveAvgPool2d((1, 1))\n        self.fc = nn.Linear(32, 10)\n        \n    def forward(self, x):\n        x = torch.relu(self.conv1(x))\n        x = self.pool(x) # [14, 14]\n        x = torch.relu(self.conv2(x))\n        x = self.pool(x) # [7, 7]\n        x = torch.relu(self.conv3(x))\n        x = torch.relu(self.conv4(x))\n        x = torch.relu(self.conv5(x))\n        x = self.gap(x)\n        x = x.flatten(start_dim=1)\n        x = self.fc(x)\n        return x\n```\n\n## Training\n\n- Optimizer: Adam\n- Learning Rate: 1e-3\n- Learning Rate Scheduler: StepLR(step_size=1, gamma=0.7)\n- Batch Size: 64\n- Epochs: 14\n- Augmentation: **NONE**\n\n## Test\n\nIn the [paper](https://arxiv.org/abs/1811.11168), authors mentioned that the network's ability to model geometric transformation with DCNv2 is considerably enhanced.\n\nI verified it with scale augmentation.\n\nAll images in the test set of MNIST dataset are augmented by scale augmentation(x0.5, x0.6, ..., x1.4, x1.5).\n\n\n### Results\n\n|Model|Top-1 Accuracy(%)|\n|---|---|\n|w/o DCNv2|90.03%|\n|**w/ DCNv2**|**92.90%**|\n\n## References\n\n[mxnet implementation](https://github.com/apache/incubator-mxnet/blob/5722f8b38af58c5a296e46ca695bfaf7cff85040/python/mxnet/gluon/nn/conv_layers.py#L1447-L1631\n)\n\n## To Do Lists\n\n- [ ] Support Onnx Conversion\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloper0hye%2Fpytorch-deformable-convolution-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveloper0hye%2Fpytorch-deformable-convolution-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloper0hye%2Fpytorch-deformable-convolution-v2/lists"}