How do i use detection from yolov4 for drawing bounding box?

Viewed 671
Traceback (most recent call last):
  File "D:\vehicle detection and counting\FinalProject\tensorflow-yolov4-tflite-master\run.py", line 8, in <module>
    d.Counting(video_path='videos/hw.mp4',output_path='output/hw.mp4',skip_frames=20,confidence_tresh=0.27)     
  File "D:\vehicle detection and counting\FinalProject\tensorflow-yolov4-tflite-master\Count.py", line 154, in Counting
    confidence = scores[class_id]
IndexError: index 1329146 is out of bounds for axis 0 with size 71

The code segment throwing the error is

image_data = image_data[np.newaxis, ...].astype(np.float32)
pred_bbox = self.model.predict(image_data)


for out in pred_bbox:
    for detection in out:
        # print(len(detection))                     
        scores = detection[5:]
        print()
        class_id = np.argmax(scores)
        print(class_id)
        confidence = scores[class_id]
        print(confidence)

How do I get bbox and class from the prediction ?

the link I used to build my model is https://github.com/hunglc007/tensorflow-yolov4-tflite and weights are used from darknet

0 Answers
Related