-
Notifications
You must be signed in to change notification settings - Fork 465
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
Conversation
ziqi-jin
commented
Aug 26, 2022
- add PPMatting-512 and PPMatting-1024 support
- add swap background function for MattingResult and SegmentationResult
#endif | ||
|
||
bool LimitShort::Run(Mat* mat, int max_short, int min_short, ProcLib lib) { | ||
auto r = LimitShort(max_short, min_short); |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 | ||
// 是 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
增加remove_small_connected_area定义