[Python] Error: Invalid shape is given with model ssdlite_mobilenet_v3_large
Created by: hieunm1821
- OS: Ubuntu 18.04
- Python version: 3.6.9
- Paddlelite: 2.6.1
I have downloaded PaddleLite Model from https://paddlemodels.bj.bcebos.com/object_detection/mobile_models/lite/ssdlite_mobilenet_v3_large.tar
My python code for implementing
from paddlelite.lite import *
import numpy as np
import cv2
config = MobileConfig()
config.set_model_from_file('./ssdlite_mobilenet_v3_large/ssdlite_mobilenet_v3_large.nb')
predictor = create_paddle_predictor(config)
def read_img(im_path, resize_h, resize_w):
im = cv2.imread(im_path).astype('float32')
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
h, w, _ = im.shape
im_scale_x = resize_h / float(w)
im_scale_y = resize_w / float(h)
out_img = cv2.resize(im, None, None, fx=im_scale_x, fy=im_scale_y, interpolation=cv2.INTER_CUBIC)
mean = np.array([0.485, 0.456, 0.406]).reshape((1, 1, -1))
std = np.array([0.229, 0.224, 0.225]).reshape((1, 1, -1))
out_img = (out_img / 255.0 - mean) / std
out_img = out_img.transpose((2, 0, 1))
return out_img
input_tensor = predictor.get_input(0);
height, width = 320, 320
input_tensor.resize([1, 3, height, width])
data = read_img('./kite.jpg', height, width).flatten()
input_tensor.set_float_data(data)
predictor.run()
output_tensor = predictor.get_output(0);
print (output_tensor.shape())
I take the input size 320,320 from https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.3/configs/mobile/README_en.md Error:
Check failed: output_dims[unk_dim_idx] * capacity == -input_size (-4372 vs. -4374) Invalid shape is given.