Beispiel #1
0
 def __init__(self,
              dataset=CocoDataSet().__dict__,
              fields=['image', 'gt_box', 'gt_label', 'gt_score'],
              image_shape=[3, 608, 608],
              sample_transforms=[
                  DecodeImage(to_rgb=True, with_mixup=True),
                  MixupImage(alpha=1.5, beta=1.5),
                  NormalizeBox(),
                  RandomDistort(),
                  ExpandImage(max_ratio=4., prob=.5,
                              mean=[123.675, 116.28, 103.53]),
                  CropImage([[1, 1, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.1, 1.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.3, 1.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.5, 1.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.7, 1.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.9, 1.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.0, 1.0]]),
                  RandomInterpImage(target_size=608),
                  RandomFlipImage(is_normalized=True),
                  NormalizeImage(
                      mean=[0.485, 0.456, 0.406],
                      std=[0.229, 0.224, 0.225],
                      is_scale=True,
                      is_channel_first=False),
                  Permute(to_bgr=False),
              ],
              batch_transforms=[
                  RandomShape(sizes=[
                      320, 352, 384, 416, 448, 480, 512, 544, 576, 608
                  ])
              ],
              batch_size=8,
              shuffle=True,
              samples=-1,
              drop_last=True,
              with_background=False,
              num_workers=8,
              bufsize=128,
              use_process=True,
              num_max_boxes=50,
              mixup_epoch=250):
     sample_transforms.append(ArrangeYOLO())
     super(YoloTrainFeed, self).__init__(
         dataset,
         fields,
         image_shape,
         sample_transforms,
         batch_transforms,
         batch_size=batch_size,
         shuffle=shuffle,
         samples=samples,
         drop_last=drop_last,
         with_background=with_background,
         num_workers=num_workers,
         bufsize=bufsize,
         use_process=use_process)
     self.num_max_boxes = num_max_boxes
     self.mixup_epoch = mixup_epoch
     self.mode = 'TRAIN'
Beispiel #2
0
    def test_loader(self):
        coco_loader = VOCDataSet(
            dataset_dir=self.image_dir,
            image_dir=self.root_path,
            anno_path=self.anno_path,
            sample_num=240,
            use_default_label=False,
            label_list='/path/to/your/fl_fruit/label_list.txt')
        sample_trans = [
            DecodeImage(to_rgb=True),
            RandomFlipImage(),
            NormalizeImage(mean=[0.485, 0.456, 0.406],
                           std=[0.229, 0.224, 0.225],
                           is_scale=True,
                           is_channel_first=False),
            ResizeImage(target_size=800, max_size=1333, interp=1),
            Permute(to_bgr=False)
        ]
        batch_trans = [
            PadBatch(pad_to_stride=32, use_padded_im_info=True),
        ]

        inputs_def = {
            'fields':
            ['image', 'im_info', 'im_id', 'gt_bbox', 'gt_class', 'is_crowd'],
        }
        data_loader = Reader(coco_loader,
                             sample_transforms=sample_trans,
                             batch_transforms=batch_trans,
                             batch_size=1,
                             shuffle=True,
                             drop_empty=True,
                             inputs_def=inputs_def)()

        return data_loader
 def __init__(self,
              dataset=CocoDataSet().__dict__,
              fields=['image', 'gt_box', 'gt_label', 'gt_score'],
              image_shape=[3, 608, 608],
              sample_transforms=[
                  DecodeImage(to_rgb=True, with_mixup=True),
                  MixupImage(alpha=1.5, beta=1.5),
                  ColorDistort(),
                  RandomExpand(fill_value=[123.675, 116.28, 103.53]),
                  RandomCrop(),
                  RandomFlipImage(is_normalized=False),
                  Resize(target_dim=608, interp='random'),
                  NormalizePermute(
                      mean=[123.675, 116.28, 103.53],
                      std=[58.395, 57.120, 57.375]),
                  NormalizeBox(),
              ],
              batch_transforms=[
                  RandomShape(sizes=[
                      320, 352, 384, 416, 448, 480, 512, 544, 576, 608
                  ])
              ],
              batch_size=8,
              shuffle=True,
              samples=-1,
              drop_last=True,
              with_background=False,
              num_workers=8,
              bufsize=128,
              use_process=True,
              memsize=None,
              num_max_boxes=50,
              mixup_epoch=250,
              class_aware_sampling=False):
     sample_transforms.append(ArrangeYOLO())
     super(YoloTrainFeed, self).__init__(
         dataset,
         fields,
         image_shape,
         sample_transforms,
         batch_transforms,
         batch_size=batch_size,
         shuffle=shuffle,
         samples=samples,
         drop_last=drop_last,
         with_background=with_background,
         num_workers=num_workers,
         bufsize=bufsize,
         use_process=use_process,
         memsize=memsize,
         class_aware_sampling=class_aware_sampling)
     self.num_max_boxes = num_max_boxes
     self.mixup_epoch = mixup_epoch
     self.mode = 'TRAIN'
 def __init__(self,
              dataset=VocDataSet().__dict__,
              fields=['image', 'gt_box', 'gt_label'],
              image_shape=[3, 300, 300],
              sample_transforms=[
                  DecodeImage(to_rgb=True, with_mixup=False),
                  NormalizeBox(),
                  RandomDistort(brightness_lower=0.875,
                                brightness_upper=1.125,
                                is_order=True),
                  ExpandImage(max_ratio=4, prob=0.5),
                  CropImage(batch_sampler=[[1, 1, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.1, 0.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.3, 0.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.5, 0.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.7, 0.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.9, 0.0],
                             [1, 50, 0.3, 1.0, 0.5, 2.0, 0.0, 1.0]],
                            satisfy_all=False, avoid_no_bbox=False),
                  ResizeImage(target_size=300, use_cv2=False, interp=1),
                  RandomFlipImage(is_normalized=True),
                  Permute(),
                  NormalizeImage(mean=[127.5, 127.5, 127.5],
                                 std=[127.502231, 127.502231, 127.502231],
                                 is_scale=False)
              ],
              batch_transforms=[],
              batch_size=32,
              shuffle=True,
              samples=-1,
              drop_last=True,
              num_workers=8,
              bufsize=10,
              use_process=True,
              memsize=None):
     sample_transforms.append(ArrangeSSD())
     super(SSDTrainFeed, self).__init__(
         dataset,
         fields,
         image_shape,
         sample_transforms,
         batch_transforms,
         batch_size=batch_size,
         shuffle=shuffle,
         samples=samples,
         drop_last=drop_last,
         num_workers=num_workers,
         bufsize=bufsize,
         use_process=use_process,
         memsize=None)
     self.mode = 'TRAIN'
 def __init__(self,
              dataset=CocoDataSet().__dict__,
              fields=[
                  'image', 'im_info', 'im_id', 'gt_box', 'gt_label',
                  'is_crowd'
              ],
              image_shape=[None, 3, None, None],
              sample_transforms=[
                  DecodeImage(to_rgb=True),
                  RandomFlipImage(prob=0.5),
                  NormalizeImage(mean=[0.485, 0.456, 0.406],
                                 std=[0.229, 0.224, 0.225],
                                 is_scale=True,
                                 is_channel_first=False),
                  ResizeImage(target_size=800, max_size=1333, interp=1),
                  Permute(to_bgr=False)
              ],
              batch_transforms=[PadBatch()],
              batch_size=1,
              shuffle=True,
              samples=-1,
              drop_last=False,
              bufsize=10,
              num_workers=2,
              use_process=False,
              memsize=None,
              class_aware_sampling=False):
     # XXX this should be handled by the data loader, since `fields` is
     # given, just collect them
     sample_transforms.append(ArrangeRCNN())
     super(FasterRCNNTrainFeed, self).__init__(
         dataset,
         fields,
         image_shape,
         sample_transforms,
         batch_transforms,
         batch_size=batch_size,
         shuffle=shuffle,
         samples=samples,
         drop_last=drop_last,
         bufsize=bufsize,
         num_workers=num_workers,
         use_process=use_process,
         memsize=memsize,
         class_aware_sampling=class_aware_sampling)
     # XXX these modes should be unified
     self.mode = 'TRAIN'
 def __init__(self,
              dataset=CocoDataSet().__dict__,
              fields=[
                  'image', 'im_info', 'im_id', 'gt_box', 'gt_label',
                  'is_crowd', 'gt_mask'
              ],
              image_shape=[None, 3, None, None],
              sample_transforms=[
                  DecodeImage(to_rgb=True),
                  RandomFlipImage(prob=0.5, is_mask_flip=True),
                  NormalizeImage(mean=[0.485, 0.456, 0.406],
                                 std=[0.229, 0.224, 0.225],
                                 is_scale=True,
                                 is_channel_first=False),
                  ResizeImage(target_size=800,
                              max_size=1333,
                              interp=1,
                              use_cv2=True),
                  Permute(to_bgr=False, channel_first=True)
              ],
              batch_transforms=[PadBatch()],
              batch_size=1,
              shuffle=True,
              samples=-1,
              drop_last=False,
              num_workers=2,
              use_process=False,
              use_padded_im_info=False):
     sample_transforms.append(ArrangeRCNN(is_mask=True))
     super(MaskRCNNTrainFeed, self).__init__(
         dataset,
         fields,
         image_shape,
         sample_transforms,
         batch_transforms,
         batch_size=batch_size,
         shuffle=shuffle,
         samples=samples,
         drop_last=drop_last,
         num_workers=num_workers,
         use_process=use_process)
     self.mode = 'TRAIN'