tensor_to_image
Function Usage
Converts the Tensor class on the host to the Image class on the host, or converts the Tensor class on the device to the Image class on the DVPP.
Only Atlas inference product and Atlas 800I A2 inference product support this API.
During the conversion, the width of Image is 16-pixel aligned upwards, and the height of Image is 2-pixel aligned upwards. The converted Image class object has a padding region.
The attributes width and height display the padded width and height of the converted Image class, and the attributes original_width and original_height display the original width and height of the image.
Example:
- Assume the Tensor class object corresponds to an image with a width of 500 and a height of 499. After padding, the attributes original_width and original_height of the Image class object display the original width and height of 500 and 499, while width and height reflect the padded width and height of 512 and 500.
- If the width and height of the image corresponding to the Tensor class object are 512 and 500, the Image object does not need to be padded after conversion. That is, both the original and aligned width and height of the Image object are 512 and 500.
Prototype
1 | tensor_to_image(tensor: Tensor, imageFormat: image_format) |
Parameters
Parameter |
Type |
Description |
|---|---|---|
tensor |
Tensor |
Input tensor, which must meet the following requirements:
|
imageFormat |
image_format enumeration |
Specified image format, which must match the image format corresponding to the inputTensor data. |
Response Parameters
Returns the corresponding Image object.