Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
221cb0332
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
221cb0332
Commits
f502233c
Commit
f502233c
authored
3 years ago
by
i-robot
Committed by
Gitee
3 years ago
Browse files
Options
Downloads
Plain Diff
!178 sync master pr to models
Merge pull request !178 from luoyang/mymodel
parents
6373238a
1b505041
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
official/cv/resnext/ascend310_infer/src/CMakeLists.txt
+1
-1
1 addition, 1 deletion
official/cv/resnext/ascend310_infer/src/CMakeLists.txt
official/cv/resnext/ascend310_infer/src/main_preprocess.cc
+47
-3
47 additions, 3 deletions
official/cv/resnext/ascend310_infer/src/main_preprocess.cc
with
48 additions
and
4 deletions
official/cv/resnext/ascend310_infer/src/CMakeLists.txt
+
1
−
1
View file @
f502233c
...
...
@@ -13,4 +13,4 @@ file(GLOB_RECURSE MD_LIB ${MINDSPORE_PATH}/_c_dataengine*)
add_executable
(
main main.cc utils.cc
)
target_link_libraries
(
main
${
MS_LIB
}
${
MD_LIB
}
gflags
)
add_executable
(
main_preprocess main_preprocess.cc utils.cc
)
target_link_libraries
(
main_preprocess
${
MS_LIB
}
${
MD_LIB
}
gflags
)
target_link_libraries
(
main_preprocess
${
MS_LIB
}
gflags
)
This diff is collapsed.
Click to expand it.
official/cv/resnext/ascend310_infer/src/main_preprocess.cc
+
47
−
3
View file @
f502233c
...
...
@@ -63,14 +63,58 @@ int main(int argc, char **argv) {
return
1
;
}
std
::
vector
<
MSTensor
>
outputs
;
ret
=
model
.
Predict
(
FLAGS_image_path
,
&
outputs
);
std
::
cout
<<
"Check if data preprocess exists: "
<<
model
.
HasPreprocess
()
<<
std
::
endl
;
// way 1, construct a common MSTensor
std
::
vector
<
MSTensor
>
inputs1
=
{
ReadFileToTensor
(
FLAGS_image_path
)};
std
::
vector
<
MSTensor
>
outputs1
;
ret
=
model
.
PredictWithPreprocess
(
inputs1
,
&
outputs1
);
if
(
ret
.
IsError
())
{
std
::
cout
<<
"ERROR: Predict failed."
<<
std
::
endl
;
return
1
;
}
std
::
ofstream
o1
(
"result1.txt"
,
std
::
ios
::
out
);
o1
.
write
(
reinterpret_cast
<
const
char
*>
(
outputs1
[
0
].
MutableData
()),
std
::
streamsize
(
outputs1
[
0
].
DataSize
()));
// way 2, construct a pointer of MSTensor, be careful of destroy
MSTensor
*
tensor
=
MSTensor
::
CreateImageTensor
(
FLAGS_image_path
);
std
::
vector
<
MSTensor
>
inputs2
=
{
*
tensor
};
MSTensor
::
DestroyTensorPtr
(
tensor
);
std
::
vector
<
MSTensor
>
outputs2
;
ret
=
model
.
PredictWithPreprocess
(
inputs2
,
&
outputs2
);
if
(
ret
.
IsError
())
{
std
::
cout
<<
"ERROR: Predict failed."
<<
std
::
endl
;
return
1
;
}
auto
shape
=
outputs
[
0
].
Shape
();
std
::
ofstream
o2
(
"result2.txt"
,
std
::
ios
::
out
);
o2
.
write
(
reinterpret_cast
<
const
char
*>
(
outputs2
[
0
].
MutableData
()),
std
::
streamsize
(
outputs2
[
0
].
DataSize
()));
// way 3, split preprocess and predict
std
::
vector
<
MSTensor
>
inputs3
=
{
ReadFileToTensor
(
FLAGS_image_path
)};
std
::
vector
<
MSTensor
>
outputs3
;
ret
=
model
.
Preprocess
(
inputs3
,
&
outputs3
);
if
(
ret
.
IsError
())
{
std
::
cout
<<
"ERROR: Preprocess failed."
<<
std
::
endl
;
return
1
;
}
std
::
vector
<
MSTensor
>
outputs4
;
ret
=
model
.
Predict
(
outputs3
,
&
outputs4
);
if
(
ret
.
IsError
())
{
std
::
cout
<<
"ERROR: Preprocess failed."
<<
std
::
endl
;
return
1
;
}
std
::
ofstream
o3
(
"result3.txt"
,
std
::
ios
::
out
);
o3
.
write
(
reinterpret_cast
<
const
char
*>
(
outputs4
[
0
].
MutableData
()),
std
::
streamsize
(
outputs4
[
0
].
DataSize
()));
// check shape
auto
shape
=
outputs1
[
0
].
Shape
();
std
::
cout
<<
"Output Shape: "
<<
std
::
endl
;
for
(
auto
s
:
shape
)
{
std
::
cout
<<
s
<<
", "
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment