edgeyolo
edgeyolo copied to clipboard
what training input formats are supported?
Hello. Very interesting. Do you support other training input formats apart from Coco? for example the text-based format used in other YOLO variants (e.g. yolov5)?
Not yet, but YOLO format is similar to Visdrone formats(both load labels from txt), and its dataloader locates in path edgeyolo/data/datasets/visdrone.py, I think just modify the following function and then you can use datasets with yolo format. You can have a try.
class VisDroneDataset(Dataset):
def get_anno_by_name(self, name):
msg = {
"image": os.path.join(self.train_dir, f"{os.path.basename(name)[:-4]}.{self.suffix}"),
"annotations": []
}
num_labels = 0
with open(name, "r", encoding="utf8") as f:
has_anno = False
for line in f.read().split("\n"):
line = line.replace(",", " ").split()
if len(line) == 8:
x1, y1, w, h = [float(k) for k in line[:4]]
x2, y2 = x1 + w, y1 + h
score = int(line[4])
if score == 0:
continue
class_id = int(line[5])
if class_id == 0 or class_id > len(self.names):
# id=0: ignore regions id=-1: others
continue
class_id -= 1
num_labels += 1
msg["annotations"].append([x1, y1, x2, y2, class_id]) # xywh
if not self.is_train:
if not has_anno:
self.coco_data.add_image(
image_id=self.idx,
file_name=os.path.basename(msg["image"]),
width=4000,
height=4000,
)
has_anno = True
self.coco_data.add_annotation(
image_id=self.idx,
anno_id=self.num_annos,
category_id=class_id,
bbox=[x1, y1, w, h],
iscrowd=0
)
self.num_annos += 1
self.max_num_labels = max(self.max_num_labels, num_labels)
msg["annotations"] = np.array(msg["annotations"])
return msg