def __call__(self, img, target): """ Args: img (PIL Image): Image to be scaled. Returns: PIL Image: Rescaled image. """ return F.resize(img, self.size, self.interpolation), F.resize(target, self.size, self.interpolation)
def __call__(self, image, target): min_h, min_w = self.min_size max_h, max_w = self.max_size h = random.randint(min_h, max_h) w = random.randint(min_w, max_w) image = F.resize(image, (h, w), interpolation=Image.LINEAR) target = target if type(target) == str else F.resize( target, (h, w), interpolation=Image.NEAREST) return image, target
def __call__(self, img): """ Args: img (numpy ndarray): Image to be scaled. Returns: numpy ndarray: Rescaled image. """ return F.resize(img, self.size, self.interpolation)
def __call__(self, sample): """ Args: img (PIL Image): Image to be scaled. Returns: PIL Image: Rescaled image. """ return F.resize(sample, self.size, self.interpolation)
def __call__(self, img, boxes=None, labels=None): """ :param img: :param boxes: :param labels: :return: """ h, w = img.height, img.width img, oh, ow = F.resize(img, self.size, self.interpolation) if boxes is not None: boxes = boxes.copy() scale_h, scale_w = oh / h, ow / w boxes[:, ::2] *= scale_h boxes[:, 1::2] *= scale_w return img, boxes, labels
def __call__(self, image, target): image = F.resize(image, self.size_image, interpolation=Image.LINEAR) target = target if type(target) == str else F.resize( target, self.size_label, interpolation=Image.NEAREST) return image, target
def __call__(self, img): return F.resize(img, self.size)