วิธีที่ถูกต้องในการรับเอาต์พุตเทนเซอร์สําหรับรุ่นที่มีเอาต์พุตมากกว่าหนึ่งเอาต์พุต
- มีเทนเซอร์เอาต์พุตสําหรับแบบจําลองแบบกําหนดเองที่มีเอาต์พุตสามเอาต์พุต:
จากคอร์นําเข้า openvino.runtime
คอร์ = คอร์ ()
รุ่น = core.read_model (model="model.xml")
compiled_model = core.compile_model(รุ่น , "CPU")
infer_request = compiled_model.create_infer_request()
infer_request.start_async()
infer_request.wait()
เอาต์พุต = infer_request.get_output_tensor()
พิมพ์ (เอาต์พุต) - ได้รับข้อผิดพลาด:
RuntimeError: ต้องเรียก get_output_tensor() บนฟังก์ชันด้วยพารามิเตอร์เดียวเท่านั้น
วิธีการ ov:InferRequest::get_output_tensor ที่ไม่มีอาร์กิวเมนต์สามารถใช้ได้สําหรับรุ่นที่มีเอาต์พุตเดียวเท่านั้น
- ใช้ ov:InferRequest::get_output_tensor เมธอดที่มีอาร์กิวเมนต์ (ดัชนี: int) สําหรับรุ่นที่มีเอาต์พุตมากกว่าหนึ่งเอาต์พุต
output1 = infer_request.get_output_tensor(0)
output2 = infer_request.get_output_tensor(1)
output3 = infer_request.get_output_tensor(2) - ใช้แอตทริบิวต์ข้อมูลของวัตถุ Tensor เพื่อเข้าถึงข้อมูลเทนเซอร์เอาต์พุตสําหรับผลลัพธ์การอนุมาน
output_buffer1 = output2.data
output_buffer2 = output2.data
output_buffer3 = output3.data
print(output_buffer1)
print(output_buffer2)
print(output_buffer3)