we0091234 / Chinese_license_plate_detection_recognition

yolov5 车牌检测 车牌识别 中文车牌识别 检测 支持12种中文车牌 支持双层车牌
GNU General Public License v3.0
1.25k stars 216 forks source link

请问加载图像标签时为什么要这样? #9

Open MAYAO913 opened 1 year ago

MAYAO913 commented 1 year ago

face_datasets.py文件中getitem方法获取关键点信息时为什么后面要(np.array(x[:, 5] > 0, dtype=np.int32) - 1)

labels[:, 5] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 5] + pad[0]) + (
        np.array(x[:, 5] > 0, dtype=np.int32) - 1)
labels[:, 6] = np.array(x[:, 6] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 6] + pad[1]) + (
        np.array(x[:, 6] > 0, dtype=np.int32) - 1)
labels[:, 7] = np.array(x[:, 7] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 7] + pad[0]) + (
        np.array(x[:, 7] > 0, dtype=np.int32) - 1)
labels[:, 8] = np.array(x[:, 8] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 8] + pad[1]) + (
        np.array(x[:, 8] > 0, dtype=np.int32) - 1)
labels[:, 9] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 9] + pad[0]) + (
        np.array(x[:, 9] > 0, dtype=np.int32) - 1)
labels[:, 10] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 10] + pad[1]) + (
        np.array(x[:, 10] > 0, dtype=np.int32) - 1)
labels[:, 11] = np.array(x[:, 11] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 11] + pad[0]) + (
        np.array(x[:, 11] > 0, dtype=np.int32) - 1)
labels[:, 12] = np.array(x[:, 12] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 12] + pad[1]) + (
        np.array(x[:, 12] > 0, dtype=np.int32) - 1)
we0091234 commented 1 year ago

face_datasets.py文件中getitem方法获取关键点信息时为什么后面要(np.array(x[:, 5] > 0, dtype=np.int32) - 1)

labels[:, 5] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 5] + pad[0]) + (
        np.array(x[:, 5] > 0, dtype=np.int32) - 1)
labels[:, 6] = np.array(x[:, 6] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 6] + pad[1]) + (
        np.array(x[:, 6] > 0, dtype=np.int32) - 1)
labels[:, 7] = np.array(x[:, 7] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 7] + pad[0]) + (
        np.array(x[:, 7] > 0, dtype=np.int32) - 1)
labels[:, 8] = np.array(x[:, 8] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 8] + pad[1]) + (
        np.array(x[:, 8] > 0, dtype=np.int32) - 1)
labels[:, 9] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 9] + pad[0]) + (
        np.array(x[:, 9] > 0, dtype=np.int32) - 1)
labels[:, 10] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 10] + pad[1]) + (
        np.array(x[:, 10] > 0, dtype=np.int32) - 1)
labels[:, 11] = np.array(x[:, 11] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 11] + pad[0]) + (
        np.array(x[:, 11] > 0, dtype=np.int32) - 1)
labels[:, 12] = np.array(x[:, 12] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 12] + pad[1]) + (
        np.array(x[:, 12] > 0, dtype=np.int32) - 1)

因为原图通过letterbox进行了变换,resize了并且有padding,那么坐标肯定也要有相应的变换

MAYAO913 commented 1 year ago

face_datasets.py文件中getitem方法获取关键点信息时为什么后面要(np.array(x[:, 5] > 0, dtype=np.int32) - 1)

labels[:, 5] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 5] + pad[0]) + (
        np.array(x[:, 5] > 0, dtype=np.int32) - 1)
labels[:, 6] = np.array(x[:, 6] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 6] + pad[1]) + (
        np.array(x[:, 6] > 0, dtype=np.int32) - 1)
labels[:, 7] = np.array(x[:, 7] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 7] + pad[0]) + (
        np.array(x[:, 7] > 0, dtype=np.int32) - 1)
labels[:, 8] = np.array(x[:, 8] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 8] + pad[1]) + (
        np.array(x[:, 8] > 0, dtype=np.int32) - 1)
labels[:, 9] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 9] + pad[0]) + (
        np.array(x[:, 9] > 0, dtype=np.int32) - 1)
labels[:, 10] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 10] + pad[1]) + (
        np.array(x[:, 10] > 0, dtype=np.int32) - 1)
labels[:, 11] = np.array(x[:, 11] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 11] + pad[0]) + (
        np.array(x[:, 11] > 0, dtype=np.int32) - 1)
labels[:, 12] = np.array(x[:, 12] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 12] + pad[1]) + (
        np.array(x[:, 12] > 0, dtype=np.int32) - 1)

因为原图通过letterbox进行了变换,resize了并且有padding,那么坐标肯定也要有相应的变换

你说的是应该是这一句代码吧,ratio[0] * w * x[:, 5] + pad[0]。 我不是很明白np.array(x[:, 5] > 0, dtype=np.int32)np.array(x[:, 5] > 0, dtype=np.int32) - 1是干嘛的。 能解释下吗?谢谢

we0091234 commented 1 year ago

face_datasets.py文件中getitem方法获取关键点信息时为什么后面要(np.array(x[:, 5] > 0, dtype=np.int32) - 1)

labels[:, 5] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 5] + pad[0]) + (
        np.array(x[:, 5] > 0, dtype=np.int32) - 1)
labels[:, 6] = np.array(x[:, 6] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 6] + pad[1]) + (
        np.array(x[:, 6] > 0, dtype=np.int32) - 1)
labels[:, 7] = np.array(x[:, 7] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 7] + pad[0]) + (
        np.array(x[:, 7] > 0, dtype=np.int32) - 1)
labels[:, 8] = np.array(x[:, 8] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 8] + pad[1]) + (
        np.array(x[:, 8] > 0, dtype=np.int32) - 1)
labels[:, 9] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 9] + pad[0]) + (
        np.array(x[:, 9] > 0, dtype=np.int32) - 1)
labels[:, 10] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 10] + pad[1]) + (
        np.array(x[:, 10] > 0, dtype=np.int32) - 1)
labels[:, 11] = np.array(x[:, 11] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 11] + pad[0]) + (
        np.array(x[:, 11] > 0, dtype=np.int32) - 1)
labels[:, 12] = np.array(x[:, 12] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 12] + pad[1]) + (
        np.array(x[:, 12] > 0, dtype=np.int32) - 1)

因为原图通过letterbox进行了变换,resize了并且有padding,那么坐标肯定也要有相应的变换

你说的是应该是这一句代码吧,ratio[0] * w * x[:, 5] + pad[0]。 我不是很明白np.array(x[:, 5] > 0, dtype=np.int32)np.array(x[:, 5] > 0, dtype=np.int32) - 1是干嘛的。 能解释下吗?谢谢

这个就是比如有负数的时候,就当做-1