-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
>>> flpped_img = F.hflip(fake_img) | ||
>>> print(flpped_img.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flpped_img -> flipped_img
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
>>> flpped_img = F.vflip(fake_img) | ||
>>> print(flpped_img.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flpped_img -> flipped_img
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
>>> # 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用 seed,不需要 skip ~
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
输出~
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
输出不对~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
>>> # 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]]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用 seed ~ 另外,最好把方括号对齐一下 ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多了一个空格 ~
>>> 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]]]) |
There was a problem hiding this comment.
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]]])
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]]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有个地方写了很多空行,清理一下吧 ~ 其他的我这边没啥问题了 ~
|
||
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) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里好多空行 ~ 是不是要整体修改一下 Codestyle ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTMeow 🐾
PR types
Others
PR changes
Others
Description
修改如下文件的示例代码,使其通过
xdoctest
检查:Related links
@sunzhongkai588 @SigureMo @megemini