CCPD数据转成YOLO v5数据格式

本文介绍了一种基于Python的车牌检测数据集标注方法。该方法读取特定路径下的图片文件,并通过解析文件名获取车牌位置信息,将其转换为YOLO格式的标注文件。适用于定制化的车牌检测训练数据准备。
CLIP-GmP-ViT-L-14编码模型

CLIP-GmP-ViT-L-14编码模型` 是一个图文双塔编码模型,适合做图文匹配、零样本分类和跨模态检索演示。本镜像已经完成 Web 部署,打开页面即可上传图片并测试图文表征能力

import cv2
import os

#参考 https://blog.csdn.net/qq_36516958/article/details/114274778
# https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data#2-create-labels

# path = "/public/ccpd_green/test/"
path = "/public/CCPD2019/ccpd_challenge/"

for filename in os.listdir(path):
    list1 = filename.split("-", 3)  # 第一次分割,以减号'-'做分割
    subname = list1[2]
    lt, rb = subname.split("_", 1) #第二次分割,以下划线'_'做分割
    lx, ly = lt.split("&", 1)
    rx, ry = rb.split("&", 1)
    width = int(rx) - int(lx)
    height = int(ry) - int(ly)  # bounding box的宽和高
    cx = float(lx) + width/2
    cy = float(ly) + height/2 #bounding box中心点

    img = cv2.imread(path + filename)
    width = width/img.shape[1]
    height = height/img.shape[0]
    cx = cx/img.shape[1]
    cy = cy/img.shape[0]

    txtname = filename.split(".", 1)
    txtfile = path + txtname[0] + ".txt"
    # 绿牌是第0类,蓝牌是第1类
    with open(txtfile, "w") as f:
        f.write(str(1)+" "+str(cx)+" "+str(cy)+" "+str(width)+" "+str(height))

    print(filename)
    print(txtfile)
    print(img.shape)
    print(cx)
    print(cy)
    print(width)
    print(height)

您可能感兴趣的与本文相关的镜像

CLIP-GmP-ViT-L-14编码模型

CLIP-GmP-ViT-L-14编码模型

图像识别
CLIP

CLIP-GmP-ViT-L-14编码模型` 是一个图文双塔编码模型,适合做图文匹配、零样本分类和跨模态检索演示。本镜像已经完成 Web 部署,打开页面即可上传图片并测试图文表征能力

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值