我正在尝试在部署在TensorFlow Serving上的yolov3模型上进行多张图像的批次推理。我可以成功地对单张图像进行推理,但当我传递多个批次时,我会遇到如下错误:
InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.INVALID_ARGUMENT details = "Can not squeeze dim[0], expected a dimension of 1, got 6 [[{{node yolov3/yolo_nms/Squeeze}}]]" debug_error_string = "{"created":"@1623673733.762863602","description":"Error received from peer ipv4:127.0.0.1:8500","file":"src/core/lib/surface/call.cc","file_line":1061,"grpc_message":"Can not squeeze dim[0], expected a dimension of 1, got 6\n\t [[{{node yolov3/yolo_nms/Squeeze}}]]","grpc_status":3}"
保存的模型签名如下所示
The given SavedModel SignatureDef contains the following input(s): inputs['input'] tensor_info: dtype: DT_FLOAT shape: (-1, -1, -1, 3) name: serving_default_input:0
我传递图像的方式如下
load_imgs = load_images_from_dir("/content/yolov3-tf2/image_data/",416,6)print(load_imgs.shape)(6, 416, 416, 3)
我遇到了上述错误。我在开发模型时使用了这个存储库中的代码
“Can not squeeze dim[0], expected a dimension of 1, got 6[[{{node yolov3/yolo_nms/Squeeze}}]]”
导致这个错误的代码行在这里链接。通常来说,我了解到我可以将多张图像作为一个批次传递给模型,但这个代码却给我带来了错误。我做错了什么?
回答:
这是因为模型被定义为只能对批次大小为1进行推理