Ejemplo n.º 1
0
 def __call__(self, img_list, label_list):
     img_list = [img.resize(self.size, Image.BILINEAR) for img in img_list]
     label_list = [
         fl.resize_flow(label, self.size[0], self.size[1], self.method)
         for label in label_list
     ]
     return img_list, label_list
Ejemplo n.º 2
0
    def __call__(self, img_list, label_list):
        temp_scale = self.scale[0] + (self.scale[1] -
                                      self.scale[0]) * random.random()
        new_crop_h = int(self.crop_h * temp_scale)
        new_crop_w = int(self.crop_w * temp_scale)

        w, h = img_list[0].size
        h_off = random.randint(0, h - new_crop_h)
        w_off = random.randint(0, w - new_crop_w)

        img_list = [
            img.crop((w_off, h_off, w_off + new_crop_w, h_off + new_crop_h))
            for img in img_list
        ]
        label_list = [
            label[h_off:h_off + new_crop_h, w_off:w_off + new_crop_w, :]
            for label in label_list
        ]

        img_list = [
            img.resize((self.crop_w, self.crop_h), Image.BILINEAR)
            for img in img_list
        ]
        label_list = [
            fl.resize_flow(label, self.crop_w, self.crop_h, self.method)
            for label in label_list
        ]

        return img_list, label_list
Ejemplo n.º 3
0
 def __call__(self, img_list, label_list):
     temp_scale = self.scale[0] + (self.scale[1] -
                                   self.scale[0]) * random.random()
     temp_aspect_ratio = 1.0
     if self.aspect_ratio is not None:
         temp_aspect_ratio = self.aspect_ratio[0] + (
             self.aspect_ratio[1] - self.aspect_ratio[0]) * random.random()
         temp_aspect_ratio = math.sqrt(temp_aspect_ratio)
     scale_factor_w = temp_scale * temp_aspect_ratio
     scale_factor_h = temp_scale / temp_aspect_ratio
     w, h = img_list[0].size
     new_w = int(w * scale_factor_w)
     new_h = int(h * scale_factor_h)
     img_list = [
         img.resize((new_w, new_h), Image.BILINEAR) for img in img_list
     ]
     label_list = [
         fl.resize_flow(label, new_w, new_h, self.method)
         for label in label_list
     ]
     return img_list, label_list