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

This Pull resolves the issues with newer versions of Python and Pytorch #43

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
43 changes: 43 additions & 0 deletions configs/rotated/e2e_ms_rcnn_R_101_FPN_1x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
MODEL:
META_ARCHITECTURE: "GeneralizedRCNN"
WEIGHT: "catalog://ImageNetPretrained/MSRA/R-101"
BACKBONE:
CONV_BODY: "R-101-FPN"
RESNETS:
BACKBONE_OUT_CHANNELS: 256
RPN:
USE_FPN: True
ANCHOR_STRIDE: (4, 8, 16, 32, 64)
PRE_NMS_TOP_N_TRAIN: 2000
PRE_NMS_TOP_N_TEST: 1000
POST_NMS_TOP_N_TEST: 1000
FPN_POST_NMS_TOP_N_TEST: 1000
ROI_HEADS:
USE_FPN: True
ROI_BOX_HEAD:
POOLER_RESOLUTION: 7
POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125)
POOLER_SAMPLING_RATIO: 2
FEATURE_EXTRACTOR: "FPN2MLPFeatureExtractor"
PREDICTOR: "FPNPredictor"
ROI_MASK_HEAD:
POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125)
FEATURE_EXTRACTOR: "MaskRCNNFPNFeatureExtractor"
PREDICTOR: "MaskRCNNC4Predictor"
POOLER_RESOLUTION: 14
POOLER_SAMPLING_RATIO: 2
RESOLUTION: 28
SHARE_BOX_FEATURE_EXTRACTOR: False
MASK_ON: True
MASKIOU_ON: True
DATASETS:
TRAIN: ("smartflow_train", "smartflow_val")
TEST: ("smartflow_test",)
DATALOADER:
SIZE_DIVISIBILITY: 32
SOLVER:
BASE_LR: 0.02
WEIGHT_DECAY: 0.0001
STEPS: (60000, 80000)
MAX_ITER: 90000
OUTPUT_DIR: "/content/rotated_maskrcnn"
6 changes: 3 additions & 3 deletions maskrcnn_benchmark/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
_C.MODEL.ROI_BOX_HEAD.POOLER_RESOLUTION = 14
_C.MODEL.ROI_BOX_HEAD.POOLER_SAMPLING_RATIO = 0
_C.MODEL.ROI_BOX_HEAD.POOLER_SCALES = (1.0 / 16,)
_C.MODEL.ROI_BOX_HEAD.NUM_CLASSES = 81
_C.MODEL.ROI_BOX_HEAD.NUM_CLASSES = 200
# Hidden layer dimension when using an MLP for the RoI box head
_C.MODEL.ROI_BOX_HEAD.MLP_HEAD_DIM = 1024
# GN
Expand Down Expand Up @@ -326,7 +326,7 @@
_C.MODEL.ROI_KEYPOINT_HEAD.MLP_HEAD_DIM = 1024
_C.MODEL.ROI_KEYPOINT_HEAD.CONV_LAYERS = tuple(512 for _ in range(8))
_C.MODEL.ROI_KEYPOINT_HEAD.RESOLUTION = 14
_C.MODEL.ROI_KEYPOINT_HEAD.NUM_CLASSES = 17
_C.MODEL.ROI_KEYPOINT_HEAD.NUM_CLASSES = 200
_C.MODEL.ROI_KEYPOINT_HEAD.SHARE_BOX_FEATURE_EXTRACTOR = True


Expand Down Expand Up @@ -380,7 +380,7 @@
_C.MODEL.RETINANET = CN()

# This is the number of foreground classes and background.
_C.MODEL.RETINANET.NUM_CLASSES = 81
_C.MODEL.RETINANET.NUM_CLASSES = 200

# Anchor aspect ratios to use
_C.MODEL.RETINANET.ANCHOR_SIZES = (32, 64, 128, 256, 512)
Expand Down
37 changes: 26 additions & 11 deletions maskrcnn_benchmark/config/paths_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class DatasetCatalog(object):
DATA_DIR = "datasets"
DATA_DIR = "/kaggle/working/training_dataset"
DATASETS = {
# CUSTOM STUFF START
"cocopose_2014_debug": {
Expand All @@ -25,22 +25,27 @@ class DatasetCatalog(object):
"ann_file": "/home/bot/Downloads/Rebin/labelled/coco_rebin.json"
},
# CUSTOM STUFF END


"coco_2017_train": {
"img_dir": "coco/train2017",
"ann_file": "coco/annotations/instances_train2017.json"
"smartflow_train": {
"img_dir": "train",
"ann_file": "train.json"
},
"coco_2017_val": {
"img_dir": "coco/val2017",
"ann_file": "coco/annotations/instances_val2017.json"
"smartflow_val": {
"img_dir": "valid",
"ann_file": "valid.json"
},
"smartflow_test": {
"img_dir": "test",
"ann_file": "test.json"
},
"coco_2014_train": {
"img_dir": "coco/train2014",
"ann_file": "coco/annotations/instances_train2014.json"
"img_dir": "Images/train",
"ann_file": "Annotations/train.json"
},
"coco_2014_val": {
"img_dir": "coco/val2014",
"ann_file": "coco/annotations/instances_val2014.json"
"img_dir": "Images/test",
"ann_file": "Annotations/test.json"
},
"coco_2014_minival": {
"img_dir": "coco/val2014",
Expand Down Expand Up @@ -150,6 +155,16 @@ def get(name):
factory="PascalVOCDataset",
args=args,
)
elif "smartflow" in name:
data_dir = DatasetCatalog.DATA_DIR
attrs = DatasetCatalog.DATASETS[name]
args = dict(root=os.path.join(data_dir, attrs["img_dir"]), # img_dir is the content of step a
ann_file=os.path.join(data_dir, attrs["ann_file"]), # ann_file is the content of a step
)
return dict(
factory="COCODataset", # MyDataset corresponds
args=args,
)
raise RuntimeError("Dataset not available: {}".format(name))


Expand Down
5 changes: 5 additions & 0 deletions maskrcnn_benchmark/csrc/cuda/deform_conv_cuda.cu
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#ifndef AT_CHECK
#define AT_CHECK TORCH_CHECK
#endif


// modify from
// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/deform_conv_cuda.c

Expand Down
4 changes: 4 additions & 0 deletions maskrcnn_benchmark/csrc/cuda/deform_pool_cuda.cu
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifndef AT_CHECK
#define AT_CHECK TORCH_CHECK
#endif

// modify from
// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/modulated_dcn_cuda.c

Expand Down
6 changes: 3 additions & 3 deletions maskrcnn_benchmark/structures/segmentation_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def __getitem__(self, item):
else:
# advanced indexing on a single dimension
selected_polygons = []
if isinstance(item, torch.Tensor) and item.dtype == torch.uint8:
if isinstance(item, torch.Tensor) and item.dtype == torch.bool:
item = item.nonzero()
item = item.squeeze(1) if item.numel() > 0 else item
item = item.tolist()
Expand Down Expand Up @@ -517,7 +517,7 @@ def convert_to_binarymask(self):
)
else:
size = self.size
masks = torch.empty([0, size[1], size[0]], dtype=torch.uint8)
masks = torch.empty([0, size[1], size[0]], dtype=torch.bool)

return BinaryMaskList(masks, size=self.size)

Expand All @@ -532,7 +532,7 @@ def __getitem__(self, item):
else:
# advanced indexing on a single dimension
selected_polygons = []
if isinstance(item, torch.Tensor) and item.dtype == torch.uint8:
if isinstance(item, torch.Tensor) and item.dtype == torch.bool:
item = item.nonzero()
item = item.squeeze(1) if item.numel() > 0 else item
item = item.tolist()
Expand Down
2 changes: 1 addition & 1 deletion maskrcnn_benchmark/utils/c2_model_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def _rename_weights_for_resnet(weights, stage_names):

def _load_c2_pickled_weights(file_path):
with open(file_path, "rb") as f:
if torch._six.PY3:
if torch._six.PY37:
data = pickle.load(f, encoding="latin1")
else:
data = pickle.load(f)
Expand Down
2 changes: 1 addition & 1 deletion maskrcnn_benchmark/utils/imports.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch

if torch._six.PY3:
if torch._six.PY37:
import importlib
import importlib.util
import sys
Expand Down