This is the follow-up question from here.
I try to use YOLOv4 model to do the inference with 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.
I have referenced Single Image Super Resolution and Super Resolution with PaddleGAN on OpenVINO docs but in vain.
And I also try to use Image.fromarray
to convert it.
The error always happens below.
AttributeError: 'openvino.pyopenvino.Tensor' object has no attribute xxxxx
How can I deal with openvino.pyopenvino.Tensor
propertly?
My environment is Windows 11 with openvino_2022.1.0.643 version.
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)