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

发布于 2025-02-01 07:47:14 字数 1637 浏览 4 评论 0原文

这是的后续问题。 /a>。

我尝试使用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)

之后,我想将output_tensor转换为图像。

我已经引用了 and 与Paddlegan的超级分辨率在OpenVino文档上,但徒劳无功。

而且我还尝试使用image.fromarray将其转换。

错误总是在下面发生。

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

如何处理openvino.pyopenvino.tensor properly?

我的环境是Windows 11,带有OpenVino_2022.1.0.643版本。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莫言歌 2025-02-08 07:47:14

使用数据对象访问输出张量数据。

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)

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文