Skip to content

Commit

Permalink
[Doc] add vision processor python api doc (PaddlePaddle#1655)
Browse files Browse the repository at this point in the history
* add vision processor python api doc

* fix reviewed problem

* fix reviewed problem
  • Loading branch information
GodIsBoom authored Mar 21, 2023
1 parent 2ff7b10 commit 0343deb
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 39 deletions.
97 changes: 97 additions & 0 deletions docs/api_docs/python/vision_processor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Vision Processor(多硬件图像处理库)

## fastdeploy.vision.common.manager.PyProcessorManager

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.manager.PyProcessorManager
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.Processor

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.Processor
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.ResizeByShort

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.ResizeByShort
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.Resize

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.Resize
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.CenterCrop

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.CenterCrop
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.Cast

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.Cast
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.HWC2CHW

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.HWC2CHW
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.Normalize

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.Normalize
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.NormalizeAndPermute

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.NormalizeAndPermute
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.Pad

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.Pad
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.PadToSize

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.PadToSize
:members:
:inherited-members:
```

## fastdeploy.vision.common.processors.StridePad

```{eval-rst}
.. autoclass:: fastdeploy.vision.common.processors.StridePad
:members:
:inherited-members:
```
73 changes: 34 additions & 39 deletions python/fastdeploy/vision/common/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self):
def __call__(self, mat):
"""call for processing input.
:param mat: the input data FDMat or FDMatBatch.
:param mat: The input data FDMat or FDMatBatch.
"""
self.processor(mat)

Expand All @@ -18,10 +18,10 @@ class ResizeByShort(Processor):
def __init__(self, target_size: int, interp=1, use_scale=True, max_hw=[]):
"""Create a ResizeByShort operation with the given parameters.
:param target_size: the target short size to resize the image
:param interp: optionally, the interpolation mode for resizing image
:param use_scale: optionally, whether to scale image
:param max_hw: max spatial size which is used by ResizeByShort
:param target_size: The target short size to resize the image
:param interp: Optionally, the interpolation mode for resizing image
:param use_scale: Optionally, whether to scale image
:param max_hw: Max spatial size which is used by ResizeByShort
"""
self.processor = C.vision.processors.ResizeByShort(target_size, interp,
use_scale, max_hw)
Expand All @@ -31,8 +31,8 @@ class CenterCrop(Processor):
def __init__(self, width, height):
"""Create a CenterCrop operation with the given parameters.
:param width: desired width of the cropped image
:param height: desired height of the cropped image
:param width: Desired width of the cropped image
:param height: Desired height of the cropped image
"""
self.processor = C.vision.processors.CenterCrop(width, height)

Expand All @@ -41,10 +41,10 @@ class Pad(Processor):
def __init__(self, top: int, bottom: int, left: int, right: int, value=[]):
"""Create a Pad operation with the given parameters.
:param top: the top padding
:param bottom: the bottom padding
:param left: the left padding
:param right: the right padding
:param top: The top padding
:param bottom: The bottom padding
:param left: The left padding
:param right: The right padding
:param value: the value that is used to pad on the input image
"""
self.processor = C.vision.processors.Pad(top, bottom, left, right,
Expand All @@ -61,11 +61,11 @@ def __init__(self,
swap_rb=False):
"""Creae a Normalize and a Permute operation with the given parameters.
:param mean A list containing the mean of each channel
:param std A list containing the standard deviation of each channel
:param is_scale Specifies if the image are being scaled or not
:param min A list containing the minimum value of each channel
:param max A list containing the maximum value of each channel
:param mean: A list containing the mean of each channel
:param std: A list containing the standard deviation of each channel
:param is_scale: Specifies if the image are being scaled or not
:param min: A list containing the minimum value of each channel
:param max: A list containing the maximum value of each channel
"""
self.processor = C.vision.processors.NormalizeAndPermute(
mean, std, is_scale, min, max, swap_rb)
Expand All @@ -75,7 +75,7 @@ class Cast(Processor):
def __init__(self, dtype="float"):
"""Creat a new cast opereaton with given dtype
:param dtype dtype of the output
:param dtype: Target dtype of the output
"""
self.processor = C.vision.processors.Cast(dtype)

Expand All @@ -90,20 +90,15 @@ def __init__(self):


class Normalize(Processor):
def __init__(self,
mean=[],
std=[],
is_scale=True,
min=[],
max=[],
def __init__(self, mean, std, is_scale=True, min=[], max=[],
swap_rb=False):
"""Creat a new normalize opereator with given paremeters.
:param mean A list containing the mean of each channel
:param std A list containing the standard deviation of each channel
:param is_scale Specifies if the image are being scaled or not
:param min A list containing the minimum value of each channel
:param max A list containing the maximum value of each channel
:param mean: A list containing the mean of each channel
:param std: A list containing the standard deviation of each channel
:param is_scale: Specifies if the image are being scaled or not
:param min: A list containing the minimum value of each channel
:param max: A list containing the maximum value of each channel
"""
self.processor = C.vision.processors.Normalize(mean, std, is_scale,
min, max, swap_rb)
Expand All @@ -113,9 +108,9 @@ class PadToSize(Processor):
def __init__(self, width, height, value=[]):
"""Create a new PadToSize opereator with given parameters.
:param width Desired width of the output image
:param height Desired height of the output image
:param value values to pad with
:param width: Desired width of the output image
:param height: Desired height of the output image
:param value: Values to pad with
"""
self.processor = C.vision.processors.PadToSize(width, height, value)

Expand All @@ -130,12 +125,12 @@ def __init__(self,
use_scale=False):
"""Create a Resize operation with the given parameters.
:param width Desired width of the output image
:param height Desired height of the output image
:param scale_w Scales the width in x-direction
:param scale_h Scales the height in y-direction
:param interp: optionally, the interpolation mode for resizing image
:param use_scale: optionally, whether to scale image
:param width: Desired width of the output image
:param height: Desired height of the output image
:param scale_w: Scales the width in x-direction
:param scale_h: Scales the height in y-direction
:param interp: Optionally, the interpolation mode for resizing image
:param use_scale: Optionally, whether to scale image
"""
self.processor = C.vision.processors.Resize(width, height, scale_w,
scale_h, interp, use_scale)
Expand All @@ -145,7 +140,7 @@ class StridePad(Processor):
def __init__(self, stride, value=[]):
"""Create a StridePad processor with given parameters.
:param stride Stride of the processor
:param value values to pad with
:param stride: Stride of the processor
:param value: Values to pad with
"""
self.processor = C.vision.processors.StridePad(stride, value)

0 comments on commit 0343deb

Please sign in to comment.