Amelia0911 / onnxruntime-for-yolov5

Using CPU to test model
31 stars 12 forks source link

cannot reshape array of size 692224 into shape (1,3,416,416) #2

Open AbinJilson opened 2 years ago

AbinJilson commented 2 years ago

when I was trying to run the model in my custom weights.I'm getting this error


  File "C:\Users\acer\.spyder-py3\metallic surface defect detection\3_onnx_cpu_detec.py", line 31, in detect
    img = img.reshape(1, 3, img_size[0], img_size[1])

ValueError: cannot reshape array of size 692224 into shape (1,3,416,416)
KaihongLi commented 1 year ago

when I was trying to run the model in my custom weights.I'm getting this error


  File "C:\Users\acer\.spyder-py3\metallic surface defect detection\3_onnx_cpu_detec.py", line 31, in detect
    img = img.reshape(1, 3, img_size[0], img_size[1])

ValueError: cannot reshape array of size 692224 into shape (1,3,416,416)

You need to preprocess the image and then to detect it because the image has four channels. You should convert RGBA into RGB. 692224 equals to 4164164(RGBA).