From 236a3bc5d80f0063ee206c30806104ed9b7f47df Mon Sep 17 00:00:00 2001 From: Liyulingyue <83450930+Liyulingyue@users.noreply.github.com> Date: Fri, 25 Mar 2022 11:21:27 +0800 Subject: [PATCH] fix paddle.vision.transforms.Resize en docs (#40719) * Update transforms.py * Update transforms.py * Update transforms.py * Update functional.py --- python/paddle/vision/transforms/functional.py | 2 ++ python/paddle/vision/transforms/transforms.py | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/python/paddle/vision/transforms/functional.py b/python/paddle/vision/transforms/functional.py index 3087d5c3ed..8caab964bf 100644 --- a/python/paddle/vision/transforms/functional.py +++ b/python/paddle/vision/transforms/functional.py @@ -124,9 +124,11 @@ def resize(img, size, interpolation='bilinear'): converted_img = F.resize(fake_img, 224) print(converted_img.size) + # (262, 224) converted_img = F.resize(fake_img, (200, 150)) print(converted_img.size) + # (150, 200) """ if not (_is_pil_image(img) or _is_numpy_image(img) or _is_tensor_image(img)): diff --git a/python/paddle/vision/transforms/transforms.py b/python/paddle/vision/transforms/transforms.py index 9fd200bf03..a22f8a2ab4 100644 --- a/python/paddle/vision/transforms/transforms.py +++ b/python/paddle/vision/transforms/transforms.py @@ -395,12 +395,17 @@ class Resize(BaseTransform): from PIL import Image from paddle.vision.transforms import Resize - transform = Resize(size=224) - - fake_img = Image.fromarray((np.random.rand(100, 120, 3) * 255.).astype(np.uint8)) + fake_img = Image.fromarray((np.random.rand(256, 300, 3) * 255.).astype(np.uint8)) - fake_img = transform(fake_img) - print(fake_img.size) + transform = Resize(size=224) + converted_img = transform(fake_img) + print(converted_img.size) + # (262, 224) + + transform = Resize(size=(200,150)) + converted_img = transform(fake_img) + print(converted_img.size) + # (150, 200) """ def __init__(self, size, interpolation='bilinear', keys=None): -- GitLab