I would like to do a train using YOLOv3 for multiple classes. I found a code for single class. And I tried to do for multiple classes, and I failed. So this is the code:
import glob
import os
import re
txt_file_paths = glob.glob(r"data/obj/*.txt")
for i, file_path in enumerate(txt_file_paths):
# get image size
with open(file_path, "r") as f_o:
lines = f_o.readlines()
text_converted = []
for line in lines:
print(line)
numbers = re.findall("[0-9.]+", line)
print(numbers)
if numbers:
# Define coordinates
text = "{} {} {} {} {}".format(0, numbers[1], numbers[2], numbers[3], numbers[4])
text_converted.append(text)
print(i, file_path)
print(text)
# Write file
with open(file_path, 'w') as fp:
for item in text_converted:
fp.writelines("%s
" % item)
Can anyone help to adapt to multiple classes?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…