Commit 3157901f authored by shizhm's avatar shizhm
Browse files

完善C++代码

parent cd05e0f0
...@@ -54,15 +54,15 @@ ErrorCode DetectorYOLOV5::Initialize(InitializationParameterOfDetector initializ ...@@ -54,15 +54,15 @@ ErrorCode DetectorYOLOV5::Initialize(InitializationParameterOfDetector initializ
yolov5Parameter.numberOfClasses=(int)netNode["NumberOfClasses"]; yolov5Parameter.numberOfClasses=(int)netNode["NumberOfClasses"];
useFP16=(bool)(int)netNode["UseFP16"]; useFP16=(bool)(int)netNode["UseFP16"];
if(Exists(modelPath)==false)
{
LOG_ERROR(stdout,"%s not exist!\n",modelPath.c_str());
return MODEL_NOT_EXIST;
}
// 加载模型
if(dynamic) if(dynamic)
{ {
// 加载模型
if(Exists(modelPath)==false)
{
LOG_ERROR(stdout,"%s not exist!\n",modelPath.c_str());
return MODEL_NOT_EXIST;
}
migraphx::onnx_options onnx_options; migraphx::onnx_options onnx_options;
onnx_options.map_input_dims["images"]={1,3,800,800};// onnx_options.map_input_dims["images"]={1,3,800,800};//
net = migraphx::parse_onnx(modelPath, onnx_options); net = migraphx::parse_onnx(modelPath, onnx_options);
...@@ -83,12 +83,6 @@ ErrorCode DetectorYOLOV5::Initialize(InitializationParameterOfDetector initializ ...@@ -83,12 +83,6 @@ ErrorCode DetectorYOLOV5::Initialize(InitializationParameterOfDetector initializ
} }
else else
{ {
// 加载模型
if(Exists(modelPath)==false)
{
LOG_ERROR(stdout,"%s not exist!\n",modelPath.c_str());
return MODEL_NOT_EXIST;
}
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());
...@@ -169,7 +163,13 @@ ErrorCode DetectorYOLOV5::Detect(const cv::Mat &srcImage, std::vector<ResultOfDe ...@@ -169,7 +163,13 @@ ErrorCode DetectorYOLOV5::Detect(const cv::Mat &srcImage, std::vector<ResultOfDe
width = srcImage.rows; width = srcImage.rows;
height = srcImage.cols; height = srcImage.cols;
relInputShape = {1,3,height,width}; relInputShape = {1,3,height,width};
inputBlob = cv::dnn::blobFromImage(srcImage); cv::dnn::blobFromImage(srcImage,
inputBlob,
1 / 255.0,
cv::Size(width, height),
cv::Scalar(0, 0, 0),
true,
false);
} }
else else
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment