diff --git a/configs/rotated/e2e_ms_rcnn_R_101_FPN_1x.yaml b/configs/rotated/e2e_ms_rcnn_R_101_FPN_1x.yaml new file mode 100644 index 000000000..177e61761 --- /dev/null +++ b/configs/rotated/e2e_ms_rcnn_R_101_FPN_1x.yaml @@ -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" \ No newline at end of file diff --git a/maskrcnn_benchmark/config/defaults.py b/maskrcnn_benchmark/config/defaults.py index 8b6d1fcf5..9d369989f 100644 --- a/maskrcnn_benchmark/config/defaults.py +++ b/maskrcnn_benchmark/config/defaults.py @@ -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 @@ -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 @@ -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) diff --git a/maskrcnn_benchmark/config/paths_catalog.py b/maskrcnn_benchmark/config/paths_catalog.py index 1a2308834..8a07c4755 100644 --- a/maskrcnn_benchmark/config/paths_catalog.py +++ b/maskrcnn_benchmark/config/paths_catalog.py @@ -5,7 +5,7 @@ class DatasetCatalog(object): - DATA_DIR = "datasets" + DATA_DIR = "/kaggle/working/training_dataset" DATASETS = { # CUSTOM STUFF START "cocopose_2014_debug": { @@ -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", @@ -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)) diff --git a/maskrcnn_benchmark/csrc/cuda/deform_conv_cuda.cu b/maskrcnn_benchmark/csrc/cuda/deform_conv_cuda.cu index 74f7d3399..b6dbeaa72 100644 --- a/maskrcnn_benchmark/csrc/cuda/deform_conv_cuda.cu +++ b/maskrcnn_benchmark/csrc/cuda/deform_conv_cuda.cu @@ -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 diff --git a/maskrcnn_benchmark/csrc/cuda/deform_pool_cuda.cu b/maskrcnn_benchmark/csrc/cuda/deform_pool_cuda.cu index 71f305af9..9e56af225 100644 --- a/maskrcnn_benchmark/csrc/cuda/deform_pool_cuda.cu +++ b/maskrcnn_benchmark/csrc/cuda/deform_pool_cuda.cu @@ -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 diff --git a/maskrcnn_benchmark/structures/segmentation_mask.py b/maskrcnn_benchmark/structures/segmentation_mask.py index c95740509..abcd27026 100644 --- a/maskrcnn_benchmark/structures/segmentation_mask.py +++ b/maskrcnn_benchmark/structures/segmentation_mask.py @@ -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() @@ -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) @@ -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() diff --git a/maskrcnn_benchmark/utils/c2_model_loading.py b/maskrcnn_benchmark/utils/c2_model_loading.py index d034034aa..44ad05d67 100644 --- a/maskrcnn_benchmark/utils/c2_model_loading.py +++ b/maskrcnn_benchmark/utils/c2_model_loading.py @@ -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) diff --git a/maskrcnn_benchmark/utils/imports.py b/maskrcnn_benchmark/utils/imports.py index 53e27e2bc..4d2148feb 100644 --- a/maskrcnn_benchmark/utils/imports.py +++ b/maskrcnn_benchmark/utils/imports.py @@ -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