-
Notifications
You must be signed in to change notification settings - Fork 676
Modify PPMatting backend and docs #182
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
Merged
Merged
Changes from all commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
1684b05
first commit for yolov7
ziqi-jin 71c00d9
pybind for yolov7
ziqi-jin 21ab2f9
CPP README.md
ziqi-jin d63e862
CPP README.md
ziqi-jin 7b3b0e2
modified yolov7.cc
ziqi-jin d039e80
README.md
ziqi-jin a34a815
python file modify
ziqi-jin eb010a8
merge test
ziqi-jin 39f64f2
delete license in fastdeploy/
ziqi-jin d071b37
repush the conflict part
ziqi-jin d5026ca
README.md modified
ziqi-jin fb376ad
README.md modified
ziqi-jin 4b8737c
file path modified
ziqi-jin ce922a0
file path modified
ziqi-jin 6e00b82
file path modified
ziqi-jin 8c359fb
file path modified
ziqi-jin 906c730
file path modified
ziqi-jin 80c1223
README modified
ziqi-jin 6072757
README modified
ziqi-jin 2c6e6a4
move some helpers to private
ziqi-jin 48136f0
add examples for yolov7
ziqi-jin 6feca92
api.md modified
ziqi-jin ae70d4f
api.md modified
ziqi-jin f591b85
api.md modified
ziqi-jin f0def41
YOLOv7
ziqi-jin 15b9160
yolov7 release link
ziqi-jin 4706e8c
yolov7 release link
ziqi-jin dc83584
yolov7 release link
ziqi-jin 086debd
copyright
ziqi-jin 4f980b9
change some helpers to private
ziqi-jin 2e61c95
Merge branch 'develop' into develop
ziqi-jin 80beadf
change variables to const and fix documents.
ziqi-jin 8103772
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin f5f7a86
gitignore
ziqi-jin e6cec25
Transfer some funtions to private member of class
ziqi-jin e25e4f2
Transfer some funtions to private member of class
ziqi-jin e8a8439
Merge from develop (#9)
ziqi-jin a182893
first commit for yolor
ziqi-jin 3aa015f
for merge
ziqi-jin d6b98aa
Develop (#11)
ziqi-jin 871cfc6
Merge branch 'yolor' into develop
ziqi-jin 013921a
Yolor (#16)
ziqi-jin 7a5a6d9
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin c996117
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 0aefe32
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 2330414
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 4660161
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 033c18e
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 6c94d65
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 85fb256
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 90ca4cb
add is_dynamic for YOLO series (#22)
ziqi-jin f6a4ed2
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 3682091
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin ca1e110
Merge remote-tracking branch 'upstream/develop' into develop
ziqi-jin 93ba6a6
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 767842e
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin cc32733
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 2771a3b
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin a1e29ac
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 5ecc6fe
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 2780588
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin c00be81
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 9082178
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 4b14f56
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 4876b82
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 9cebb1f
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin d1e3b29
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 69cf0d2
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 2ff10e1
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin a673a2c
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 832d777
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin e513eac
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin ded2054
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin 19db925
modify ppmatting backend and docs
ziqi-jin 15be4a6
modify ppmatting docs
ziqi-jin 3a5b93a
fix the PPMatting size problem
ziqi-jin f765853
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin c2332b0
fix LimitShort's log
ziqi-jin 950f948
retrigger ci
ziqi-jin 64a13c9
modify PPMatting docs
ziqi-jin 09c073d
modify the way for dealing with LimitShort
ziqi-jin 99969b6
Merge branch 'develop' into develop
jiangjiajun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
csrc/fastdeploy/vision/common/processors/resize_by_long.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. | ||
| // | ||
| // 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. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "fastdeploy/vision/common/processors/resize_by_long.h" | ||
|
|
||
| namespace fastdeploy { | ||
| namespace vision { | ||
|
|
||
| bool ResizeByLong::CpuRun(Mat* mat) { | ||
| cv::Mat* im = mat->GetCpuMat(); | ||
| int origin_w = im->cols; | ||
| int origin_h = im->rows; | ||
| double scale = GenerateScale(origin_w, origin_h); | ||
| if (use_scale_) { | ||
| cv::resize(*im, *im, cv::Size(), scale, scale, interp_); | ||
| } else { | ||
| int width = static_cast<int>(round(scale * im->cols)); | ||
| int height = static_cast<int>(round(scale * im->rows)); | ||
| cv::resize(*im, *im, cv::Size(width, height), 0, 0, interp_); | ||
| } | ||
| mat->SetWidth(im->cols); | ||
| mat->SetHeight(im->rows); | ||
| return true; | ||
| } | ||
|
|
||
| #ifdef ENABLE_OPENCV_CUDA | ||
| bool ResizeByLong::GpuRun(Mat* mat) { | ||
| cv::cuda::GpuMat* im = mat->GetGpuMat(); | ||
| int origin_w = im->cols; | ||
| int origin_h = im->rows; | ||
| double scale = GenerateScale(origin_w, origin_h); | ||
| im->convertTo(*im, CV_32FC(im->channels())); | ||
| if (use_scale_) { | ||
| cv::cuda::resize(*im, *im, cv::Size(), scale, scale, interp_); | ||
| } else { | ||
| int width = static_cast<int>(round(scale * im->cols)); | ||
| int height = static_cast<int>(round(scale * im->rows)); | ||
| cv::cuda::resize(*im, *im, cv::Size(width, height), 0, 0, interp_); | ||
| } | ||
| mat->SetWidth(im->cols); | ||
| mat->SetHeight(im->rows); | ||
| return true; | ||
| } | ||
| #endif | ||
|
|
||
| double ResizeByLong::GenerateScale(const int origin_w, const int origin_h) { | ||
| int im_size_max = std::max(origin_w, origin_h); | ||
| int im_size_min = std::min(origin_w, origin_h); | ||
| double scale = 1.0f; | ||
| if (target_size_ == -1) { | ||
| if (im_size_max > max_size_) { | ||
| scale = static_cast<double>(max_size_) / static_cast<double>(im_size_max); | ||
| } | ||
| } else { | ||
| scale = | ||
| static_cast<double>(target_size_) / static_cast<double>(im_size_max); | ||
| } | ||
| return scale; | ||
| } | ||
|
|
||
| bool ResizeByLong::Run(Mat* mat, int target_size, int interp, bool use_scale, | ||
| int max_size, ProcLib lib) { | ||
| auto r = ResizeByLong(target_size, interp, use_scale, max_size); | ||
| return r(mat, lib); | ||
| } | ||
| } // namespace vision | ||
| } // namespace fastdeploy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. | ||
| // | ||
| // 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. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "fastdeploy/vision/common/processors/base.h" | ||
|
|
||
| namespace fastdeploy { | ||
| namespace vision { | ||
|
|
||
| class ResizeByLong : public Processor { | ||
| public: | ||
| ResizeByLong(int target_size, int interp = 1, bool use_scale = true, | ||
| int max_size = -1) { | ||
| target_size_ = target_size; | ||
| max_size_ = max_size; | ||
| interp_ = interp; | ||
| use_scale_ = use_scale; | ||
| } | ||
| bool CpuRun(Mat* mat); | ||
| #ifdef ENABLE_OPENCV_CUDA | ||
| bool GpuRun(Mat* mat); | ||
| #endif | ||
| std::string Name() { return "ResizeByLong"; } | ||
|
|
||
| static bool Run(Mat* mat, int target_size, int interp = 1, | ||
| bool use_scale = true, int max_size = -1, | ||
| ProcLib lib = ProcLib::OPENCV_CPU); | ||
|
|
||
| private: | ||
| double GenerateScale(const int origin_w, const int origin_h); | ||
| int target_size_; | ||
| int max_size_; | ||
| int interp_; | ||
| bool use_scale_; | ||
| }; | ||
| } // namespace vision | ||
| } // namespace fastdeploy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ wget https://bj.bcebos.com/paddlehub/fastdeploy/matting_bgr.jpg | |
|
|
||
| # CPU推理 | ||
| ./infer_demo PP-Matting-512 matting_input.jpg matting_bgr.jpg 0 | ||
| # GPU推理 (TODO: ORT-GPU 推理会报错) | ||
| # GPU推理 | ||
| ./infer_demo PP-Matting-512 matting_input.jpg matting_bgr.jpg 1 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里保留GpuInfer,但是设置一下backend为paddle |
||
| # GPU上TensorRT推理 | ||
| ./infer_demo PP-Matting-512 matting_input.jpg matting_bgr.jpg 2 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ wget https://bj.bcebos.com/paddlehub/fastdeploy/matting_input.jpg | |
| wget https://bj.bcebos.com/paddlehub/fastdeploy/matting_bgr.jpg | ||
| # CPU推理 | ||
| python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bgr.jpg --device cpu | ||
| # GPU推理 (TODO: ORT-GPU 推理会报错) | ||
| # GPU推理 | ||
| python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bgr.jpg --device gpu | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 |
||
| # GPU上使用TensorRT推理 (注意:TensorRT推理第一次运行,有序列化模型的操作,有一定耗时,需要耐心等待) | ||
| python infer.py --model PP-Matting-512 --image matting_input.jpg --bg matting_bgr.jpg --device gpu --use_trt True | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
naive 值传递 不需要 const限制