Browse Source

docs(mge): add some docs for cvt_color and GraphInference

GitOrigin-RevId: d78628bfcf
release-1.7
Megvii Engine Team 3 years ago
parent
commit
acd835d0df
2 changed files with 36 additions and 1 deletions
  1. +32
    -1
      imperative/python/megengine/functional/vision.py
  2. +4
    -0
      imperative/python/megengine/utils/comp_graph_tools.py

+ 32
- 1
imperative/python/megengine/functional/vision.py View File

@@ -44,6 +44,37 @@ def cvt_color(inp: Tensor, mode: str = ""):
Returns:
convert result.

Note:
There are different supported modes for different combinations of :attr:`~.Tensor.device` and :attr:`~.Tensor.dtype`.

x86/ARM:

float32:
"RGB2GRAY", "RGB2YUV", "YUV2RGB", "GRAY2RGB", "BGR2GRAY"

uint8:
"RGB2GRAY", "RGB2YUV", "YUV2RGB", "GRAY2RGB", "RGBA2RGB", "RGBA2BGR",
"RGBA2GRAY", "RGB2BGR", "BGR2GRAY", "BGR2RGB", "YUV2GRAY_NV21", "YUV2RGB_NV21",
"YUV2BGR_NV21", "YUV2GRAY_NV12", "YUV2RGB_NV12", "YUV2BGR_NV12", "YUV2GRAY_YV12",
"YUV2RGB_YV12", "YUV2BGR_YV12", "YUV2GRAY_YU12", "YUV2RGB_YU12", "YUV2BGR_YU12",
"YCrCb2RGB", "YCrCb2BGR", "BT601_YUV2RGB_NV21", "BT601_YUV2BGR_NV21", "BT601_YUV2RGB_NV12",
"BT601_YUV2BGR_NV12", "BT601_YUV2RGB_YV12", "BT601_YUV2BGR_YV12" ,"BT601_YUV2RGB_YU12",
"BT601_YUV2BGR_YU12"


CUDA:

float32:
"RGB2GRAY", "BGR2GRAY", "RGB2YUV", "YUV2RGB", "GRAY2RGB"

uint8:
"RGB2GRAY", "BGR2GRAY", "RGB2YUV", "YUV2RGB", "GRAY2RGB",
"YUV2GRAY_NV12", "YUV2GRAY_NV21", "YUV2GRAY_YU12"
"YUV2GRAY_YV12", "YUV2RGB_NV12", "YUV2RGB_NV21", "YUV2BGR_NV12"
"YUV2BGR_NV21", "YUV2RGB_YU12", "YUV2RGB_YV12", "YUV2BGR_YU12",
"YUV2BGR_YV12"


Examples:

.. testcode::
@@ -62,7 +93,7 @@ def cvt_color(inp: Tensor, mode: str = ""):

[[[[0.86555195]]]]
"""
mode = mode.upper()
mode = mode.upper() if "YCrCb" not in mode else mode
assert mode in builtin.CvtColor.Mode.__dict__, "unspport mode for cvt_color"
mode = getattr(builtin.CvtColor.Mode, mode)
assert isinstance(mode, builtin.CvtColor.Mode)


+ 4
- 0
imperative/python/megengine/utils/comp_graph_tools.py View File

@@ -480,6 +480,10 @@ class GraphInference:

Returns:
a dict {output_name: output_value}.

Note:
Note that the order of the Graph's input nodes may be different from the order of the origin traced function's arguments.
It is recommended to use ``inp_dict`` to provide input data by name.
"""
assert len(inp_args) <= len(
self._inp_dict


Loading…
Cancel
Save