Ejemplo n.º 1
0
    def __call__(self, in_data):
        img, label = in_data
        _, H, W = img.shape
        img = preprocess(img, self.min_size, self.max_size)
        _, o_H, o_W = img.shape
        scale = o_H / H

        # horizontally flip
        img, params = util.random_flip(img, x_random=True, return_param=True)

        return img, label, scale
Ejemplo n.º 2
0
 def __call__(self, in_data):
     img, bbox, label = in_data
     _, H, W = img.shape
     img = preprocess(img, self.min_size, self.max_size)#对图像缩放处理
     _, o_H, o_W = img.shape
     scale = o_H / H
     bbox = util.resize_bbox(bbox, (H, W), (o_H, o_W))#对bbox处理
     #图像随机水平翻转
     img, params = util.random_flip(img, x_random=True, return_param=True)
     #对应的bbox
     bbox = util.flip_bbox(bbox, (o_H, o_W), x_flip=params['x_flip'])
     return img, bbox, label, scale
    def __call__(self, in_data):
        img, bbox, label = in_data
        _, H, W = img.shape
        img = preprocess(img, self.min_size, self.max_size)
        _, o_H, o_W = img.shape
        scale = o_H / H
        bbox = util.resize_bbox(bbox, (H, W), (o_H, o_W))

        # horizontally flip
        img, params = util.random_flip(img, x_random=True, return_param=True)
        bbox = util.flip_bbox(bbox, (o_H, o_W), x_flip=params['x_flip'])

        return img, bbox, label, scale
    def __call__(self, in_data):
        img, bbox, label = in_data
        _, H, W = img.shape
        img = preprocess(img, self.min_size, self.max_size)
        _, o_H, o_W = img.shape # 缩放后的图像大小
        scale = o_H / H # 缩放比例
        bbox = util.resize_bbox(bbox, (H, W), (o_H, o_W)) # 按比例缩放包围盒

        # horizontally flip, 将图像随机水平翻转
        img, params = util.random_flip(img, x_random=True, return_param=True)
        # 将包围盒进行与图像相同的水平翻转
        bbox = util.flip_bbox(bbox, (o_H, o_W), x_flip=params['x_flip'])

        return img, bbox, label, scale
Ejemplo n.º 5
0
    def __call__(self, data):
        img, bbox, label = data
        _, H, W = img.shape
        img = preprocess(img)
        _, o_H, o_W = img.shape
        bbox = resize_bbox(bbox, (H, W), (o_H, o_W))

        #randomly horizontally flip
        img, x_flip = random_flip(img)
        if x_flip:
            bbox = flip_bbox(bbox, (o_H, o_W))

        scale = o_H / H
        return img, bbox, label, scale
Ejemplo n.º 6
0
    def __call__(self, in_data):
        img, bbox, label = in_data
        _, H, W = img.shape

        img = preprocess(img, self.min_size, self.max_size)  #预处理图片
        _, o_H, o_W = img.shape
        scale = o_H / H
        #预处理图片中的bbox,对相应的bounding boxes 也进行同等尺度的缩放。
        bbox = util.resize_bbox(bbox, (H, W), (o_H, o_W))

        # horizontally flip水平翻转
        img, params = util.random_flip(img, x_random=True, return_param=True)
        bbox = util.flip_bbox(bbox, (o_H, o_W), x_flip=params['x_flip'])

        return img, bbox, label, scale
Ejemplo n.º 7
0
    def __call__(self, in_data):
        img, bbox, label = in_data
        _, H, W = img.shape
        img = preprocess(img, self.min_size,
                         self.max_size)  # 将图片进行最小最大化放缩然后进行归一化
        _, o_H, o_W = img.shape
        scale = o_H / H  # 放缩前后相除,得出放缩比因子
        bbox = util.resize_bbox(bbox, (H, W), (o_H, o_W))  # 重新调整bboxes框的大小

        # 水平翻转
        # 进行图片的随机反转,图片旋转不变性,增强网络的鲁棒性!
        img, params = util.random_flip(img, x_random=True, return_param=True)
        # 同样的对bboxes进行随机反转
        bbox = util.flip_bbox(bbox, (o_H, o_W), x_flip=params['x_flip'])
        return img, bbox, label, scale
Ejemplo n.º 8
0
    def __call__(self, in_data):
        img, bbox, label = in_data
        _, H, W = img.shape  #(3,h,w)
        img = preprocess(img, self.min_size,
                         self.max_size)  #(3,h*scale,w*scale)
        _, o_H, o_W = img.shape
        scale = o_H / H  #(得出缩放比因子) #scale
        bbox = util.resize_bbox(bbox, (H, W), (o_H, o_W))  #

        # horizontally flip
        img, params = util.random_flip(
            img, x_random=True,
            return_param=True)  #jiang pictures shuiping fanzhuang
        bbox = util.flip_bbox(bbox, (o_H, o_W), x_flip=params['x_flip'])

        return img, bbox, label, scale
Ejemplo n.º 9
0
    def __call__(self, in_data):
        img, bbox, label = in_data
        _, H, W = img.shape
        # 图像等比例缩放
        img = preprocess(img, self.min_size, self.max_size)
        _, o_H, o_W = img.shape
        # 得出缩放比因子
        scale = o_H / H
        # bbox按照与原图等比例缩放
        bbox = util.resize_bbox(bbox, (H, W), (o_H, o_W))

        # 将图片进行随机水平翻转,没有进行垂直翻转
        img, params = util.random_flip(
            img, x_random=True, return_param=True)
        # 同样地将bbox进行与对应图片同样的水平翻转
        bbox = util.flip_bbox(
            bbox, (o_H, o_W), x_flip=params['x_flip'])

        return img, bbox, label, scale
Ejemplo n.º 10
0
    def __call__(self, in_data):
        img, bbox, label = in_data
        _, H, W = img.shape
        # print("before preprocessing:", img.shape, img[:, 100: 200, 100: 200])
        img = preprocess(img, self.min_size, self.max_size)
        # print("after preprocessing:", img.shape, img[:, 100: 200, 100: 200])
        _, o_H, o_W = img.shape
        # TODO change the defenition of scale.
        # warning: might have issue.
        scale = o_H / H
        # print("bbox pre: ", bbox)
        bbox = util.resize_bbox(bbox, (H, W), (o_H, o_W))
        # print("bbox after: ", bbox)
        # horizontally flip
        img, params = util.random_flip(img, x_random=True, return_param=True)
        bbox = util.flip_bbox(bbox, (o_H, o_W), x_flip=params['x_flip'])
        # print("bbox after flip: ", bbox, bbox.shape)

        return img, bbox, label, scale
Ejemplo n.º 11
0
    def __call__(self, in_data):
        img, bbox, label, depth, y_rot = in_data
        _, H, W = img.shape
        img = preprocess(img, self.min_size, self.max_size)
        _, o_H, o_W = img.shape
        scale = o_H / H
        bbox = util.resize_bbox(bbox, (H, W), (o_H, o_W))

        # horizontally flip
        img, params = util.random_flip(img, x_random=True, return_param=True)
        bbox = util.flip_bbox(bbox, (o_H, o_W), x_flip=params['x_flip'])
        if params['x_flip']:
            for i in range(len(y_rot)):
                theta = float(y_rot[i])
                if theta > 0:
                    y_rot[i] = pi - theta
                if theta < 0:
                    y_rot[i] = -pi - theta
                    y_rot[i]
                if theta == 0:
                    y_rot[i] = 3.14

        return img, bbox, label, depth, y_rot, scale