YOLO V5 custom object detection : csv output

Issue

I managed to train the YOLO V5 model on my customed data and I’m having great results. I was just wondering how I could export the bonding boxes in a csv or txt file in which I’d have the coordinates and the score of prediction.
I’ve read that I’ll need to change the detect.py file but I just don’t know how.

Solution

in the line 159 at https://github.com/ultralytics/yolov5/blob/master/detect.py

there is an argument to save txt files, usage shoud be something like:

python detect.py --weights yolov5s.pt --save-txt det.txt

the other option is to:

import pandas as pd
detections = []

...
detections.append(line)

... 
#condition to save
df = pd.DataFrame.from_dict( {'detections': detections})
df.to_csv("detections.csv")

Answered By – Guinther Kovalski

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published