Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doctest]fix No.163,164,166, test=docs_preview #56527

Merged
merged 6 commits into from
Sep 1, 2023

Conversation

liyongchao911
Copy link
Contributor

PR types

Others

PR changes

Others

Description

修改如下文件的示例代码,使其通过 xdoctest 检查:

  • python/paddle/vision/models/squeezenet.py
  • python/paddle/vision/models/vgg.py
  • python/paddle/vision/transforms/functional.py

Related links

@sunzhongkai588 @SigureMo @megemini

@paddle-bot
Copy link

paddle-bot bot commented Aug 22, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Aug 22, 2023
Comment on lines 343 to 344
>>> flpped_img = F.hflip(fake_img)
>>> print(flpped_img.size)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flpped_img -> flipped_img

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Comment on lines 385 to 386
>>> flpped_img = F.vflip(fake_img)
>>> print(flpped_img.size)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flpped_img -> flipped_img

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Comment on lines 426 to 436
>>> # doctest: +SKIP('random sample')

fake_img = (np.random.rand(256, 300, 3) * 255.).astype('uint8')
>>> fake_img = (np.random.rand(256, 300, 3) * 255.).astype('uint8')
>>> fake_img = Image.fromarray(fake_img)

>>> print(fake_img.load()[1,1])
(95, 127, 202)
>>> converted_img = F.adjust_brightness(fake_img, 0.5)
>>> print(converted_img.load()[1,1])
(47, 63, 101)
>>> # doctest: -SKIP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用 seed,不需要 skip ~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

gray_img = F.to_grayscale(fake_img)
print(gray_img.size)
>>> gray_img = F.to_grayscale(fake_img)
>>> print(gray_img.size)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

输出~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

print(normalized_img.max(), normalized_img.min())
>>> normalized_img = F.normalize(fake_img, mean, std, data_format='HWC')
>>> print(normalized_img.max(), normalized_img.min())
(300, 256)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

输出不对~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 1064 to 1089
>>> # doctest: +SKIP('random sample')
>>> fake_img = paddle.randn((3, 2, 4)).astype(paddle.float32)
>>> print(fake_img)

Tensor(shape=[3, 2, 4], dtype=float32, place=Place(gpu:0), stop_gradient=True,
[[[ 0.02169025, -0.97859967, -1.39175487, -1.07478464],
[ 0.20654772, 1.74624777, 0.32268861, -0.13857445]],
[[-0.14993843, 1.10793507, -0.40056887, -1.94395220],
[ 0.41686651, 0.44551995, -0.09356714, -0.60898107]],
[[-0.24998808, -1.47699273, -0.88838995, 0.42629015],
[ 0.56948012, -0.96200180, 0.53355658, 3.20450878]]])

>>> values = paddle.zeros((1,1,1), dtype=paddle.float32)
>>> result = paddle.vision.transforms.erase(fake_img, 0, 1, 1, 2, values)

>>> print(result)

Tensor(shape=[3, 2, 4], dtype=float32, place=Place(gpu:0), stop_gradient=True,
[[[ 0.02169025, 0. , 0. , -1.07478464],
[ 0.20654772, 1.74624777, 0.32268861, -0.13857445]],

[[-0.14993843, 0. , 0. , -1.94395220],
[ 0.41686651, 0.44551995, -0.09356714, -0.60898107]],

[[-0.24998808, 0. , 0. , 0.42629015],
[ 0.56948012, -0.96200180, 0.53355658, 3.20450878]]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用 seed ~ 另外,最好把方括号对齐一下 ~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Aug 22, 2023
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自行看下 log 吧,还有很多对不上的

print(normalized_img.max(), normalized_img.min())
>>> normalized_img = F.normalize(fake_img, mean, std, data_format='HWC')
>>> print(normalized_img.max(), normalized_img.min())
(0.99215686 -1.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

点错了,不应该 approve 的


>>> fake_img = (np.random.rand(256, 300, 3) * 255.).astype('uint8')
>>> fake_img = Image.fromarray(fake_img)
>>> print(fake_img.size)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多了一个空格 ~

Comment on lines 1065 to 1074
>>> print(fake_img)
Tensor(shape=[3, 2, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[ 0.06132207, 1.11349595, 0.41906244, -0.24858207],
[-1.85169315, -1.50370061, 1.73954511, 0.13331604]],

[[ 1.66359663, -0.55764782, -0.59911072, -0.57773495],
[-1.03176904, -0.33741450, -0.29695082, -1.50258386]],

[[ 0.67233968, -1.07747352, 0.80170447, -0.06695852],
[-1.85003340, -0.23008066, 0.65083790, 0.75387722]]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

输出不要空行 ~ 另外,可以对齐一下方括号 ~

Tensor(shape=[3, 2, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[ 0.06132207,  1.11349595,  0.41906244, -0.24858207],
  [-1.85169315, -1.50370061,  1.73954511,  0.13331604]],
 [[ 1.66359663, -0.55764782, -0.59911072, -0.57773495],
  [-1.03176904, -0.33741450, -0.29695082, -1.50258386]],
 [[ 0.67233968, -1.07747352,  0.80170447, -0.06695852],
  [-1.85003340, -0.23008066,  0.65083790,  0.75387722]]])

Comment on lines 1079 to 1087
Tensor(shape=[3, 2, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[[ 0.06132207, 0. , 0. , -0.24858207],
[-1.85169315, -1.50370061, 1.73954511, 0.13331604]],

[[ 1.66359663, 0. , 0. , -0.57773495],
[-1.03176904, -0.33741450, -0.29695082, -1.50258386]],

[[ 0.67233968, 0. , 0. , -0.06695852],
[-1.85003340, -0.23008066, 0.65083790, 0.75387722]]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Copy link
Contributor

@megemini megemini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有个地方写了很多空行,清理一下吧 ~ 其他的我这边没啥问题了 ~

Comment on lines 439 to 443

import numpy as np
from PIL import Image
from paddle.vision.transforms import functional as F

fake_img = (np.random.rand(256, 300, 3) * 255.).astype('uint8')

fake_img = Image.fromarray(fake_img)
print(fake_img.size) # (300, 256)
print(fake_img.load()[1,1]) # (95, 127, 202)
converted_img = F.adjust_brightness(fake_img, 0.5)
print(converted_img.size) # (300, 256)
print(converted_img.load()[1,1]) # (47, 63, 101)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里好多空行 ~ 是不是要整体修改一下 Codestyle ~

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@luotao1 luotao1 merged commit a277fe4 into PaddlePaddle:develop Sep 1, 2023
BeingGod pushed a commit to BeingGod/Paddle that referenced this pull request Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants