google-coral / pycoral

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

KeyError: 'output_0' Pycoral issue on Raspberry Pi 4 #142

Open opc241 opened 3 months ago

opc241 commented 3 months ago

Hi,

the minimal code example:

from pycoral.adapters import detect
from pycoral.adapters import common
from pycoral.utils.edgetpu import make_interpreter
from PIL import Image

interpreter = make_interpreter('/home/pi/homecontrol/software/yolo-Weights/yolov8n_saved_model/yolov8n_full_integer_quant.tflite')
interpreter.allocate_tensors()

image = Image.open('/home/pi/homecontrol/software/yolo-Weights/yolov8n_saved_model/capture.png')
_, scale = common.set_resized_input(interpreter, image.size, lambda size: image.resize(size, Image.LANCZOS))

# Run inference
interpreter.invoke()

# Process detection results
detections = detect.get_objects(interpreter, scale)
for detection in detections:
    print(detection)

leads to the following error:

Traceback (most recent call last):
  File "/home/pi/homecontrol/software/__test.py", line 16, in <module>
    detections = detect.get_objects(interpreter, scale)
  File "/usr/lib/python3/dist-packages/pycoral/adapters/detect.py", line 210, in get_objects
    count = int(interpreter.tensor(signature['outputs']['output_0'])()[0])
KeyError: 'output_0'

Name: pycoral Version: 2.0.0

Name: tflite-runtime Version: 2.5.0.post1

Running on bullseye linux for Raspberry Pi