當前位置: 首頁>>代碼示例>>Python>>正文


Python functional.vflip方法代碼示例

本文整理匯總了Python中torchvision.transforms.functional.vflip方法的典型用法代碼示例。如果您正苦於以下問題:Python functional.vflip方法的具體用法?Python functional.vflip怎麽用?Python functional.vflip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在torchvision.transforms.functional的用法示例。


在下文中一共展示了functional.vflip方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: cv_transform

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def cv_transform(img):
    # img = resize(img, size=(100, 300))
    # img = to_tensor(img)
    # img = normalize(img, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
    # img = pad(img, padding=(10, 10, 20, 20), fill=(255, 255, 255), padding_mode='constant')
    # img = pad(img, padding=(100, 100, 100, 100), fill=5, padding_mode='symmetric')
    # img = crop(img, -40, -20, 1000, 1000)
    # img = center_crop(img, (310, 300))
    # img = resized_crop(img, -10.3, -20, 330, 220, (500, 500))
    # img = hflip(img)
    # img = vflip(img)
    # tl, tr, bl, br, center = five_crop(img, 100)
    # img = adjust_brightness(img, 2.1)
    # img = adjust_contrast(img, 1.5)
    # img = adjust_saturation(img, 2.3)
    # img = adjust_hue(img, 0.5)
    # img = adjust_gamma(img, gamma=3, gain=0.1)
    # img = rotate(img, 10, resample='BILINEAR', expand=True, center=None)
    # img = to_grayscale(img, 3)
    # img = affine(img, 10, (0, 0), 1, 0, resample='BICUBIC', fillcolor=(255,255,0))
    # img = gaussion_noise(img)
    # img = poisson_noise(img)
    img = salt_and_pepper(img)
    return to_tensor(img) 
開發者ID:YU-Zhiyang,項目名稱:opencv_transforms_torchvision,代碼行數:26,代碼來源:cvfunctional.py

示例2: pil_transform

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def pil_transform(img):
    # img = functional.resize(img, size=(100, 300))
    # img = functional.to_tensor(img)
    # img = functional.normalize(img, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
    # img = functional.pad(img, padding=(10, 10, 20, 20), fill=(255, 255, 255), padding_mode='constant')
    # img = functional.pad(img, padding=(100, 100, 100, 100), padding_mode='symmetric')
    # img = functional.crop(img, -40, -20, 1000, 1000)
    # img = functional.center_crop(img, (310, 300))
    # img = functional.resized_crop(img, -10.3, -20, 330, 220, (500, 500))
    # img = functional.hflip(img)
    # img = functional.vflip(img)
    # tl, tr, bl, br, center = functional.five_crop(img, 100)
    # img = functional.adjust_brightness(img, 2.1)
    # img = functional.adjust_contrast(img, 1.5)
    # img = functional.adjust_saturation(img, 2.3)
    # img = functional.adjust_hue(img, 0.5)
    # img = functional.adjust_gamma(img, gamma=3, gain=0.1)
    # img = functional.rotate(img, 10, resample=PIL.Image.BILINEAR, expand=True, center=None)
    # img = functional.to_grayscale(img, 3)
    # img = functional.affine(img, 10, (0, 0), 1, 0, resample=PIL.Image.BICUBIC, fillcolor=(255,255,0))

    return functional.to_tensor(img) 
開發者ID:YU-Zhiyang,項目名稱:opencv_transforms_torchvision,代碼行數:24,代碼來源:cvfunctional.py

示例3: __call__

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def __call__(self, sample):
        image, label = sample['image'], sample['label']
        if self.rand_flip_index is None or self.image_mode:
            self.rand_flip_index = random.randint(-1,2)
        # 0: horizontal flip, 1: vertical flip, -1: horizontal and vertical flip
        if self.rand_flip_index == 0:
            image = F.hflip(image)
            label = F.hflip(label)
        elif self.rand_flip_index == 1:
            image = F.vflip(image)
            label = F.vflip(label)
        elif self.rand_flip_index == 2:
            image = F.vflip(F.hflip(image))
            label = F.vflip(F.hflip(label))
        sample['image'], sample['label'] = image, label
        return sample 
開發者ID:Kinpzz,項目名稱:RCRNet-Pytorch,代碼行數:18,代碼來源:transforms.py

示例4: center_crop_with_flip

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def center_crop_with_flip(img, size, vertical_flip=False):
    crop_h, crop_w = size
    first_crop = F.center_crop(img, (crop_h, crop_w))
    if vertical_flip:
        img = F.vflip(img)
    else:
         img = F.hflip(img)
    second_crop = F.center_crop(img, (crop_h, crop_w))
    return (first_crop, second_crop) 
開發者ID:jiangtaoxie,項目名稱:fast-MPN-COV,代碼行數:11,代碼來源:imagepreprocess.py

示例5: __call__

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def __call__(self, image, target):
        if random.random() < self.prob:
            image = F.vflip(image)
            target = target.transpose(1)
        return image, target 
開發者ID:simaiden,項目名稱:Clothing-Detection,代碼行數:7,代碼來源:transforms.py

示例6: __call__

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def __call__(self, data):
        """
        Args:
            img (PIL Image): Image to be flipped.
        Returns:
            PIL Image: Randomly flipped image.
        """
        hr, lr = data
        if random.random() < 0.5:
            return F.vflip(hr), F.vflip(lr)
        return hr, lr 
開發者ID:jacobgil,項目名稱:pytorch-zssr,代碼行數:13,代碼來源:source_target_transforms.py

示例7: __call__

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def __call__(self, img, anns):
        if random.random() < self.p:
            img = VF.vflip(img)
            anns = HF.vflip(anns, img.size)
            return img, anns
        return img, anns 
開發者ID:qixuxiang,項目名稱:Pytorch_Lightweight_Network,代碼行數:8,代碼來源:__init__.py

示例8: vflip

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def vflip(img):
    """Vertically flip the given PIL Image.

    Args:
        img (CV Image): Image to be flipped.

    Returns:
        PIL Image:  Vertically flipped image.
    """
    if not _is_numpy_image(img):
        raise TypeError('img should be PIL Image. Got {}'.format(type(img)))

    return cv2.flip(img, 0) 
開發者ID:YU-Zhiyang,項目名稱:opencv_transforms_torchvision,代碼行數:15,代碼來源:cvfunctional.py

示例9: ten_crop

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def ten_crop(img, size, vertical_flip=False):
    """Crop the given CV Image into four corners and the central crop plus the
       flipped version of these (horizontal flipping is used by default).

    .. Note::
        This transform returns a tuple of images and there may be a
        mismatch in the number of inputs and targets your ``Dataset`` returns.

       Args:
           size (sequence or int): Desired output size of the crop. If size is an
               int instead of sequence like (h, w), a square crop (size, size) is
               made.
           vertical_flip (bool): Use vertical flipping instead of horizontal

        Returns:
            tuple: tuple (tl, tr, bl, br, center, tl_flip, tr_flip, bl_flip,
                br_flip, center_flip) corresponding top left, top right,
                bottom left, bottom right and center crop and same for the
                flipped image.
    """
    if isinstance(size, numbers.Number):
        size = (int(size), int(size))
    else:
        assert len(size) == 2, "Please provide only two dimensions (h, w) for size."

    first_five = five_crop(img, size)

    if vertical_flip:
        img = vflip(img)
    else:
        img = hflip(img)

    second_five = five_crop(img, size)
    return first_five + second_five 
開發者ID:YU-Zhiyang,項目名稱:opencv_transforms_torchvision,代碼行數:36,代碼來源:cvfunctional.py

示例10: vflip

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def vflip(img, bbox):
    bbox = bbox.copy()
    bbox[:, 1] = 1 - bbox[:, 1]
    bbox[:, 3] = 1 - bbox[:, 3]
    return TF.vflip(img), bbox 
開發者ID:vacancy,項目名稱:Jacinle,代碼行數:7,代碼來源:functional.py

示例11: vflip

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def vflip(img, coor):
    coor = coor.copy()
    coor[:, 1] = 1 - coor[:, 1]
    return TF.vflip(img), coor 
開發者ID:vacancy,項目名稱:Jacinle,代碼行數:6,代碼來源:functional.py

示例12: __call__

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def __call__(self, *imgs):
        if random.random() < self.p:
            return map(F.vflip, imgs)
        else:
            return imgs 
開發者ID:microsoft,項目名稱:nni,代碼行數:7,代碼來源:augmentation.py

示例13: _verticalFlip

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def _verticalFlip(img, points=None, labels=None):
    img = F.vflip(img)
    if points is not None and len(labels):
        points[:,1] = img.size[1] - points[:,1]
    return img, points, labels 
開發者ID:microsoft,項目名稱:aerial_wildlife_detection,代碼行數:7,代碼來源:points.py

示例14: _verticalFlip

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def _verticalFlip(img, bboxes=None, labels=None):
    img = F.vflip(img)
    if bboxes is not None and len(labels):
        bboxes[:,1] = img.size[1] - (bboxes[:,1] + bboxes[:,3])
    return img, bboxes, labels 
開發者ID:microsoft,項目名稱:aerial_wildlife_detection,代碼行數:7,代碼來源:boundingBoxes.py

示例15: __call__

# 需要導入模塊: from torchvision.transforms import functional [as 別名]
# 或者: from torchvision.transforms.functional import vflip [as 別名]
def __call__(self, image):
        return F.vflip(image) 
開發者ID:tristandeleu,項目名稱:pytorch-meta,代碼行數:4,代碼來源:augmentations.py


注:本文中的torchvision.transforms.functional.vflip方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。