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

Data loader adjustments #44

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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: 2 additions & 1 deletion mmdet/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@

#xez
from .coco_seg import Coco_Seg_Dataset
from .coco_seg_fast import Coco_SegFast_Dataset


__all__ = [
'CustomDataset', 'XMLDataset', 'CocoDataset', 'VOCDataset',
'CityscapesDataset', 'GroupSampler', 'DistributedGroupSampler',
'build_dataloader', 'to_tensor', 'random_scale', 'show_ann',
'ConcatDataset', 'RepeatDataset', 'ExtraAugmentation', 'WIDERFaceDataset',
'DATASETS', 'build_dataset', 'Coco_Seg_Dataset'
'DATASETS', 'build_dataset', 'Coco_Seg_Dataset', 'Coco_SegFast_Dataset'
]
13 changes: 8 additions & 5 deletions mmdet/datasets/coco_seg.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ def prepare_train_img(self, idx):

self.center_sample = True
self.use_mask_center = True
self.all_contours = False
self.radius = 1.5
self.strides = [8, 16, 32, 64, 128]
self.regress_ranges=((-1, 64), (64, 128), (128, 256), (256, 512),(512, INF))
self.regress_ranges=[(-1, 64), (64, 128), (128, 256), (256, 512),(512, INF)]
featmap_sizes = self.get_featmap_size(pad_shape)
self.featmap_sizes = featmap_sizes
num_levels = len(self.strides)
Expand Down Expand Up @@ -382,18 +383,17 @@ def polar_target_single(self, gt_bboxes, gt_masks, gt_labels, points, regress_ra
# condition1: inside a gt bbox
#加入center sample
if self.center_sample:
strides = [8, 16, 32, 64, 128]
if self.use_mask_center:
inside_gt_bbox_mask = self.get_mask_sample_region(gt_bboxes,
mask_centers,
strides,
self.strides,
self.num_points_per_level,
xs,
ys,
radius=self.radius)
else:
inside_gt_bbox_mask = self.get_sample_region(gt_bboxes,
strides,
self.strides,
self.num_points_per_level,
xs,
ys,
Expand Down Expand Up @@ -516,7 +516,10 @@ def get_centerpoint(self, lis):

def get_single_centerpoint(self, mask):
contour, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
contour.sort(key=lambda x: cv2.contourArea(x), reverse=True) #only save the biggest one
if self.all_contours:
contour = [np.concatenate(contour, axis=0)] # combine all contours yielding largest mask
else:
contour.sort(key=lambda x: cv2.contourArea(x), reverse=True) # only save the biggest contour
'''debug IndexError: list index out of range'''
count = contour[0][:, 0, :]
try:
Expand Down
14 changes: 8 additions & 6 deletions mmdet/datasets/coco_seg_fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,10 @@ def prepare_train_img(self, idx):

self.center_sample = True
self.use_mask_center = True
self.all_contours = False
self.radius = 1.5
self.strides = [8, 16, 32, 64, 128]
self.regress_ranges=((-1, 64), (64, 128), (128, 256), (256, 512),(512, INF))
self.regress_ranges=[(-1, 64), (64, 128), (128, 256), (256, 512),(512, INF)]
featmap_sizes = self.get_featmap_size(pad_shape)
self.featmap_sizes = featmap_sizes
num_levels = len(self.strides)
Expand Down Expand Up @@ -370,18 +371,17 @@ def fcos_target_single(self, gt_bboxes, gt_masks, gt_labels, points, regress_ran
# condition1: inside a gt bbox
#加入center sample
if self.center_sample:
strides = [8, 16, 32, 64, 128]
if self.use_mask_center:
inside_gt_bbox_mask = self.get_mask_sample_region(gt_bboxes,
mask_centers,
strides,
self.strides,
self.num_points_per_level,
xs,
ys,
radius=self.radius)
else:
inside_gt_bbox_mask = self.get_sample_region(gt_bboxes,
strides,
self.strides,
self.num_points_per_level,
xs,
ys,
Expand Down Expand Up @@ -530,8 +530,10 @@ def get_centerpoint(self, lis):

def get_single_centerpoint(self, mask):
contour, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
contour.sort(key=lambda x: cv2.contourArea(x), reverse=True) # only save the biggest one

if self.all_contours:
contour = [np.concatenate(contour, axis=0)] # combine all contours yielding largest mask
else:
contour.sort(key=lambda x: cv2.contourArea(x), reverse=True) # only save the biggest contour
'''debug IndexError: list index out of range'''
count = contour[0][:, 0, :]
try:
Expand Down