我加载模型应该是成功的,能够读出input name是img img_info img_shape这三个
但是在reshape之前发现所有的input_tensor的shape都是0,不知道是不是有问题,下面是input_tensor的定义:
input_tensor = predictor.get_input_tensor(input_names[0])
之后进行reshape就能形成正确的shape:
input_tensor.reshape([1, 3, 640, 640])
难道不是读取模型的时候就能知道shape吗?还是一定得自己手动reshape?不太懂其中的机制,希望能解答一下
我提出这个问题是因为报错了
['image', 'im_info', 'im_shape']
---------------------------------------------------------------------------
EnforceNotMet Traceback (most recent call last) in
39
40
---> 41 predictor.zero_copy_run()
42
43 # 获取输出
EnforceNotMet:
----------------------
Error Message Summary:
----------------------
Error: The start row index must be lesser than the end row index.
[Hint: Expected begin_idx < end_idx, but received begin_idx:0 >= end_idx:0.] at (/paddle/paddle/fluid/framework/tensor.cc:83)
[operator < distribute_fpn_proposals > error]
感觉出错的源代码:
input_tensor = predictor.get_input_tensor(input_names[0])
print(input_tensor.shape())
input_tensor.reshape([1, 3, 640, 640])
print(input_tensor.shape())
input_tensor.copy_from_cpu(fake_input)
input_tensor = predictor.get_input_tensor(input_names[1]) ##这个是输入img
print(input_tensor.shape())
input_tensor.reshape([1])
input_tensor.copy_from_cpu(np.array([0]).astype('float32'))
input_tensor = predictor.get_input_tensor(input_names[2]) ##这个是输入img_info
print(input_tensor.shape())
input_tensor.reshape([1]) ##这个是输入img_shape
input_tensor.copy_from_cpu(np.array([1, 3, 640, 640]).astype('float32'))