Skip to content

[Doc] Add C++ comments for external models #394

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 98 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
1684b05
first commit for yolov7
ziqi-jin Jul 13, 2022
71c00d9
pybind for yolov7
ziqi-jin Jul 14, 2022
21ab2f9
CPP README.md
ziqi-jin Jul 14, 2022
d63e862
CPP README.md
ziqi-jin Jul 14, 2022
7b3b0e2
modified yolov7.cc
ziqi-jin Jul 14, 2022
d039e80
README.md
ziqi-jin Jul 15, 2022
a34a815
python file modify
ziqi-jin Jul 18, 2022
eb010a8
merge test
ziqi-jin Jul 18, 2022
39f64f2
delete license in fastdeploy/
ziqi-jin Jul 18, 2022
d071b37
repush the conflict part
ziqi-jin Jul 18, 2022
d5026ca
README.md modified
ziqi-jin Jul 18, 2022
fb376ad
README.md modified
ziqi-jin Jul 18, 2022
4b8737c
file path modified
ziqi-jin Jul 18, 2022
ce922a0
file path modified
ziqi-jin Jul 18, 2022
6e00b82
file path modified
ziqi-jin Jul 18, 2022
8c359fb
file path modified
ziqi-jin Jul 18, 2022
906c730
file path modified
ziqi-jin Jul 18, 2022
80c1223
README modified
ziqi-jin Jul 18, 2022
6072757
README modified
ziqi-jin Jul 18, 2022
2c6e6a4
move some helpers to private
ziqi-jin Jul 18, 2022
48136f0
add examples for yolov7
ziqi-jin Jul 18, 2022
6feca92
api.md modified
ziqi-jin Jul 18, 2022
ae70d4f
api.md modified
ziqi-jin Jul 18, 2022
f591b85
api.md modified
ziqi-jin Jul 18, 2022
f0def41
YOLOv7
ziqi-jin Jul 18, 2022
15b9160
yolov7 release link
ziqi-jin Jul 18, 2022
4706e8c
yolov7 release link
ziqi-jin Jul 18, 2022
dc83584
yolov7 release link
ziqi-jin Jul 18, 2022
086debd
copyright
ziqi-jin Jul 18, 2022
4f980b9
change some helpers to private
ziqi-jin Jul 18, 2022
2e61c95
Merge branch 'develop' into develop
ziqi-jin Jul 19, 2022
80beadf
change variables to const and fix documents.
ziqi-jin Jul 19, 2022
8103772
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Jul 19, 2022
f5f7a86
gitignore
ziqi-jin Jul 19, 2022
e6cec25
Transfer some funtions to private member of class
ziqi-jin Jul 19, 2022
e25e4f2
Transfer some funtions to private member of class
ziqi-jin Jul 19, 2022
e8a8439
Merge from develop (#9)
ziqi-jin Jul 20, 2022
a182893
first commit for yolor
ziqi-jin Jul 20, 2022
3aa015f
for merge
ziqi-jin Jul 20, 2022
d6b98aa
Develop (#11)
ziqi-jin Jul 20, 2022
871cfc6
Merge branch 'yolor' into develop
ziqi-jin Jul 20, 2022
013921a
Yolor (#16)
ziqi-jin Jul 21, 2022
7a5a6d9
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Jul 21, 2022
c996117
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Jul 22, 2022
0aefe32
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Jul 26, 2022
2330414
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Jul 26, 2022
4660161
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Jul 27, 2022
033c18e
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Jul 28, 2022
6c94d65
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Jul 28, 2022
85fb256
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Jul 29, 2022
90ca4cb
add is_dynamic for YOLO series (#22)
ziqi-jin Jul 29, 2022
f6a4ed2
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 1, 2022
3682091
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 3, 2022
ca1e110
Merge remote-tracking branch 'upstream/develop' into develop
ziqi-jin Aug 8, 2022
93ba6a6
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 9, 2022
767842e
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 10, 2022
cc32733
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 10, 2022
2771a3b
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 11, 2022
a1e29ac
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 11, 2022
5ecc6fe
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 11, 2022
2780588
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 12, 2022
c00be81
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 15, 2022
9082178
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 15, 2022
4b14f56
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 15, 2022
4876b82
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 16, 2022
9cebb1f
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 18, 2022
d1e3b29
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 19, 2022
69cf0d2
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 22, 2022
2ff10e1
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 23, 2022
a673a2c
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 25, 2022
832d777
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 25, 2022
e513eac
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Aug 29, 2022
ded2054
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Sep 1, 2022
19db925
modify ppmatting backend and docs
ziqi-jin Sep 1, 2022
15be4a6
modify ppmatting docs
ziqi-jin Sep 1, 2022
3a5b93a
fix the PPMatting size problem
ziqi-jin Sep 3, 2022
f765853
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Sep 3, 2022
c2332b0
fix LimitShort's log
ziqi-jin Sep 3, 2022
950f948
retrigger ci
ziqi-jin Sep 4, 2022
64a13c9
modify PPMatting docs
ziqi-jin Sep 4, 2022
09c073d
modify the way for dealing with LimitShort
ziqi-jin Sep 6, 2022
99969b6
Merge branch 'develop' into develop
jiangjiajun Sep 6, 2022
cf248de
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Sep 8, 2022
9d4a4c9
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Sep 13, 2022
622fbf7
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Sep 15, 2022
d1cf1ad
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Sep 19, 2022
ff9a07e
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Sep 21, 2022
2707b03
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Sep 22, 2022
896d1d9
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 8, 2022
25ee7e2
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 12, 2022
79068d3
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 17, 2022
be7b2a8
add C++ comments for external models
ziqi-jin Oct 18, 2022
e5d0f8d
Merge branch 'develop' into document
jiangjiajun Oct 19, 2022
296e22c
Merge branch 'develop' into document
ziqi-jin Oct 19, 2022
441cfa3
Merge branch 'develop' into document
jiangjiajun Oct 20, 2022
5116576
add comments for external models
ziqi-jin Oct 20, 2022
c22558a
add comments for ocr, seg, ppyoloe and yolov5cls
ziqi-jin Oct 20, 2022
983067e
modify copyright to pass the code style check
ziqi-jin Oct 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fastdeploy/vision/classification/contrib/yolov5cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FASTDEPLOY_DECL YOLOv5Cls : public FastDeployModel {

/** \brief Predict the classification result for an input image
*
* \param[in] im The input image data, comes from cv::imread()
* \param[in] im The input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format
* \param[in] result The output classification result will be writen to this structure
* \param[in] topk Returns the topk classification result with the highest predicted probability, the default is 1
* \return true if the prediction successed, otherwise false
Expand Down
39 changes: 28 additions & 11 deletions fastdeploy/vision/detection/contrib/nanodet_plus.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,51 @@ namespace fastdeploy {
namespace vision {

namespace detection {

/*! @brief NanoDetPlus model object used when to load a NanoDetPlus model exported by NanoDet.
*/
class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel {
public:
/** \brief Set path of model file and the configuration of runtime.
*
* \param[in] model_file Path of model file, e.g ./nanodet_plus_320.onnx
* \param[in] params_file Path of parameter file, e.g ppyoloe/model.pdiparams, if the model format is ONNX, this parameter will be ignored
* \param[in] custom_option RuntimeOption for inference, the default will use cpu, and choose the backend defined in "valid_cpu_backends"
* \param[in] model_format Model format of the loaded model, default is ONNX format
*/
NanoDetPlus(const std::string& model_file,
const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const ModelFormat& model_format = ModelFormat::ONNX);

/// Get model's name
std::string ModelName() const { return "nanodet"; }


/** \brief Predict the detection result for an input image
*
* \param[in] im The input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format
* \param[in] result The output detection result will be writen to this structure
* \param[in] conf_threshold confidence threashold for postprocessing, default is 0.35
* \param[in] nms_iou_threshold iou threashold for NMS, default is 0.5
* \return true if the prediction successed, otherwise false
*/
virtual bool Predict(cv::Mat* im, DetectionResult* result,
float conf_threshold = 0.35f,
float nms_iou_threshold = 0.5f);

// tuple of input size (width, height), e.g (320, 320)
/// tuple of input size (width, height), e.g (320, 320)
std::vector<int> size;
// padding value, size should be same with Channels
/// padding value, size should be the same as channels
std::vector<float> padding_value;
// keep aspect ratio or not when perform resize operation.
// This option is set as `false` by default in NanoDet-Plus.
/*! @brief
keep aspect ratio or not when perform resize operation. This option is set as `false` by default in NanoDet-Plus
*/
bool keep_ratio;
// downsample strides for NanoDet-Plus to generate anchors, will
// take (8, 16, 32, 64) as default values.
/*! @brief
downsample strides for NanoDet-Plus to generate anchors, will take (8, 16, 32, 64) as default values
*/
std::vector<int> downsample_strides;
// for offseting the boxes by classes when using NMS, default 4096.
/// for offseting the boxes by classes when using NMS, default 4096
float max_wh;
// reg_max for GFL regression, default 7
/// reg_max for GFL regression, default 7
int reg_max;

private:
Expand Down
42 changes: 30 additions & 12 deletions fastdeploy/vision/detection/contrib/scaledyolov4.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,53 @@
namespace fastdeploy {
namespace vision {
namespace detection {

/*! @brief ScaledYOLOv4 model object used when to load a ScaledYOLOv4 model exported by ScaledYOLOv4.
*/
class FASTDEPLOY_DECL ScaledYOLOv4 : public FastDeployModel {
public:
/** \brief Set path of model file and the configuration of runtime.
*
* \param[in] model_file Path of model file, e.g ./scaled_yolov4.onnx
* \param[in] params_file Path of parameter file, e.g ppyoloe/model.pdiparams, if the model format is ONNX, this parameter will be ignored
* \param[in] custom_option RuntimeOption for inference, the default will use cpu, and choose the backend defined in "valid_cpu_backends"
* \param[in] model_format Model format of the loaded model, default is ONNX format
*/

ScaledYOLOv4(const std::string& model_file,
const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const ModelFormat& model_format = ModelFormat::ONNX);

virtual std::string ModelName() const { return "ScaledYOLOv4"; }

/** \brief Predict the detection result for an input image
*
* \param[in] im The input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format
* \param[in] result The output detection result will be writen to this structure
* \param[in] conf_threshold confidence threashold for postprocessing, default is 0.25
* \param[in] nms_iou_threshold iou threashold for NMS, default is 0.5
* \return true if the prediction successed, otherwise false
*/
virtual bool Predict(cv::Mat* im, DetectionResult* result,
float conf_threshold = 0.25,
float nms_iou_threshold = 0.5);

// tuple of (width, height)
/// tuple of (width, height)
std::vector<int> size;
// padding value, size should be same with Channels
/// padding value, size should be the same as channels
std::vector<float> padding_value;
// only pad to the minimum rectange which height and width is times of stride
/// only pad to the minimum rectange which height and width is times of stride
bool is_mini_pad;
// while is_mini_pad = false and is_no_pad = true, will resize the image to
// the set size
/*! @brief
while is_mini_pad = false and is_no_pad = true, will resize the image to the set size
*/
bool is_no_pad;
// if is_scale_up is false, the input image only can be zoom out, the maximum
// resize scale cannot exceed 1.0
/*! @brief
if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0
*/
bool is_scale_up;
// padding stride, for is_mini_pad
/// padding stride, for is_mini_pad
int stride;
// for offseting the boxes by classes when using NMS
/// for offseting the boxes by classes when using NMS
float max_wh;

private:
Expand All @@ -70,7 +88,7 @@ class FASTDEPLOY_DECL ScaledYOLOv4 : public FastDeployModel {
// or not.)
// while is_dynamic_shape if 'false', is_mini_pad will force 'false'. This
// value will
// auto check by fastdeploy after the internal Runtime already initialized.
// auto check by fastdeploy after the internal Runtime already initialized
bool is_dynamic_input_;
};
} // namespace detection
Expand Down
42 changes: 30 additions & 12 deletions fastdeploy/vision/detection/contrib/yolor.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. //NOLINT
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -20,34 +20,51 @@
namespace fastdeploy {
namespace vision {
namespace detection {

/*! @brief YOLOR model object used when to load a YOLOR model exported by YOLOR.
*/
class FASTDEPLOY_DECL YOLOR : public FastDeployModel {
public:
/** \brief Set path of model file and the configuration of runtime.
*
* \param[in] model_file Path of model file, e.g ./yolor.onnx
* \param[in] params_file Path of parameter file, e.g ppyoloe/model.pdiparams, if the model format is ONNX, this parameter will be ignored
* \param[in] custom_option RuntimeOption for inference, the default will use cpu, and choose the backend defined in "valid_cpu_backends"
* \param[in] model_format Model format of the loaded model, default is ONNX format
*/
YOLOR(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const ModelFormat& model_format = ModelFormat::ONNX);

virtual std::string ModelName() const { return "YOLOR"; }

/** \brief Predict the detection result for an input image
*
* \param[in] im The input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format
* \param[in] result The output detection result will be writen to this structure
* \param[in] conf_threshold confidence threashold for postprocessing, default is 0.25
* \param[in] nms_iou_threshold iou threashold for NMS, default is 0.5
* \return true if the prediction successed, otherwise false
*/
virtual bool Predict(cv::Mat* im, DetectionResult* result,
float conf_threshold = 0.25,
float nms_iou_threshold = 0.5);

// tuple of (width, height)
/// tuple of (width, height)
std::vector<int> size;
// padding value, size should be same with Channels
/// padding value, size should be the same as channels
std::vector<float> padding_value;
// only pad to the minimum rectange which height and width is times of stride
/// only pad to the minimum rectange which height and width is times of stride
bool is_mini_pad;
// while is_mini_pad = false and is_no_pad = true, will resize the image to
// the set size
/*! @brief
while is_mini_pad = false and is_no_pad = true, will resize the image to the set size
*/
bool is_no_pad;
// if is_scale_up is false, the input image only can be zoom out, the maximum
// resize scale cannot exceed 1.0
/*! @brief
if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0
*/
bool is_scale_up;
// padding stride, for is_mini_pad
/// padding stride, for is_mini_pad
int stride;
// for offseting the boxes by classes when using NMS
/// for offseting the boxes by classes when using NMS
float max_wh;

private:
Expand All @@ -72,6 +89,7 @@ class FASTDEPLOY_DECL YOLOR : public FastDeployModel {
// auto check by fastdeploy after the internal Runtime already initialized.
bool is_dynamic_input_;
};

} // namespace detection
} // namespace vision
} // namespace fastdeploy
43 changes: 30 additions & 13 deletions fastdeploy/vision/detection/contrib/yolov5.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. //NOLINT
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -21,17 +21,32 @@
namespace fastdeploy {
namespace vision {
namespace detection {

/*! @brief YOLOv5 model object used when to load a YOLOv5 model exported by YOLOv5.
*/
class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
public:
/** \brief Set path of model file and the configuration of runtime.
*
* \param[in] model_file Path of model file, e.g ./yolov5.onnx
* \param[in] params_file Path of parameter file, e.g ppyoloe/model.pdiparams, if the model format is ONNX, this parameter will be ignored
* \param[in] custom_option RuntimeOption for inference, the default will use cpu, and choose the backend defined in "valid_cpu_backends"
* \param[in] model_format Model format of the loaded model, default is ONNX format
*/
YOLOv5(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const ModelFormat& model_format = ModelFormat::ONNX);

~YOLOv5();

std::string ModelName() const { return "yolov5"; }

/** \brief Predict the detection result for an input image
*
* \param[in] im The input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format
* \param[in] result The output detection result will be writen to this structure
* \param[in] conf_threshold confidence threashold for postprocessing, default is 0.25
* \param[in] nms_iou_threshold iou threashold for NMS, default is 0.5
* \return true if the prediction successed, otherwise false
*/
virtual bool Predict(cv::Mat* im, DetectionResult* result,
float conf_threshold = 0.25,
float nms_iou_threshold = 0.5);
Expand Down Expand Up @@ -62,23 +77,25 @@ class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
float conf_threshold, float nms_iou_threshold, bool multi_label,
float max_wh = 7680.0);

// tuple of (width, height)
/// tuple of (width, height)
std::vector<int> size_;
// padding value, size should be same with Channels
/// padding value, size should be the same as channels
std::vector<float> padding_value_;
// only pad to the minimum rectange which height and width is times of stride
/// only pad to the minimum rectange which height and width is times of stride
bool is_mini_pad_;
// while is_mini_pad = false and is_no_pad = true, will resize the image to
// the set size
/*! @brief
while is_mini_pad = false and is_no_pad = true, will resize the image to the set size
*/
bool is_no_pad_;
// if is_scale_up is false, the input image only can be zoom out, the maximum
// resize scale cannot exceed 1.0
/*! @brief
if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0
*/
bool is_scale_up_;
// padding stride, for is_mini_pad
/// padding stride, for is_mini_pad
int stride_;
// for offseting the boxes by classes when using NMS
/// for offseting the boxes by classes when using NMS
float max_wh_;
// for different strategies to get boxes when postprocessing
/// for different strategies to get boxes when postprocessing
bool multi_label_;

private:
Expand Down
Loading