EdjeElectronics / TensorFlow-Lite-Object-Detection-on-Android-and-Raspberry-Pi

A tutorial showing how to train, convert, and run TensorFlow Lite object detection models on Android devices, the Raspberry Pi, and more!
Apache License 2.0
1.51k stars 683 forks source link

TypeError: object of type 'numpy.float32' has no len() #159

Open Darrenll opened 1 year ago

Darrenll commented 1 year ago

Line 177 has a type error. The example in your 19 year video ran smoothly, but I trained a new one to encounter this error. pi@raspberrypi:~ $ cd tflite1/ pi@raspberrypi:~/tflite1 $ source tflite1-env/bin/activate (tflite1-env) pi@raspberrypi:~/tflite1 $ python3 TFLite_detection_webcam.py --modeldir=custom_model_lite Traceback (most recent call last): File "TFLite_detection_webcam.py", line 177, in for i in range(len(scores)): TypeError: object of type 'numpy.float32' has no len() ^CException ignored in: <module 'threading' from '/usr/lib/python3.7/threading.py'> Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 1281, in _shutdown t.join() File "/usr/lib/python3.7/threading.py", line 1032, in join self._wait_for_tstate_lock() File "/usr/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock elif lock.acquire(block, timeout): KeyboardInterrupt May I ask if there is a problem with my training set or with the version? Please help

EdjeElectronics commented 1 year ago

Which model are you using? I've seen that error before when trying to train a different model than ssd-mobilenet-v2.

Darrenll commented 1 year ago

Which model are you using? I've seen that error before when trying to train a different model than ssd-mobilenet-v2.

It is indeed a version issue, and I have solved the problem using your code from last year's version of TF. Thank you very much!

Gottmituns2022 commented 1 year ago

Hello everyone. I used the ssd-mobilnet-v2 version, teaching her on this collab notebook https://colab.research.google.com/github/EdjeElectronics/TensorFlow-Lite-Object-Detection-on-Android-and-Raspberry-Pi/blob/master/Train_TFLite2_Object_Detction_Model.ipynb?authuser=2#scrollTo=6t8CMarqBqP9 and I got the same error as you. Can you tell me how to fix it?