Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
bf2ef95f
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bf2ef95f
编写于
8月 18, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 18, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4694 fix: RandomAffine parameter check
Merge pull request !4694 from guozhijian/fix_randomaffine_err
上级
e9eee16e
5f294fb9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
1 deletion
+36
-1
mindspore/dataset/transforms/vision/c_transforms.py
mindspore/dataset/transforms/vision/c_transforms.py
+3
-1
mindspore/dataset/transforms/vision/validators.py
mindspore/dataset/transforms/vision/validators.py
+7
-0
tests/ut/python/dataset/test_random_affine.py
tests/ut/python/dataset/test_random_affine.py
+26
-0
未找到文件。
mindspore/dataset/transforms/vision/c_transforms.py
浏览文件 @
bf2ef95f
...
@@ -262,7 +262,8 @@ class RandomAffine(cde.RandomAffineOp):
...
@@ -262,7 +262,8 @@ class RandomAffine(cde.RandomAffineOp):
- Inter.BICUBIC, means resample method is bicubic interpolation.
- Inter.BICUBIC, means resample method is bicubic interpolation.
fill_value (tuple or int, optional): Optional fill_value to fill the area outside the transform
fill_value (tuple or int, optional): Optional fill_value to fill the area outside the transform
in the output image. Used only in Pillow versions > 5.0.0 (default=0, filling is performed).
in the output image. There must be three elements in tuple and the value of single element is [0, 255].
Used only in Pillow versions > 5.0.0 (default=0, filling is performed).
Raises:
Raises:
ValueError: If degrees is negative.
ValueError: If degrees is negative.
...
@@ -274,6 +275,7 @@ class RandomAffine(cde.RandomAffineOp):
...
@@ -274,6 +275,7 @@ class RandomAffine(cde.RandomAffineOp):
TypeError: If translate is specified but is not list or a tuple of length 2.
TypeError: If translate is specified but is not list or a tuple of length 2.
TypeError: If scale is not a list or tuple of length 2.''
TypeError: If scale is not a list or tuple of length 2.''
TypeError: If shear is not a list or tuple of length 2 or 4.
TypeError: If shear is not a list or tuple of length 2 or 4.
TypeError: If fill_value is not a single integer or a 3-tuple.
Examples:
Examples:
>>> c_transform.RandomAffine(degrees=15, translate=(0.1, 0.1), scale=(0.9, 1.1))
>>> c_transform.RandomAffine(degrees=15, translate=(0.1, 0.1), scale=(0.9, 1.1))
...
...
mindspore/dataset/transforms/vision/validators.py
浏览文件 @
bf2ef95f
...
@@ -509,6 +509,8 @@ def check_random_affine(method):
...
@@ -509,6 +509,8 @@ def check_random_affine(method):
if
len
(
scale
)
==
2
:
if
len
(
scale
)
==
2
:
for
i
,
s
in
enumerate
(
scale
):
for
i
,
s
in
enumerate
(
scale
):
check_positive
(
s
,
"scale[{}]"
.
format
(
i
))
check_positive
(
s
,
"scale[{}]"
.
format
(
i
))
if
scale
[
0
]
>
scale
[
1
]:
raise
ValueError
(
"Input scale[1] must be equal to or greater than scale[0]."
)
else
:
else
:
raise
TypeError
(
"scale should be a list or tuple of length 2."
)
raise
TypeError
(
"scale should be a list or tuple of length 2."
)
...
@@ -519,6 +521,11 @@ def check_random_affine(method):
...
@@ -519,6 +521,11 @@ def check_random_affine(method):
else
:
else
:
if
len
(
shear
)
not
in
(
2
,
4
):
if
len
(
shear
)
not
in
(
2
,
4
):
raise
TypeError
(
"shear must be of length 2 or 4."
)
raise
TypeError
(
"shear must be of length 2 or 4."
)
if
len
(
shear
)
==
2
and
shear
[
0
]
>
shear
[
1
]:
raise
ValueError
(
"Input shear[1] must be equal to or greater than shear[0]"
)
if
len
(
shear
)
==
4
and
(
shear
[
0
]
>
shear
[
1
]
or
shear
[
2
]
>
shear
[
3
]):
raise
ValueError
(
"Input shear[1] must be equal to or greater than shear[0] and "
"shear[3] must be equal to or greater than shear[2]."
)
type_check
(
resample
,
(
Inter
,),
"resample"
)
type_check
(
resample
,
(
Inter
,),
"resample"
)
...
...
tests/ut/python/dataset/test_random_affine.py
浏览文件 @
bf2ef95f
...
@@ -190,6 +190,12 @@ def test_random_affine_exception_scale_value():
...
@@ -190,6 +190,12 @@ def test_random_affine_exception_scale_value():
logger
.
info
(
"Got an exception in DE: {}"
.
format
(
str
(
e
)))
logger
.
info
(
"Got an exception in DE: {}"
.
format
(
str
(
e
)))
assert
str
(
e
)
==
"Input scale[0] must be greater than 0."
assert
str
(
e
)
==
"Input scale[0] must be greater than 0."
try
:
_
=
py_vision
.
RandomAffine
(
degrees
=
15
,
scale
=
(
2.0
,
1.1
))
except
ValueError
as
e
:
logger
.
info
(
"Got an exception in DE: {}"
.
format
(
str
(
e
)))
assert
str
(
e
)
==
"Input scale[1] must be equal to or greater than scale[0]."
def
test_random_affine_exception_shear_value
():
def
test_random_affine_exception_shear_value
():
"""
"""
...
@@ -202,6 +208,26 @@ def test_random_affine_exception_shear_value():
...
@@ -202,6 +208,26 @@ def test_random_affine_exception_shear_value():
logger
.
info
(
"Got an exception in DE: {}"
.
format
(
str
(
e
)))
logger
.
info
(
"Got an exception in DE: {}"
.
format
(
str
(
e
)))
assert
str
(
e
)
==
"Input shear must be greater than 0."
assert
str
(
e
)
==
"Input shear must be greater than 0."
try
:
_
=
py_vision
.
RandomAffine
(
degrees
=
15
,
shear
=
(
5
,
1
))
except
ValueError
as
e
:
logger
.
info
(
"Got an exception in DE: {}"
.
format
(
str
(
e
)))
assert
str
(
e
)
==
"Input shear[1] must be equal to or greater than shear[0]"
try
:
_
=
py_vision
.
RandomAffine
(
degrees
=
15
,
shear
=
(
5
,
1
,
2
,
8
))
except
ValueError
as
e
:
logger
.
info
(
"Got an exception in DE: {}"
.
format
(
str
(
e
)))
assert
str
(
e
)
==
"Input shear[1] must be equal to or greater than shear[0] and "
\
"shear[3] must be equal to or greater than shear[2]."
try
:
_
=
py_vision
.
RandomAffine
(
degrees
=
15
,
shear
=
(
5
,
9
,
2
,
1
))
except
ValueError
as
e
:
logger
.
info
(
"Got an exception in DE: {}"
.
format
(
str
(
e
)))
assert
str
(
e
)
==
"Input shear[1] must be equal to or greater than shear[0] and "
\
"shear[3] must be equal to or greater than shear[2]."
def
test_random_affine_exception_degrees_size
():
def
test_random_affine_exception_degrees_size
():
"""
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录