Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add PPMatting Support #163

Merged
merged 86 commits into from
Aug 31, 2022
Merged

Add PPMatting Support #163

merged 86 commits into from
Aug 31, 2022

Conversation

ziqi-jin
Copy link
Contributor

  • add PPMatting-512 and PPMatting-1024 support
  • add swap background function for MattingResult and SegmentationResult

@DefTruth DefTruth self-requested a review August 29, 2022 03:17
#endif

bool LimitShort::Run(Mat* mat, int max_short, int min_short, ProcLib lib) {
auto r = LimitShort(max_short, min_short);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个缩写是不是改成 l 更合理?像normalize是n,convert是c,等等

@@ -0,0 +1,187 @@
#include "fastdeploy/vision/matting/ppmatting/ppmatting.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

漏了 copyright

@@ -0,0 +1,44 @@
#pragma once
Copy link
Collaborator

Choose a reason for hiding this comment

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

漏了 copyright

bool Postprocess(std::vector<FDTensor>& infer_result, MattingResult* result,
const std::map<std::string, std::array<int, 2>>& im_info);

bool is_resized = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

private应该加下划线 is_resized_

return vis_img;
}
// 对SegmentationResult做背景替换,由于分割模型可以预测多个类别其中background_label
// 是
Copy link
Collaborator

Choose a reason for hiding this comment

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

感觉这句注释没有写完整

@@ -15,20 +15,24 @@ cd examples/vision/matting/modnet/python/
#下载modnet模型文件和测试图片
wget https://bj.bcebos.com/paddlehub/fastdeploy/modnet_photographic_portrait_matting.onnx
wget https://raw.githubusercontent.com/DefTruth/lite.ai.toolkit/main/examples/lite/resources/test_lite_matting_input.jpg
wget https://raw.githubusercontent.com/DefTruth/lite.ai.toolkit/main/examples/lite/resources/test_lite_matting_bgr.jpg
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上

# GPU上使用TensorRT推理
python infer.py --model modnet_photographic_portrait_matting.onnx --image test_lite_matting_input.jpg --device gpu --use_trt True
python infer.py --model modnet_photographic_portrait_matting.onnx --image test_lite_matting_input.jpg --bg test_lite_matting_bgr.jpg --device gpu --use_trt True
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上

# 下载PPMatting模型文件和测试图片
wget https://bj.bcebos.com/paddlehub/fastdeploy/PP-Matting-512.tgz
tar -xvf PP-Matting-512.tgz
wget https://raw.githubusercontent.com/DefTruth/lite.ai.toolkit/main/examples/lite/resources/test_lite_matting_input.jpg
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上

# GPU推理 (TODO: ORT-GPU 推理会报错)
./infer_demo PP-Matting-512 test_lite_matting_input.jpg test_lite_matting_bgr.jpg 1
# GPU上TensorRT推理
./infer_demo PP-Matting-512 test_lite_matting_input.jpg test_lite_matting_bgr.jpg 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

同上

result, C.vision.
SegmentationResult), "The result must be SegmentaitonResult type"
return C.vision.Visualize.swap_background_segmentation(
im_data, background, background_label, result)
Copy link
Collaborator

Choose a reason for hiding this comment

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

增加remove_small_connected_area定义

@jiangjiajun jiangjiajun merged commit f0dbd13 into PaddlePaddle:develop Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants