为了用BDD100K数据集训练YOLOV5模型,首先需要将BDD100K数据集格式转成YOLOV5支持的输入格式。转换代码如下:
一、BDD100K转YOLO格式#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import os
import json
def search_file(data_dir, pattern=r'\.jpg$'):
root_dir = os.path.abspath(data_dir)
for root, dirs, files in os.walk(root_dir):
for f in files:
if re.search(pattern, f, re.I):
abs_path = os.path.join(root, f)
# print('new file %s' % absfn)
yield abs_path
class Bdd2yolov5:
def __init__(self):
self.bdd100k_width = 1280
self.bdd100k_height = 720
# self.select_categorys = ["person", "car", "bus", "truck"]
# self.cat2id = {
# "person": 0,
# "car": 1,
# "bus": 1,
# "tr
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)