简体   繁体   English

OpenVINO API 2.0 输出张量无法转换为图像

[英]OpenVINO API 2.0 output tensor cannot convert to image

This is the follow-up question from here .这是here的后续问题。

I try to use YOLOv4 model to do the inference with OpenVINO API 2.0.我尝试使用 YOLOv4 模型通过 OpenVINO API 2.0 进行推理。

dcm_file = "1037973"
ds = dcmread(dcm_file, force=True)
ds.PixelRepresentation = 0
ds_arr = ds.pixel_array
        
core = ov.Core()
model = core.read_model(model="frozen_darknet_yolov4_model.xml")
model.reshape([ds_arr.shape[0], ds_arr.shape[1], ds_arr.shape[2], 3])
compiled_model = core.compile_model(model, "CPU")
infer_request = compiled_model.create_infer_request()
input_tensor = ov.Tensor(array=ds_arr, shared_memory=True)
#infer_request.set_input_tensor(input_tensor)
infer_request.start_async()
infer_request.wait()
output_tensor1 = infer_request.get_output_tensor(0)
output_tensor2 = infer_request.get_output_tensor(1)
output_tensor3 = infer_request.get_output_tensor(2)

Afterwards, I want to convert the output_tensor to image.之后,我想将 output_tensor 转换为图像。

I have referenced Single Image Super Resolution and Super Resolution with PaddleGAN on OpenVINO docs but in vain.我在 OpenVINO 文档上引用了单图像超分辨率PaddleGAN 超分辨率,但徒劳无功。

And I also try to use Image.fromarray to convert it.而且我也尝试使用Image.fromarray来转换它。

The error always happens below.错误总是发生在下面。

AttributeError: 'openvino.pyopenvino.Tensor' object has no attribute xxxxx

How can I deal with openvino.pyopenvino.Tensor propertly?如何正确处理openvino.pyopenvino.Tensor

My environment is Windows 11 with openvino_2022.1.0.643 version.我的环境是带有 openvino_2022.1.0.643 版本的 Windows 11。

Use the data attribute of the Tensor object to access the output tensor data.使用张量对象的数据属性来访问输出张量数据。

output_tensor1 = infer_request.get_output_tensor(0)
output_tensor2 = infer_request.get_output_tensor(1)
output_tensor3 = infer_request.get_output_tensor(2)
output_buffer1 = output_tensor1.data
output_buffer2 = output_tensor2.data
output_buffer3 = output_tensor3.data
print(output_buffer1)
print(output_buffer2)
print(output_buffer3)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM