Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
UNet_migraphx
Commits
ce346218
Commit
ce346218
authored
Oct 07, 2023
by
liucong
Browse files
修改input/output代码
parent
fb1c8860
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
9 deletions
+43
-9
Doc/Tutorial_Cpp.md
Doc/Tutorial_Cpp.md
+15
-4
Python/Unet.py
Python/Unet.py
+13
-1
Src/Unet.cpp
Src/Unet.cpp
+15
-4
No files found.
Doc/Tutorial_Cpp.md
View file @
ce346218
...
@@ -23,10 +23,21 @@ ErrorCode Unet::Initialize(InitializationParameterOfSegmentation initParamOfSegm
...
@@ -23,10 +23,21 @@ ErrorCode Unet::Initialize(InitializationParameterOfSegmentation initParamOfSegm
net = migraphx::parse_onnx(modelPath);
net = migraphx::parse_onnx(modelPath);
LOG_INFO(logFile,"succeed to load model: %s\n",GetFileName(modelPath).c_str());
LOG_INFO(logFile,"succeed to load model: %s\n",GetFileName(modelPath).c_str());
// 获取模型输入属性
// 获取模型输入/输出节点信息
std::pair<std::string, migraphx::shape> inputAttribute=net.get_parameter_shapes();
std::cout<<"inputs:"<<std::endl;
inputName=inputAttribute.first;
std::unordered_map<std::string, migraphx::shape> inputs=net.get_inputs();
inputShape=inputAttribute.second;
for(auto i:inputs)
{
std::cout<<i.first<<":"<<i.second<<std::endl;
}
std::cout<<"outputs:"<<std::endl;
std::unordered_map<std::string, migraphx::shape> outputs=net.get_outputs();
for(auto i:outputs)
{
std::cout<<i.first<<":"<<i.second<<std::endl;
}
inputName=inputs.first;
inputShape=inputs.second;
int N=inputShape.lens()[0];
int N=inputShape.lens()[0];
int C=inputShape.lens()[1];
int C=inputShape.lens()[1];
int H=inputShape.lens()[2];
int H=inputShape.lens()[2];
...
...
Python/Unet.py
View file @
ce346218
...
@@ -26,8 +26,20 @@ if __name__ == '__main__':
...
@@ -26,8 +26,20 @@ if __name__ == '__main__':
# 加载模型
# 加载模型
model
=
migraphx
.
parse_onnx
(
"../Resource/Models/unet_13_256.onnx"
)
model
=
migraphx
.
parse_onnx
(
"../Resource/Models/unet_13_256.onnx"
)
# 获取模型输入/输出节点信息
print
(
"inputs:"
)
inputs
=
model
.
get_inputs
()
for
key
,
value
in
inputs
.
items
():
print
(
"{}:{}"
.
format
(
key
,
value
))
print
(
"outputs:"
)
outputs
=
model
.
get_outputs
()
for
key
,
value
in
outputs
.
items
():
print
(
"{}:{}"
.
format
(
key
,
value
))
inputName
=
model
.
get_parameter_names
()
inputName
=
model
.
get_parameter_names
()
inputShape
=
model
.
get_parameter_shape
s
()
inputShape
=
inputs
[
inputName
].
len
s
()
print
(
"inputName:{0}
\n
inputShape:{1}"
.
format
(
inputName
,
inputShape
))
print
(
"inputName:{0}
\n
inputShape:{1}"
.
format
(
inputName
,
inputShape
))
# 编译模型
# 编译模型
...
...
Src/Unet.cpp
View file @
ce346218
...
@@ -53,10 +53,21 @@ ErrorCode Unet::Initialize(InitializationParameterOfSegmentation initParamOfSegm
...
@@ -53,10 +53,21 @@ ErrorCode Unet::Initialize(InitializationParameterOfSegmentation initParamOfSegm
net
=
migraphx
::
parse_onnx
(
modelPath
);
net
=
migraphx
::
parse_onnx
(
modelPath
);
LOG_INFO
(
stdout
,
"succeed to load model: %s
\n
"
,
GetFileName
(
modelPath
).
c_str
());
LOG_INFO
(
stdout
,
"succeed to load model: %s
\n
"
,
GetFileName
(
modelPath
).
c_str
());
// 获取模型输入属性
// 获取模型输入/输出节点信息
std
::
unordered_map
<
std
::
string
,
migraphx
::
shape
>
inputMap
=
net
.
get_parameter_shapes
();
std
::
cout
<<
"inputs:"
<<
std
::
endl
;
inputName
=
inputMap
.
begin
()
->
first
;
std
::
unordered_map
<
std
::
string
,
migraphx
::
shape
>
inputs
=
net
.
get_inputs
();
inputShape
=
inputMap
.
begin
()
->
second
;
for
(
auto
i
:
inputs
)
{
std
::
cout
<<
i
.
first
<<
":"
<<
i
.
second
<<
std
::
endl
;
}
std
::
cout
<<
"outputs:"
<<
std
::
endl
;
std
::
unordered_map
<
std
::
string
,
migraphx
::
shape
>
outputs
=
net
.
get_outputs
();
for
(
auto
i
:
outputs
)
{
std
::
cout
<<
i
.
first
<<
":"
<<
i
.
second
<<
std
::
endl
;
}
inputName
=
inputs
.
begin
()
->
first
;
inputShape
=
inputs
.
begin
()
->
second
;
int
N
=
inputShape
.
lens
()[
0
];
int
N
=
inputShape
.
lens
()[
0
];
int
C
=
inputShape
.
lens
()[
1
];
int
C
=
inputShape
.
lens
()[
1
];
int
H
=
inputShape
.
lens
()[
2
];
int
H
=
inputShape
.
lens
()[
2
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment