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

[Doc] API docs for Visualize module #770

Merged
merged 122 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 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
74b3ee0
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 21, 2022
a75c0c4
add python comments for external models
ziqi-jin Oct 21, 2022
985d273
modify resnet c++ comments
ziqi-jin Oct 21, 2022
e32a25c
modify C++ comments for external models
ziqi-jin Oct 21, 2022
8a73af6
modify python comments and add result class comments
ziqi-jin Oct 21, 2022
2aa7939
Merge branch 'develop' into doc_python
jiangjiajun Oct 22, 2022
887c53a
Merge branch 'develop' into doc_python
jiangjiajun Oct 23, 2022
963b9b9
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 24, 2022
337e8c0
fix comments compile error
ziqi-jin Oct 24, 2022
d1d6890
modify result.h comments
ziqi-jin Oct 24, 2022
67234dd
Merge branch 'develop' into doc_python
jiangjiajun Oct 24, 2022
440e2a9
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 24, 2022
ac35141
Merge branch 'doc_python' into develop
ziqi-jin Oct 24, 2022
3d83785
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 24, 2022
363a485
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 25, 2022
dc44eac
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 26, 2022
07717b4
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 26, 2022
33b4c62
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Oct 27, 2022
f911f3b
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 1, 2022
ebb9365
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 2, 2022
0ac31bd
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 7, 2022
661a1ef
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 11, 2022
b7fbc70
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 14, 2022
710e7ea
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 17, 2022
4d2a1e3
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 22, 2022
45e97f1
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 22, 2022
a6dd7e4
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 25, 2022
c3d76c0
Merge branch 'PaddlePaddle:develop' into develop
ziqi-jin Nov 29, 2022
dea961e
comments for vis
ziqi-jin Nov 29, 2022
e25f951
python API
ziqi-jin Dec 1, 2022
0655f89
python API
ziqi-jin Dec 1, 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 docs/api_docs/cpp/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED = protected=private
PREDEFINED = protected=private ENABLE_VISION_VISUALIZE=1

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
57 changes: 57 additions & 0 deletions docs/api_docs/python/visualize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Visaulize(可视化)

## fastdeploy.vision.vis_detection

```{eval-rst}
.. autoclass:: fastdeploy.vision.vis_detection
:members:
:inherited-members:
```

## fastdeploy.vision.vis_segmentation

```{eval-rst}
.. autoclass:: fastdeploy.vision.vis_segmentation
:members:
:inherited-members:
```

## fastdeploy.vision.vis_keypoint_detection

```{eval-rst}
.. autoclass:: fastdeploy.vision.vis_keypoint_detection
:members:
:inherited-members:
```
## fastdeploy.vision.vis_face_detection

```{eval-rst}
.. autoclass:: fastdeploy.vision.vis_face_detection
:members:
:inherited-members:
```


## fastdeploy.vision.vis_face_alignment

```{eval-rst}
.. autoclass:: fastdeploy.vision.vis_face_alignment
:members:
:inherited-members:
```

## fastdeploy.vision.vis_matting

```{eval-rst}
.. autoclass:: fastdeploy.vision.vis_matting
:members:
:inherited-members:
```

## fastdeploy.vision.vis_ppocr

```{eval-rst}
.. autoclass:: fastdeploy.vision.vis_ppocr
:members:
:inherited-members:
```
84 changes: 83 additions & 1 deletion fastdeploy/vision/visualize/visualize.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
#include "fastdeploy/vision/tracking/pptracking/model.h"

namespace fastdeploy {
/** \brief All C++ FastDeploy Vision Models APIs are defined inside this namespace
*
*/
namespace vision {

// This class will deprecated, please not use it
class FASTDEPLOY_DECL Visualize {
public:
static int num_classes_;
Expand Down Expand Up @@ -52,35 +54,108 @@ class FASTDEPLOY_DECL Visualize {

std::vector<int> GenerateColorMap(int num_classes = 1000);
cv::Mat RemoveSmallConnectedArea(const cv::Mat& alpha_pred, float threshold);
/** \brief Show the visualized results for detection models
*
* \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 result produced by model
* \param[in] score_threshold threshold for result scores, the bounding box will not be shown if the score is less than score_threshold
* \param[in] line_size line size for bounding boxes
* \param[in] font_size font size for text
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisDetection(const cv::Mat& im,
const DetectionResult& result,
float score_threshold = 0.0,
int line_size = 1, float font_size = 0.5f);
/** \brief Show the visualized results with custom labels for detection models
*
* \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 result produced by model
* \param[in] labels the visualized result will show the bounding box contain class label
* \param[in] score_threshold threshold for result scores, the bounding box will not be shown if the score is less than score_threshold
* \param[in] line_size line size for bounding boxes
* \param[in] font_size font size for text
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisDetection(const cv::Mat& im,
const DetectionResult& result,
const std::vector<std::string>& labels,
float score_threshold = 0.0,
int line_size = 1, float font_size = 0.5f);
/** \brief Show the visualized results for classification models
*
* \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 result produced by model
* \param[in] top_k the length of return values, e.g., if topk==2, the result will include the 2 most possible class label for input image.
* \param[in] score_threshold threshold for top_k scores, the class will not be shown if the score is less than score_threshold
* \param[in] font_size font size
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisClassification(
const cv::Mat& im, const ClassifyResult& result, int top_k = 5,
float score_threshold = 0.0f, float font_size = 0.5f);
/** \brief Show the visualized results with custom labels for classification models
*
* \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 result produced by model
* \param[in] labels custom labels for user, the visualized result will show the corresponding custom labels
* \param[in] top_k the length of return values, e.g., if topk==2, the result will include the 2 most possible class label for input image.
* \param[in] score_threshold threshold for top_k scores, the class will not be shown if the score is less than score_threshold
* \param[in] font_size font size
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisClassification(
const cv::Mat& im, const ClassifyResult& result,
const std::vector<std::string>& labels, int top_k = 5,
float score_threshold = 0.0f, float font_size = 0.5f);
/** \brief Show the visualized results for face detection models
*
* \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 result produced by model
* \param[in] line_size line size for bounding boxes
* \param[in] font_size font size for text
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisFaceDetection(const cv::Mat& im,
const FaceDetectionResult& result,
int line_size = 1,
float font_size = 0.5f);
/** \brief Show the visualized results for face alignment models
*
* \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 result produced by model
* \param[in] line_size line size for circle point
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisFaceAlignment(const cv::Mat& im,
const FaceAlignmentResult& result,
int line_size = 1);
/** \brief Show the visualized results for segmentation models
*
* \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 result produced by model
* \param[in] weight transparent weight of visualized result image
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisSegmentation(const cv::Mat& im,
const SegmentationResult& result,
float weight = 0.5);
/** \brief Show the visualized results for matting models
*
* \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 result produced by model
* \param[in] remove_small_connected_area if remove_small_connected_area==true, the visualized result will not include the small connected areas
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisMatting(const cv::Mat& im,
const MattingResult& result,
bool remove_small_connected_area = false);
/** \brief Show the visualized results for Ocr models
*
* \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 result produced by model
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisOcr(const cv::Mat& im, const OCRResult& ocr_result);

FASTDEPLOY_DECL cv::Mat VisMOT(const cv::Mat& img, const MOTResult& results,
Expand All @@ -93,6 +168,13 @@ FASTDEPLOY_DECL cv::Mat SwapBackground(const cv::Mat& im,
const cv::Mat& background,
const SegmentationResult& result,
int background_label);
/** \brief Show the visualized results for key point detection models
*
* \param[in] im the input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format
* \param[in] results the result produced by model
* \param[in] conf_threshold threshold for result scores, the result will not be shown if the score is less than conf_threshold
* \return cv::Mat type stores the visualized results
*/
FASTDEPLOY_DECL cv::Mat VisKeypointDetection(const cv::Mat& im,
const KeyPointDetectionResult& results,
float conf_threshold = 0.5f);
Expand Down
52 changes: 52 additions & 0 deletions python/fastdeploy/vision/visualize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,64 @@ def vis_detection(im_data,
score_threshold=0.0,
line_size=1,
font_size=0.5):
"""Show the visualized results for detection models

:param im_data: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
:param det_result: the result produced by model
:param labels: (list of str) the visualized result will show the bounding box contain class label
:param score_threshold: (float) score_threshold threshold for result scores, the bounding box will not be shown if the score is less than score_threshold
:param line_size: (float) line_size line size for bounding boxes
:param font_size: (float) font_size font size for text
:return: (numpy.ndarray) image with visualized results
"""
return C.vision.vis_detection(im_data, det_result, labels, score_threshold,
line_size, font_size)


def vis_keypoint_detection(im_data, keypoint_det_result, conf_threshold=0.5):
"""Show the visualized results for keypoint detection models

:param im_data: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
:param keypoint_det_result: the result produced by model
:param conf_threshold: (float) conf_threshold threshold for result scores, the bounding box will not be shown if the score is less than conf_threshold
:return: (numpy.ndarray) image with visualized results
"""
return C.vision.Visualize.vis_keypoint_detection(
im_data, keypoint_det_result, conf_threshold)


def vis_face_detection(im_data, face_det_result, line_size=1, font_size=0.5):
"""Show the visualized results for face detection models

:param im_data: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
:param face_det_result: the result produced by model
:param line_size: (float) line_size line size for bounding boxes
:param font_size: (float) font_size font size for text
:return: (numpy.ndarray) image with visualized results
"""
return C.vision.vis_face_detection(im_data, face_det_result, line_size,
font_size)


def vis_face_alignment(im_data, face_align_result, line_size=1):
"""Show the visualized results for face alignment models

:param im_data: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
:param face_align_result: the result produced by model
:param line_size: (float)line_size line size for circle point
:return: (numpy.ndarray) image with visualized results
"""
return C.vision.vis_face_alignment(im_data, face_align_result, line_size)


def vis_segmentation(im_data, seg_result, weight=0.5):
"""Show the visualized results for segmentation models

:param im_data: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
:param seg_result: the result produced by model
:param weight: (float)transparent weight of visualized result image
:return: (numpy.ndarray) image with visualized results
"""
return C.vision.vis_segmentation(im_data, seg_result, weight)


Expand All @@ -57,6 +96,13 @@ def vis_matting_alpha(im_data,


def vis_matting(im_data, matting_result, remove_small_connected_area=False):
"""Show the visualized results for matting models

:param im_data: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
:param matting_result: the result produced by model
:param remove_small_connected_area: (bool) if remove_small_connected_area==True, the visualized result will not include the small connected areas
:return: (numpy.ndarray) image with visualized results
"""
return C.vision.vis_matting(im_data, matting_result,
remove_small_connected_area)

Expand Down Expand Up @@ -105,6 +151,12 @@ def swap_background(im_data,


def vis_ppocr(im_data, det_result):
"""Show the visualized results for ocr models

:param im_data: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
:param det_result: the result produced by model
:return: (numpy.ndarray) image with visualized results
"""
return C.vision.vis_ppocr(im_data, det_result)


Expand Down