Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Left TODO] Support PaddleSeg deployment #39

Merged
merged 25 commits into from
Aug 5, 2022

Conversation

felixhjh
Copy link
Collaborator

@felixhjh felixhjh commented Jul 25, 2022

  1. 支持 PaddleSeg 六个模型的部署(Deeplabv3-ResNet50, hrnet-w18, pp-humanseg, pp-humanseg-server, PP-LiteSeg, unet)
  2. 支持三种模型导出形式(logits matrix, logits matrix with argmax, logits matrix with argmax and with softmax)
  3. 支持visualization

@felixhjh felixhjh changed the title Visualize function resize mask back to original image size Support PaddleSeg deployment Aug 2, 2022
std::map<std::string, std::array<int, 2>>* im_info) {
FDASSERT(infer_result.dtype == FDDataType::INT64 ||
infer_result.dtype == FDDataType::FP32,
"Require the data type of output is int64 or fp32, but now it's " +
Str(const_cast<fastdeploy::FDDataType&>(infer_result.dtype)) +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是可以直接写成Str(infer_result.dtype)

}
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个hwc2chw是不是可以直接改成opencv的操作

for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
temp_mat.at<float_t>(i, j) =
static_cast<float_t>(infer_result_buffer[index++]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processor的这个函数建议按照功能模块拆一下,提升可读性

int64_t chw = channel * height * width;
int64_t* infer_result_buffer = static_cast<int64_t*>(infer_result.Data());
std::vector<float_t> float_result_buffer(chw);
temp_mat = cv::Mat(height, width, CV_32FC(channel));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int64出来的结果,转为了float的来进行后面的resize处理,这个部署的结果是否跟PaddleSeg对齐了?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这么做的原因有二:

  1. int64的结果出来的是类别的mask矩阵,对于pp-human系列也就是0,1矩阵(其他也就是0-num_classes的矩阵)。opencv没有64位的矩阵变量,因此必须要转。
  2. 转为float是因为,resize的插值方式双线性策略(inter=1,也是前处理所使用的策略)只支持float类型opencv mat(不支持int、uint8精度缺失)。为保持前后处理一致所以统一转为float。
  3. PaddleSeg给到的三张示例图片,正常人像、竖屏人像、横屏人像fastdeploy结果与PaddleSeg是一致的,后续evaluation模块开发完成(正在去除Paddle依赖)会跑全量

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第3点, 先确认输出的值(numpy) 与 PaddleSeg是一致的,并做到与Seg结果一致

@jiangjiajun jiangjiajun changed the title Support PaddleSeg deployment [Left TODO] Support PaddleSeg deployment Aug 5, 2022
@jiangjiajun
Copy link
Collaborator

  • WARNING日志的关闭,当前在infer里面每次都会输出提示,需让用户能够关闭
  • NHWC2CHW的实现应该为FDTensor的基础操作,需集成Eigen库来解决,后续需替换

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants