Skip to content

[Doc] Update PaddleSeg comments #785

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 18 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions docs/api_docs/python/semantic_segmentation.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
# Semantic Segmentation(语义分割)


## fastdeploy.vision.segmentation.PaddleSegPreprocessor

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

## fastdeploy.vision.segmentation.PaddleSegModel

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

## fastdeploy.vision.segmentation.PaddleSegPostprocessor

```{eval-rst}
.. autoclass:: fastdeploy.vision.segmentation.PaddleSegPostprocessor
:members:
:inherited-members:
```
3 changes: 2 additions & 1 deletion fastdeploy/vision/segmentation/ppseg/postprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
namespace fastdeploy {
namespace vision {
namespace segmentation {

/*! @brief Postprocessor object for PaddleSeg serials model.
*/
class FASTDEPLOY_DECL PaddleSegPostprocessor {
public:
/** \brief Create a postprocessor instance for PaddleSeg serials model
Expand Down
3 changes: 2 additions & 1 deletion fastdeploy/vision/segmentation/ppseg/preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
namespace fastdeploy {
namespace vision {
namespace segmentation {

/*! @brief Preprocessor object for PaddleSeg serials model.
*/
class FASTDEPLOY_DECL PaddleSegPreprocessor {
public:
/** \brief Create a preprocessor instance for PaddleSeg serials model
Expand Down
21 changes: 14 additions & 7 deletions python/fastdeploy/vision/segmentation/ppseg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,38 +50,43 @@ def predict(self, image):
return self._model.predict(image)

def batch_predict(self, image_list):
"""Predict the segmentation results for a batch of input image
"""Predict the segmentation results for a batch of input images

:param image_list: (list of numpy.ndarray) The input image list, each element is a 3-D array with layout HWC, BGR format
:return list of SegmentationResult
:return: list of SegmentationResult
"""
return self._model.batch_predict(image_list)

@property
def preprocessor(self):
"""Get PaddleSegPreprocessor object of the loaded model
:return PaddleSegPreprocessor

:return: PaddleSegPreprocessor
"""
return self._model.preprocessor

@property
def postprocessor(self):
"""Get PaddleSegPostprocessor object of the loaded model
:return PaddleSegPostprocessor

:return: PaddleSegPostprocessor
"""
return self._model.postprocessor


class PaddleSegPreprocessor:
def __init__(self, config_file):
"""Create a preprocessor for PaddleSegModel from configuration file

:param config_file: (str)Path of configuration file, e.g ppliteseg/deploy.yaml
"""
self._preprocessor = C.vision.segmentation.PaddleSegPreprocessor(
config_file)

def run(self, input_ims):
"""Preprocess input images for PaddleSegModel
:param: input_ims: (list of numpy.ndarray)The input image

:param input_ims: (list of numpy.ndarray)The input image
:return: list of FDTensor
"""
return self._preprocessor.run(input_ims)
Expand Down Expand Up @@ -114,15 +119,17 @@ def is_vertical_screen(self, value):
class PaddleSegPostprocessor:
def __init__(self, config_file):
"""Create a postprocessor for PaddleSegModel from configuration file

:param config_file: (str)Path of configuration file, e.g ppliteseg/deploy.yaml
"""
self._postprocessor = C.vision.segmentation.PaddleSegPostprocessor(
config_file)

def run(self, runtime_results, imgs_info):
"""Postprocess the runtime results for PaddleSegModel
:param: runtime_results: (list of FDTensor)The output FDTensor results from runtime
:param: imgs_info: The original input images shape info map, key is "shape_info", value is [[image_height, image_width]]

:param runtime_results: (list of FDTensor)The output FDTensor results from runtime
:param imgs_info: The original input images shape info map, key is "shape_info", value is [[image_height, image_width]]
:return: list of SegmentationResult(If the runtime_results is predict by batched samples, the length of this list equals to the batch size)
"""
return self._postprocessor.run(runtime_results, imgs_info)
Expand Down