我正在使用一个对象检测模型,我引用这个链接来拟合我的图像模型,从而包括方法set_input_tensor"从这里
现在当我执行这行代码
def set_input_tensor(interpreter, image):
tensor_index = interpreter.get_input_details()[0]['index']
input_tensor = interpreter.tensor(tensor_index)()[0]
input_tensor[:, :] = image
我得到这行错误
TypeError: __array__() takes 1 positional argument but 2 were given
图片形状:(1,320,320,3)
Shape of input_tensor: (320,320,3)
所以我试着把代码改成
input_tensor = image[0, :, :, :]
因为我没有实现类,我没有使用self
参数
请帮
可以,下面是代码:-
interpreter = tf.lite.Interpreter(model_path="model_path")
interpreter.allocate_tensors()
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
input_data = image
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
boxes = interpreter.get_tensor(output_details[0]['index'])
labels =interpreter.get_tensor(output_details[1]['index'])
scores =interpreter.get_tensor(output_details[2]['index'])
num =interpreter.get_tensor(output_details[3]['index'])