Browse Source

!15893 fix codex

From: @yuzhenhua666
Reviewed-by: @oacjiewen,@c_34
Signed-off-by: @c_34
pull/15893/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
2ee7db52f2
14 changed files with 44 additions and 50 deletions
  1. +3
    -3
      model_zoo/official/cv/ctpn/ascend310_infer/inc/utils.h
  2. +5
    -5
      model_zoo/official/cv/ctpn/ascend310_infer/src/main.cc
  3. +5
    -7
      model_zoo/official/cv/ctpn/ascend310_infer/src/utils.cc
  4. +3
    -3
      model_zoo/official/cv/deeptext/ascend310_infer/inc/utils.h
  5. +2
    -1
      model_zoo/official/cv/deeptext/ascend310_infer/src/main.cc
  6. +6
    -9
      model_zoo/official/cv/deeptext/ascend310_infer/src/utils.cc
  7. +1
    -2
      model_zoo/official/cv/faster_rcnn/ascend310_infer/src/AclProcess.cpp
  8. +3
    -2
      model_zoo/official/cv/faster_rcnn/ascend310_infer/src/main.cpp
  9. +3
    -0
      model_zoo/official/cv/maskrcnn/ascend310_infer/src/AclProcess.cpp
  10. +6
    -8
      model_zoo/official/cv/resnet/ascend310_infer/src/main.cc
  11. +5
    -5
      model_zoo/official/cv/unet/ascend310_infer/src/main.cc
  12. +0
    -1
      model_zoo/official/cv/yolov4/ascend310_infer/src/main.cc
  13. +1
    -2
      model_zoo/official/recommend/naml/ascend310_infer/src/sample_process.cpp
  14. +1
    -2
      model_zoo/official/recommend/naml/ascend310_infer/src/utils.cpp

+ 3
- 3
model_zoo/official/cv/ctpn/ascend310_infer/inc/utils.h View File

@@ -1,12 +1,12 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.


+ 5
- 5
model_zoo/official/cv/ctpn/ascend310_infer/src/main.cc View File

@@ -99,11 +99,11 @@ int main(int argc, char **argv) {
return 1;
}

std::shared_ptr<TensorTransform> decode(new Decode());
std::shared_ptr<TensorTransform> resize(new Resize({576, 960}));
std::shared_ptr<TensorTransform> normalize(new Normalize({123.675, 116.28, 103.53}, {58.395, 57.12, 57.375}));
std::shared_ptr<TensorTransform> hwc2chw(new HWC2CHW());
std::shared_ptr<TensorTransform> typeCast(new TypeCast("float16"));
auto decode = Decode();
auto resize = Resize({576, 960});
auto normalize = Normalize({123.675, 116.28, 103.53}, {58.395, 57.12, 57.375});
auto hwc2chw = HWC2CHW();
auto typeCast = TypeCast("float16");

mindspore::dataset::Execute transformDecode(decode);
mindspore::dataset::Execute transform({resize, normalize, hwc2chw});


+ 5
- 7
model_zoo/official/cv/ctpn/ascend310_infer/src/utils.cc View File

@@ -1,12 +1,12 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -48,8 +48,7 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
std::string homePath = "./result_Files";
for (size_t i = 0; i < outputs.size(); ++i) {
size_t outputSize;
std::shared_ptr<const void> netOutput;
netOutput = outputs[i].Data();
std::shared_ptr<const void> netOutput = outputs[i].Data();
outputSize = outputs[i].DataSize();
int pos = imageFile.rfind('/');
std::string fileName(imageFile, pos + 1);
@@ -104,8 +103,7 @@ DIR *OpenDir(std::string_view dirName) {
std::cout << "dirName is not a valid directory !" << std::endl;
return nullptr;
}
DIR *dir;
dir = opendir(realPath.c_str());
DIR *dir = opendir(realPath.c_str());
if (dir == nullptr) {
std::cout << "Can not open dir " << dirName << std::endl;
return nullptr;


+ 3
- 3
model_zoo/official/cv/deeptext/ascend310_infer/inc/utils.h View File

@@ -1,12 +1,12 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.


+ 2
- 1
model_zoo/official/cv/deeptext/ascend310_infer/src/main.cc View File

@@ -101,7 +101,8 @@ int main(int argc, char **argv) {
std::map<double, double> costTime_map;
size_t size = all_files.size();

Execute transform(std::shared_ptr<DvppDecodeResizeJpeg>(new DvppDecodeResizeJpeg({576, 960})));
auto dvppDecodeResizeJpeg = DvppDecodeResizeJpeg({576, 960});
Execute transform(dvppDecodeResizeJpeg);

for (size_t i = 0; i < size; ++i) {
struct timeval start;


+ 6
- 9
model_zoo/official/cv/deeptext/ascend310_infer/src/utils.cc View File

@@ -1,12 +1,12 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -48,14 +48,13 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
std::string homePath = "./result_Files";
for (size_t i = 0; i < outputs.size(); ++i) {
size_t outputSize;
std::shared_ptr<const void> netOutput;
netOutput = outputs[i].Data();
std::shared_ptr<const void> netOutput = outputs[i].Data();
outputSize = outputs[i].DataSize();
int pos = imageFile.rfind('/');
std::string fileName(imageFile, pos + 1);
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
std::string outFileName = homePath + "/" + fileName;
FILE * outputFile = fopen(outFileName.c_str(), "wb");
FILE *outputFile = fopen(outFileName.c_str(), "wb");
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
fclose(outputFile);
outputFile = nullptr;
@@ -104,8 +103,7 @@ DIR *OpenDir(std::string_view dirName) {
std::cout << "dirName is not a valid directory !" << std::endl;
return nullptr;
}
DIR *dir;
dir = opendir(realPath.c_str());
DIR *dir = opendir(realPath.c_str());
if (dir == nullptr) {
std::cout << "Can not open dir " << dirName << std::endl;
return nullptr;
@@ -118,7 +116,6 @@ std::string RealPath(std::string_view path) {
char realPathMem[PATH_MAX] = {0};
char *realPathRet = nullptr;
realPathRet = realpath(path.data(), realPathMem);

if (realPathRet == nullptr) {
std::cout << "File: " << path << " is not exist.";
return "";


+ 1
- 2
model_zoo/official/cv/faster_rcnn/ascend310_infer/src/AclProcess.cpp View File

@@ -142,8 +142,7 @@ int AclProcess::WriteResult(const std::string& imageFile) {
void *resHostBuf = nullptr;
for (size_t i = 0; i < outputBuffers_.size(); ++i) {
size_t output_size;
void *netOutput;
netOutput = outputBuffers_[i];
void *netOutput = outputBuffers_[i];
output_size = outputSizes_[i];
int ret = aclrtMallocHost(&resHostBuf, output_size);
if (ret != OK) {


+ 3
- 2
model_zoo/official/cv/faster_rcnn/ascend310_infer/src/main.cpp View File

@@ -88,8 +88,7 @@ int main(int argc, char* argv[]) {
}
} else if (is_dir(FLAGS_data_path)) {
struct dirent *filename;
DIR *dir;
dir = opendir(FLAGS_data_path.c_str());
DIR *dir = opendir(FLAGS_data_path.c_str());
if (dir == nullptr) {
aclProcess.Release();
return ERROR;
@@ -104,9 +103,11 @@ int main(int argc, char* argv[]) {
if (ret != OK) {
std::cout << "model process failed, errno = " << ret << std::endl;
aclProcess.Release();
closedir(dir);
return ret;
}
}
closedir(dir);
} else {
std::cout << " input image path error" << std::endl;
}


+ 3
- 0
model_zoo/official/cv/maskrcnn/ascend310_infer/src/AclProcess.cpp View File

@@ -298,12 +298,14 @@ int AclProcess::ModelInfer(std::map<double, double> *costTime_map) {
if (ret != ACL_ERROR_NONE) {
std::cout << "aclrtMalloc failed, ret = " << ret << std::endl;
aclrtFree(imInfo_dst);
free(im_info);
return ret;
}
ret = aclrtMemcpy(reinterpret_cast<uint8_t *>(imInfo_dst), 8, im_info, 8, ACL_MEMCPY_HOST_TO_DEVICE);
if (ret != ACL_ERROR_NONE) {
std::cout << "aclrtMemcpy failed, ret = " << ret << std::endl;
aclrtFree(imInfo_dst);
free(im_info);
return ret;
}

@@ -327,6 +329,7 @@ int AclProcess::ModelInfer(std::map<double, double> *costTime_map) {
return ret;
}
RELEASE_DVPP_DATA(resizeOutData->data);
free(im_info);
return OK;
}



+ 6
- 8
model_zoo/official/cv/resnet/ascend310_infer/src/main.cc View File

@@ -70,7 +70,6 @@ int main(int argc, char **argv) {
Serialization::Load(FLAGS_mindir_path, ModelType::kMindIR, &graph);
Model model;
Status ret = model.Build(GraphCell(graph), context);

if (ret != kSuccess) {
std::cout << "ERROR: Build failed." << std::endl;
return 1;
@@ -90,14 +89,13 @@ int main(int argc, char **argv) {
std::vector<float> mean = {0.485 * 255, 0.456 * 255, 0.406 * 255};
std::vector<float> std = {0.229 * 255, 0.224 * 255, 0.225 * 255};

std::shared_ptr<TensorTransform> decode(new Decode());
std::shared_ptr<TensorTransform> resize(new Resize(resize_paras));
std::shared_ptr<TensorTransform> centercrop(new CenterCrop(crop_paras));
std::shared_ptr<TensorTransform> normalize(new Normalize(mean, std));
std::shared_ptr<TensorTransform> hwc2chw(new HWC2CHW());
auto decode = Decode();
auto resize = Resize(resize_paras);
auto centercrop = CenterCrop(crop_paras);
auto normalize = Normalize(mean, std);
auto hwc2chw = HWC2CHW();

std::vector<std::shared_ptr<TensorTransform>> trans_list = {decode, resize, centercrop, normalize, hwc2chw};
mindspore::dataset::Execute SingleOp(trans_list);
mindspore::dataset::Execute SingleOp({decode, resize, centercrop, normalize, hwc2chw});

for (size_t i = 0; i < size; ++i) {
for (size_t j = 0; j < all_files[i].size(); ++j) {


+ 5
- 5
model_zoo/official/cv/unet/ascend310_infer/src/main.cc View File

@@ -86,11 +86,11 @@ int main(int argc, char **argv) {
std::map<double, double> costTime_map;
size_t size = all_files.size();

auto decode(new Decode());
auto swapredblue(new SwapRedBlue());
auto resize(new Resize({96, 96}));
auto normalize(new Normalize({127.5, 127.5, 127.5}, {127.5, 127.5, 127.5}));
auto hwc2chw(new HWC2CHW());
auto decode = Decode();
auto swapredblue = SwapRedBlue();
auto resize = Resize({96, 96});
auto normalize = Normalize({127.5, 127.5, 127.5}, {127.5, 127.5, 127.5});
auto hwc2chw = HWC2CHW();
Execute preprocess({decode, swapredblue, resize, normalize, hwc2chw});

for (size_t i = 0; i < size; ++i) {


+ 0
- 1
model_zoo/official/cv/yolov4/ascend310_infer/src/main.cc View File

@@ -69,7 +69,6 @@ int main(int argc, char **argv) {
mindspore::Graph graph;
Serialization::Load(FLAGS_mindir_path, ModelType::kMindIR, &graph);


if (!FLAGS_precision_mode.empty()) {
ascend310->SetPrecisionMode(FLAGS_precision_mode);
}


+ 1
- 2
model_zoo/official/recommend/naml/ascend310_infer/src/sample_process.cpp View File

@@ -350,8 +350,7 @@ std::vector<std::string> SampleProcess::GetModelExecCostTimeInfo() {
" ms of infer_count " << infer_cnt << std::endl;
result.emplace_back(timeCost.str());

double totalCostTime;
totalCostTime = totalCostTime_map_.begin()->second - totalCostTime_map_.begin()->first;
double totalCostTime = totalCostTime_map_.begin()->second - totalCostTime_map_.begin()->first;
std::stringstream totalTimeCost;
totalTimeCost << "total inference cost time: "<< totalCostTime << " ms; count " << infer_cnt << std::endl;
result.emplace_back(totalTimeCost.str());


+ 1
- 2
model_zoo/official/recommend/naml/ascend310_infer/src/utils.cpp View File

@@ -157,8 +157,7 @@ DIR *Utils::OpenDir(std::string dir_name) {
return nullptr;
}

DIR *dir;
dir = opendir(real_path.c_str());
DIR *dir = opendir(real_path.c_str());
if (dir == nullptr) {
std::cout << "Can not open dir " << dir_name << std::endl;
return nullptr;


Loading…
Cancel
Save