google-coral / pycoral

Python API for ML inferencing and transfer-learning on Coral devices
https://coral.ai
Apache License 2.0
359 stars 146 forks source link

Image with 640x480 resolution breaks the Example in Detect_Image.py #14

Closed mitchross closed 3 years ago

mitchross commented 3 years ago
 python3 examples/detect_image.py   --model test_data/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite   --labels test_data/coco_labels.txt   --input test_data/bear480.png   --output ${HOME}/bear480_processed.png
Traceback (most recent call last):
  File "examples/detect_image.py", line 112, in <module>
    main()
  File "examples/detect_image.py", line 79, in main
    _, scale = common.set_resized_input(
  File "/usr/lib/python3/dist-packages/pycoral/adapters/common.py", line 99, in set_resized_input
    tensor[:h, :w] = np.reshape(result, (h, w, channel))
  File "<__array_function__ internals>", line 5, in reshape
  File "/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py", line 301, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py", line 58, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py", line 47, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: cannot reshape array of size 270000 into shape (225,300,3)

Test Data

bear480

Namburger commented 3 years ago

@mitchross that's odd that it is trying to reshape it to (225, 300, 3) when the model is (300, 300, 3). If the picture you posted the original picture with full size (I see the picture here is only 397x297)? If not, could you attach it here?

mitchross commented 3 years ago

@Namburger I've zipped it up. Lets try that. should be 640x480. bear480.zip

Namburger commented 3 years ago

Thanks for reporting, looks like it is a reproducible bug

ghbn8 commented 2 years ago

How was this resolved? This appears to still be an issue.

hjonnala commented 2 years ago

@ghbn8 Please add the below line here to run the demo with the image mentioned at: https://github.com/google-coral/pycoral/issues/14#issuecomment-775176844. Thanks!

image = image.convert('RGB')