hhk7734 / tensorflow-yolov4

YOLOv4 Implemented in Tensorflow 2.
MIT License
136 stars 75 forks source link

range(3) causes index out of range #12

Closed RealHandy closed 4 years ago

RealHandy commented 4 years ago

Hi -- thanks so much for making this package, it's great.

I made a lite + tiny test:

yolo = YOLOv4(tiny=True)

yolo.classes = "coco.names"

yolo.make_model()
yolo.load_weights("/users/andy/downloads/yolov4-tiny.weights", weights_type="yolo")

yolo.save_as_tflite("yolov4-tiny.tflite")
from yolov4.tflite import YOLOv4

yolo = YOLOv4()

yolo.classes = "coco.names"

yolo.load_tflite("yolov4-tiny.tflite")
yolo.inference(media_path="/users/andy/downloads/vtest.avi", is_image=False)

When I ran it, I got two list index out of range errors in tflite/__init__.py.

I'm not sure if my fix is valid for all cases, so I didn't make a PR,but I made these changes to __init__.py, and then the lite + tiny test ran properly.

At line 72, i changed: self.output_index = [output_details[i]["index"] for i in range(3)] to: self.output_index = [output_details[i]["index"] for i in range(len(output_details))]

At line 141, I changed: self.interpreter.get_tensor(self.output_index[i]) for i in range(3) to: self.interpreter.get_tensor(self.output_index[i]) for i in range(len(self.output_index))

hhk7734 commented 4 years ago

Good!! :+1: If you send me a PR, I will do some tests and reflect them.

hhk7734 commented 4 years ago

closed by #13