需要一个类似字节的对象,而不是“列表”

时间:2019-06-20 03:38:10

标签: tensorflow tensorrt

我正在尝试使用多张图片测试INT8 TnesroRT引擎。

批量大小为5。 由于图像尺寸为3x640x480 因此,阵列是为3,640,480张图像中的5张制作的,例如

images=[0 for x in range(921600*5)] 

然后将图像放置为

for i in range(1,6):  
       image = cv2.imread('CalibrationData/test/'+testfiles[index+i],cv2.IMREAD_COLOR)
       image = np.array(image, dtype=np.float32, order='C') 
       image=image.transpose([2, 0, 1])
       images[i-1*921600:i*921600-1]=image.flatten()

然后进行推断

with engine.create_execution_context() as context:
      fps_time = time.time()
      inputs, outputs, bindings, stream = common.allocate_buffers(engine)     
      inputs[0].host = images
      [outputs] = common.do_inference(context, bindings, inputs, outputs, stream, 1)

但是错误在于此推断行

[outputs] = common.do_inference(context, bindings, inputs, outputs, stream, 1)

TypeError: a bytes-like object is required, not 'list'

推理的格式应该是什么? 我对1张图片做了同样的事情。很好。

0 个答案:

没有答案