Esempio n. 1
0
    def trainTransform(self, rgb, depth):
        s = np.random.uniform(1.0, 1.5)  # random scaling
        depth_np = depth / s
        angle = np.random.uniform(-5.0, 5.0)  # random rotation degrees
        do_flip = np.random.uniform(0.0, 1.0) < 0.5  # random horizontal flip

        # perform 1st step of data augmentation
        first_resize = tuple(
            map(
                int,
                list((250.0 / IMAGE_HEIGHT) *
                     np.array([IMAGE_HEIGHT, IMAGE_WIDTH]))))
        second_resize = tuple(
            map(int, list(s * np.array([IMAGE_HEIGHT, IMAGE_WIDTH]))))
        transform = T.Compose([
            T.Resize(
                first_resize
            ),  # this is for computational efficiency, since rotation can be slow
            T.Rotate(angle),
            T.Resize(second_resize),
            T.CenterCrop((228, 304)),
            T.HorizontalFlip(do_flip),
            T.Resize(self.output_size),
        ])
        rgb_np = transform(rgb)
        rgb_np = self.color_jitter(rgb_np)  # random color jittering
        rgb_np = np.asfarray(rgb_np, dtype='float') / 255
        depth_np = transform(depth_np)

        return rgb_np, depth_np
Esempio n. 2
0
    def validationTransform(self, rgb, depth):
        first_resize = tuple(
            map(
                int,
                list((250.0 / IMAGE_HEIGHT) *
                     np.array([IMAGE_HEIGHT, IMAGE_WIDTH]))))
        depth_np = depth
        transform = T.Compose([
            T.Resize(first_resize),
            T.CenterCrop((228, 304)),
            T.Resize(self.output_size),
        ])
        rgb_np = transform(rgb)
        rgb_np = np.asfarray(rgb_np, dtype='float') / 255
        depth_np = transform(depth_np)

        return rgb_np, depth_np