e96031413 / TensorFlow-Lite-Object-Detection-and-Image-Classification-on-Jetson-Nano

Live Object Detection and Image Classification System (PiCamera+OpenCV+TensorFlow Lite+Firebase) on Jetson Nano
15 stars 1 forks source link

IndexError: list index out of range #1

Closed hzhoanglee closed 3 years ago

hzhoanglee commented 3 years ago

I am having an issue with model trained by Teachable machine. The sample model worked fine but when I load my own model and run the app, I got this issue: IndexError: list index out of range Can you help me please, thanks.

e96031413 commented 3 years ago

Please paste your entire code here and tell me which line occurs this error so that I can help you

by the way, what's the filetype of model trained by Teachable machine?

hzhoanglee commented 3 years ago

I got this error:

Traceback (most recent call last):
  File "/home/control/Downloads/TensorFlow-Lite-Object-Detection-and-Image-Classification-on-Jetson-Nano-master (1)/object_detection_and_image_classification.py", line 160, in <module>
    classes = interpreter.get_tensor(output_details[1]['index'])[0] # Class index of detected objects
IndexError: list index out of range
GST_ARGUS: Cleaning up

I also attached the model trained by Teachable Machine below. Can you guide me to a guide where I can train my own model or convert it? Thanks. converted_tflite.zip

e96031413 commented 3 years ago

I think you should change your labels.txt from

0 Haylou
1 AirPods
2 TicC2

to

Haylou
AirPods
TicC2

and be sure to use code editor instead of Microsoft Notepad due to the encoding problem.

Then try execute the code again, and see if it works.

hzhoanglee commented 3 years ago

Tried that but same error occurred. I think it the issue of compatibility. May I ask that did you trained your model? File "object_detection_and_image_classification.py", line 160, in <module> classes = interpreter.get_tensor(output_details[1]['index'])[0] # Class index of detected objects IndexError: list index out of range GST_ARGUS: Cleaning up

e96031413 commented 3 years ago

Tried that but same error occurred. I think it the issue of compatibility. May I ask that did you trained your model? File "object_detection_and_image_classification.py", line 160, in <module> classes = interpreter.get_tensor(output_details[1]['index'])[0] # Class index of detected objects IndexError: list index out of range GST_ARGUS: Cleaning up

I trained my model from GoogleAutoML instead of TeachableMachine

I think you could change the following code from

innterpreter.get_tensor(output_details[1]['index'])[0]

to

innterpreter.get_tensor(output_details[0]['index'])[0]

and see if it works

hzhoanglee commented 3 years ago

Re-Trained by Google AutoML from Google Cloud Platform, everything works flawlessly.