Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
71d33b08
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看板
提交
71d33b08
编写于
6月 28, 2020
作者:
Z
zhaozhenlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
limit ssim input img type to fp32 and fp16
上级
80dd3321
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
10 deletion
+7
-10
mindspore/nn/layer/image.py
mindspore/nn/layer/image.py
+5
-0
tests/ut/python/nn/test_ssim.py
tests/ut/python/nn/test_ssim.py
+2
-10
未找到文件。
mindspore/nn/layer/image.py
浏览文件 @
71d33b08
...
@@ -110,6 +110,10 @@ def _check_input_filter_size(input_shape, param_name, filter_size, func_name):
...
@@ -110,6 +110,10 @@ def _check_input_filter_size(input_shape, param_name, filter_size, func_name):
validator
.
check
(
param_name
+
" shape[2]"
,
input_shape
[
2
],
"filter_size"
,
filter_size
,
Rel
.
GE
,
func_name
)
validator
.
check
(
param_name
+
" shape[2]"
,
input_shape
[
2
],
"filter_size"
,
filter_size
,
Rel
.
GE
,
func_name
)
validator
.
check
(
param_name
+
" shape[3]"
,
input_shape
[
3
],
"filter_size"
,
filter_size
,
Rel
.
GE
,
func_name
)
validator
.
check
(
param_name
+
" shape[3]"
,
input_shape
[
3
],
"filter_size"
,
filter_size
,
Rel
.
GE
,
func_name
)
@
constexpr
def
_check_input_dtype
(
input_dtype
,
param_name
,
allow_dtypes
,
cls_name
):
validator
.
check_type_name
(
param_name
,
input_dtype
,
allow_dtypes
,
cls_name
)
class
SSIM
(
Cell
):
class
SSIM
(
Cell
):
r
"""
r
"""
Returns SSIM index between img1 and img2.
Returns SSIM index between img1 and img2.
...
@@ -160,6 +164,7 @@ class SSIM(Cell):
...
@@ -160,6 +164,7 @@ class SSIM(Cell):
self
.
mean
=
P
.
DepthwiseConv2dNative
(
channel_multiplier
=
1
,
kernel_size
=
filter_size
)
self
.
mean
=
P
.
DepthwiseConv2dNative
(
channel_multiplier
=
1
,
kernel_size
=
filter_size
)
def
construct
(
self
,
img1
,
img2
):
def
construct
(
self
,
img1
,
img2
):
_check_input_dtype
(
F
.
dtype
(
img1
),
"img1"
,
[
mstype
.
float32
,
mstype
.
float16
],
self
.
cls_name
)
_check_input_filter_size
(
F
.
shape
(
img1
),
"img1"
,
self
.
filter_size
,
self
.
cls_name
)
_check_input_filter_size
(
F
.
shape
(
img1
),
"img1"
,
self
.
filter_size
,
self
.
cls_name
)
P
.
SameTypeShape
()(
img1
,
img2
)
P
.
SameTypeShape
()(
img1
,
img2
)
max_val
=
_convert_img_dtype_to_float32
(
self
.
max_val
,
self
.
max_val
)
max_val
=
_convert_img_dtype_to_float32
(
self
.
max_val
,
self
.
max_val
)
...
...
tests/ut/python/nn/test_ssim.py
浏览文件 @
71d33b08
...
@@ -35,16 +35,8 @@ class SSIMNet(nn.Cell):
...
@@ -35,16 +35,8 @@ class SSIMNet(nn.Cell):
def
test_compile
():
def
test_compile
():
net
=
SSIMNet
()
net
=
SSIMNet
()
img1
=
Tensor
(
np
.
random
.
random
((
8
,
3
,
16
,
16
)))
img1
=
Tensor
(
np
.
random
.
random
((
8
,
3
,
16
,
16
)),
mstype
.
float32
)
img2
=
Tensor
(
np
.
random
.
random
((
8
,
3
,
16
,
16
)))
img2
=
Tensor
(
np
.
random
.
random
((
8
,
3
,
16
,
16
)),
mstype
.
float32
)
_executor
.
compile
(
net
,
img1
,
img2
)
def
test_compile_grayscale
():
max_val
=
255
net
=
SSIMNet
(
max_val
=
max_val
)
img1
=
Tensor
(
np
.
random
.
randint
(
0
,
256
,
(
8
,
1
,
16
,
16
),
np
.
uint8
))
img2
=
Tensor
(
np
.
random
.
randint
(
0
,
256
,
(
8
,
1
,
16
,
16
),
np
.
uint8
))
_executor
.
compile
(
net
,
img1
,
img2
)
_executor
.
compile
(
net
,
img1
,
img2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录