Пример #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'
Пример #2
0
 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'