项目实训第四周

第四周项目实训专注于Ultra-fast-lane-detection的研究,包括数据集标注、模型训练和测试。使用labelme工具进行道路图片标注,然后在服务器上进行训练。模型测试结果显示在3090显卡上推理速度达250fps,但标注时间较长,考虑后期优化。
摘要由CSDN通过智能技术生成

第四周的任务主要是对Ultra-fast-lane-detection的进一步探索,对于ultra-fast-lane-detection的训练,推理测速以及目标点选取,和tensorrt的学习。

数据集标注

首先是标注数据集,我选择了软件学院的道路进行拍照,收集了上百张图片进行标注。(后期由于图片数量不足,我先对网上给出的数据集进行了训练和测试,由于场地和模型选择都还没确定,因此我们先只是观察该模型的效果)
标注是使用labelme进行标注。该工具在标注的基础上生成json文件,而我们需要的是标注后的label照片。因此还需要我们自己编写脚本来根据json文件生成label实例掩膜图片

import argparse
import glob
import json
import os
import os.path as ops
import cv2
import numpy as np


def init_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('--img_dir', type=str, help='The origin path of image')
    parser.add_argument('--json_dir', type=str, help='The origin path of json')
    return parser.parse_args()

def process_json_file(img_path, json_path, instance_dst_dir):
    """
    :param img_path: 原始图像路径
    :param json_path: 标签文件路径
    :param instance_dst_dir:实例图像保存路径
    :return:
    """

    assert ops.exists(img_path), '{:s} not exist'.format(img_path)
    image = cv2.imread(img_path, cv2.IMREAD_COLOR)
    instance_image = np.zeros([image.shape[0], image.shape[1]], np.uint8)
    with open(json_path, 'r',encoding='utf8') as file:
        info_dict = json.load(file)
        for ind,info in enumerate(info_dict['shapes']):
            contours = info['points']
            contours = np.array(contours,dtype=int)
            # 绘制多边形
            cv2.fillPoly(instance_image, [contours], (ind+1, ind+1, ind+1)) #  * 50 + 20

        instance_image_path = img_path.replace(os.path.dirname(img_path),instance_dst_dir)
        cv2.imwrite(instance_image_path.replace('.jpg','.png'), instance_image)  # 实例分割图像
# 训练库构建
def process_tusimple_dataset(img_dir,json_dir):
    """
	:param json_dir: 标签文件路径
    :param img_dir: 原始图像路径
    :return:
    """
    gt_instance_dir = ops.join(os.path.dirname(img_dir), 'label')  # 与原始图片文件夹在同级父目录下
    os.makedirs(gt_instance_dir, exist_ok=True)

    for img_path in glob.glob('{:s}/*.jpg'.format(img_dir)):
        json_path 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值