From acd835d0df0b36e557db17dd006654eb9bd72d38 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Tue, 23 Nov 2021 20:48:12 +0800 Subject: [PATCH] docs(mge): add some docs for cvt_color and GraphInference GitOrigin-RevId: d78628bfcf34d34dd522c9c6546c98c50ccb2bda --- imperative/python/megengine/functional/vision.py | 33 +++++++++++++++++++++- .../python/megengine/utils/comp_graph_tools.py | 4 +++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/imperative/python/megengine/functional/vision.py b/imperative/python/megengine/functional/vision.py index 03169950..7ab6bf24 100644 --- a/imperative/python/megengine/functional/vision.py +++ b/imperative/python/megengine/functional/vision.py @@ -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) diff --git a/imperative/python/megengine/utils/comp_graph_tools.py b/imperative/python/megengine/utils/comp_graph_tools.py index 9b5898c3..521c61db 100644 --- a/imperative/python/megengine/utils/comp_graph_tools.py +++ b/imperative/python/megengine/utils/comp_graph_tools.py @@ -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