nicknochnack / TFODRPi

86 stars 71 forks source link

TypeError: only size-1 arrays can be converted to Python scalars #3

Open Rosskong opened 3 years ago

Rosskong commented 3 years ago

hello , guys, I have a problem . When I run the first program, it runs successfully.

it can detect and recognize the Hello gesture. But when I imported the tflite model like a blogger and successfully changed the label(Happy and Sad), I started running the code, and the code reported an error. The error is as follows:

ross@ross-KPL-W0X:~/桌面/Sentiment/TFODRPi$ python3 detect.py Traceback (most recent call last): File "detect.py", line 88, in main() File "detect.py", line 68, in main res = detect_objects(interpreter, img, 0.8) File "detect.py", line 45, in detect_objects count = int(get_output_tensor(interpreter, 3)) TypeError: only size-1 arrays can be converted to Python scalars @nicknochnack can you help me ?

Oh, by the way, I'm running on the Ubuntu system of the dual system on my computer, and you're running on raspberry pie. I don't know whether this will affect the program. However, I successfully ran the program to detect Hello, but there was an error in the program happy and sad.

Rosskong commented 3 years ago

Python 3.6.9

Linux version 5.4.0-53-generic (buildd@lgw01-amd64-046) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04))

59~18.04.1-Ubuntu SMP Wed Oct 21 12:14:56 UTC 2020

opencv 3.2.0

chenkang455 commented 3 years ago

Python 3.6.9

Linux version 5.4.0-53-generic (buildd@lgw01-amd64-046) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #59~18.04.1-Ubuntu SMP Wed Oct 21 12:14:56 UTC 2020

opencv 3.2.0

I met the same problem as yours. I successfully ran the detect.tflite on the github but when I changed it to my converted detect.tflite , the problem occurs , have you solved it?

chenkang455 commented 3 years ago

Python 3.6.9

Linux version 5.4.0-53-generic (buildd@lgw01-amd64-046) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #59~18.04.1-Ubuntu SMP Wed Oct 21 12:14:56 UTC 2020

opencv 3.2.0

I suspect this is caused by the version of our tensorflow or others , I have tried an official tensorlite model transfer code but there is an error again which frustrates me a lot.

chenkang455 commented 3 years ago

Python 3.6.9

Linux version 5.4.0-53-generic (buildd@lgw01-amd64-046) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #59~18.04.1-Ubuntu SMP Wed Oct 21 12:14:56 UTC 2020

opencv 3.2.0

Hello, Have you fixed your problem?

chenkang455 commented 3 years ago

I got it!!! I solved the problem!!!So unforgettable!!!

Rosskong commented 3 years ago

@chenkang455 How did you do that? what's wrong with the program? Can you tell me? I need your help .

chenkang455 commented 3 years ago

Consider changing the detect.py boxes =get_output_tensor(interpreter, 1) classes = get_output_tensor(interpreter, 3) scores = get_output_tensor(interpreter, 0)

count = int(get_output_tensor(interpreter, 2))

tuxmann commented 3 years ago

Chenkang455, Thank you so much. That worked for me after I changed the four lines you recommended. I had a problem when I tried to run detect.py with the thumbsup, thumbsdown, thankyou & livelong gestures.

boxes = get_output_tensor(interpreter, 1) classes = get_output_tensor(interpreter, 3) scores = get_output_tensor(interpreter, 0) count = int(get_output_tensor(interpreter, 2))

Nikhil-Mudgal commented 2 years ago

Thanks for this,I was stuck here for 2 days. Questioning on stack overflow and almost throwing my RPi on the wall. T_T ...you are a legend'