megengine.functional.nn.cvt_color

cvt_color(inp, mode='')[源代码]

Convert images from one format to another

参数
  • inp (Tensor) – input images.

  • mode (str) – format mode.

返回

convert result.

实际案例

import numpy as np
import megengine as mge
import megengine.functional as F

x = mge.tensor(np.array([[[[-0.58675045, 1.7526233, 0.10702174]]]]).astype(np.float32))
y = F.vision.cvt_color(x, mode="RGB2GRAY")
print(y.numpy())

Outputs:

[[[[0.86555195]]]]