Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

fix cv2 compatibility between versions 3 and 4; ignore vscode; minor … #846

Merged
merged 1 commit into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ dist/
# Pycharm editor settings
.idea

# vscode editor settings
.vscode

# MacOS
.DS_Store

Expand Down
16 changes: 8 additions & 8 deletions docker/docker-jupyter/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import os
from IPython.lib import passwd

#c = c # pylint:disable=undefined-variable
# c = c # pylint:disable=undefined-variable
c = get_config()
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = int(os.getenv('PORT', 8888))
c.NotebookApp.open_browser = False

# sets a password if PASSWORD is set in the environment
if 'PASSWORD' in os.environ:
password = os.environ['PASSWORD']
if password:
c.NotebookApp.password = passwd(password)
else:
c.NotebookApp.password = ''
c.NotebookApp.token = ''
del os.environ['PASSWORD']
password = os.environ['PASSWORD']
if password:
c.NotebookApp.password = passwd(password)
else:
c.NotebookApp.password = ''
c.NotebookApp.token = ''
del os.environ['PASSWORD']
8 changes: 4 additions & 4 deletions maskrcnn_benchmark/data/datasets/voc.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def _preprocess_annotation(self, target):
gt_classes = []
difficult_boxes = []
TO_REMOVE = 1

for obj in target.iter("object"):
difficult = int(obj.find("difficult").text) == 1
if not self.keep_difficult and difficult:
Expand All @@ -99,9 +99,9 @@ def _preprocess_annotation(self, target):
# Make pixel indexes 0-based
# Refer to "https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/datasets/pascal_voc.py#L208-L211"
box = [
bb.find("xmin").text,
bb.find("ymin").text,
bb.find("xmax").text,
bb.find("xmin").text,
bb.find("ymin").text,
bb.find("xmax").text,
bb.find("ymax").text,
]
bndbox = tuple(
Expand Down
4 changes: 2 additions & 2 deletions maskrcnn_benchmark/layers/dcn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#
#
# Copied From [mmdetection](https://github.com/open-mmlab/mmdetection/tree/master/mmdet/ops/dcn)
#
#
156 changes: 78 additions & 78 deletions maskrcnn_benchmark/layers/dcn/deform_conv_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ class DeformConvFunction(Function):

@staticmethod
def forward(
ctx,
input,
offset,
ctx,
input,
offset,
weight,
stride=1,
padding=0,
dilation=1,
groups=1,
deformable_groups=1,
stride=1,
padding=0,
dilation=1,
groups=1,
deformable_groups=1,
im2col_step=64
):
if input is not None and input.dim() != 4:
Expand Down Expand Up @@ -47,21 +47,21 @@ def forward(
assert (input.shape[0] %
cur_im2col_step) == 0, 'im2col step must divide batchsize'
_C.deform_conv_forward(
input,
weight,
offset,
output,
ctx.bufs_[0],
input,
weight,
offset,
output,
ctx.bufs_[0],
ctx.bufs_[1],
weight.size(3),
weight.size(2),
ctx.stride[1],
weight.size(3),
weight.size(2),
ctx.stride[1],
ctx.stride[0],
ctx.padding[1],
ctx.padding[0],
ctx.padding[1],
ctx.padding[0],
ctx.dilation[1],
ctx.dilation[0],
ctx.groups,
ctx.dilation[0],
ctx.groups,
ctx.deformable_groups,
cur_im2col_step
)
Expand All @@ -85,45 +85,45 @@ def backward(ctx, grad_output):
grad_input = torch.zeros_like(input)
grad_offset = torch.zeros_like(offset)
_C.deform_conv_backward_input(
input,
offset,
grad_output,
input,
offset,
grad_output,
grad_input,
grad_offset,
weight,
ctx.bufs_[0],
grad_offset,
weight,
ctx.bufs_[0],
weight.size(3),
weight.size(2),
ctx.stride[1],
weight.size(2),
ctx.stride[1],
ctx.stride[0],
ctx.padding[1],
ctx.padding[0],
ctx.padding[1],
ctx.padding[0],
ctx.dilation[1],
ctx.dilation[0],
ctx.groups,
ctx.dilation[0],
ctx.groups,
ctx.deformable_groups,
cur_im2col_step
)

if ctx.needs_input_grad[2]:
grad_weight = torch.zeros_like(weight)
_C.deform_conv_backward_parameters(
input,
offset,
input,
offset,
grad_output,
grad_weight,
ctx.bufs_[0],
ctx.bufs_[1],
grad_weight,
ctx.bufs_[0],
ctx.bufs_[1],
weight.size(3),
weight.size(2),
ctx.stride[1],
weight.size(2),
ctx.stride[1],
ctx.stride[0],
ctx.padding[1],
ctx.padding[0],
ctx.padding[1],
ctx.padding[0],
ctx.dilation[1],
ctx.dilation[0],
ctx.groups,
ctx.deformable_groups,
ctx.dilation[0],
ctx.groups,
ctx.deformable_groups,
1,
cur_im2col_step
)
Expand Down Expand Up @@ -180,24 +180,24 @@ def forward(
ModulatedDeformConvFunction._infer_shape(ctx, input, weight))
ctx._bufs = [input.new_empty(0), input.new_empty(0)]
_C.modulated_deform_conv_forward(
input,
weight,
bias,
ctx._bufs[0],
offset,
mask,
input,
weight,
bias,
ctx._bufs[0],
offset,
mask,
output,
ctx._bufs[1],
weight.shape[2],
weight.shape[3],
ctx._bufs[1],
weight.shape[2],
weight.shape[3],
ctx.stride,
ctx.stride,
ctx.stride,
ctx.padding,
ctx.padding,
ctx.dilation,
ctx.padding,
ctx.padding,
ctx.dilation,
ctx.groups,
ctx.deformable_groups,
ctx.dilation,
ctx.groups,
ctx.deformable_groups,
ctx.with_bias
)
return output
Expand All @@ -214,29 +214,29 @@ def backward(ctx, grad_output):
grad_weight = torch.zeros_like(weight)
grad_bias = torch.zeros_like(bias)
_C.modulated_deform_conv_backward(
input,
weight,
bias,
ctx._bufs[0],
offset,
mask,
input,
weight,
bias,
ctx._bufs[0],
offset,
mask,
ctx._bufs[1],
grad_input,
grad_weight,
grad_bias,
grad_offset,
grad_input,
grad_weight,
grad_bias,
grad_offset,
grad_mask,
grad_output,
weight.shape[2],
weight.shape[3],
grad_output,
weight.shape[2],
weight.shape[3],
ctx.stride,
ctx.stride,
ctx.stride,
ctx.padding,
ctx.padding,
ctx.dilation,
ctx.padding,
ctx.padding,
ctx.dilation,
ctx.dilation,
ctx.groups,
ctx.deformable_groups,
ctx.groups,
ctx.deformable_groups,
ctx.with_bias
)
if not ctx.with_bias:
Expand Down
42 changes: 21 additions & 21 deletions maskrcnn_benchmark/layers/dcn/deform_pool_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ def forward(
output = data.new_empty(n, out_channels, out_size, out_size)
output_count = data.new_empty(n, out_channels, out_size, out_size)
_C.deform_psroi_pooling_forward(
data,
rois,
offset,
output,
output_count,
data,
rois,
offset,
output,
output_count,
ctx.no_trans,
ctx.spatial_scale,
ctx.out_channels,
ctx.group_size,
ctx.spatial_scale,
ctx.out_channels,
ctx.group_size,
ctx.out_size,
ctx.part_size,
ctx.sample_per_part,
ctx.part_size,
ctx.sample_per_part,
ctx.trans_std
)

Expand All @@ -73,19 +73,19 @@ def backward(ctx, grad_output):
grad_offset = torch.zeros_like(offset)

_C.deform_psroi_pooling_backward(
grad_output,
data,
rois,
offset,
output_count,
grad_output,
data,
rois,
offset,
output_count,
grad_input,
grad_offset,
ctx.no_trans,
ctx.spatial_scale,
grad_offset,
ctx.no_trans,
ctx.spatial_scale,
ctx.out_channels,
ctx.group_size,
ctx.out_size,
ctx.part_size,
ctx.group_size,
ctx.out_size,
ctx.part_size,
ctx.sample_per_part,
ctx.trans_std
)
Expand Down
22 changes: 11 additions & 11 deletions maskrcnn_benchmark/layers/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ def _output_size(dim):
class DFConv2d(nn.Module):
"""Deformable convolutional layer"""
def __init__(
self,
in_channels,
out_channels,
with_modulated_dcn=True,
kernel_size=3,
stride=1,
self,
in_channels,
out_channels,
with_modulated_dcn=True,
kernel_size=3,
stride=1,
groups=1,
dilation=1,
deformable_groups=1,
Expand Down Expand Up @@ -156,7 +156,7 @@ def __init__(
padding=padding,
groups=1,
dilation=dilation
)
)
for l in [self.offset,]:
nn.init.kaiming_uniform_(l.weight, a=1)
torch.nn.init.constant_(l.bias, 0.)
Expand Down Expand Up @@ -192,10 +192,10 @@ def forward(self, x):
output_shape = [
(i + 2 * p - (di * (k - 1) + 1)) // d + 1
for i, p, di, k, d in zip(
x.shape[-2:],
self.padding,
self.dilation,
self.kernel_size,
x.shape[-2:],
self.padding,
self.dilation,
self.kernel_size,
self.stride
)
]
Expand Down
Loading