Pytorch_Retinaface
Pytorch_Retinaface copied to clipboard
你好,有关自定义数据集测试结果偏差的问题
我用RetinaFace(包括在你的框架下构建的其他检测器)在不带landmark自己的数据集上训练的模型(训练size 512 x 512),发现512的测试size会发生严重的检测框偏移(都是向左下),原图测试无偏移且结果正常。但带landmark的WIDER FACE数据集训练的模型基本没有偏移,而且做landmark和不做landmark的相同检测器均存在偏移。 请问下我是哪个环节出错了,在读取label时,默认所有的gt框landmark值为-1,类别label为1,这样处理对吗。
大致流程没问题,应该是相关编解码等细节有些问题. 我实现的retinaface最开始自测的版本是没有关键点信息,后面再加的关键点,均没有出现你说的现象. 你可以继续参考本项目相关细节以及其他项目相关SSD实现.
这两张图片分别是自定义数据集上训练,使用训练size和原图size测试的结果,训练size测试结果的偏移比较严重。
现在可以排除的是训练和测试代码(两个数据集训练的代码都是完全一致的),我仅在读取Label的时候有些不同,因为自定义数据无landmark,以下是我修改后的代码。
# for idx, label in enumerate(labels):
# num = len(label)
# gt_num = num // 4
# annotation = np.zeros((1, 15))
# # bbox
# for i in range(gt_num):
# annotation[0, 0] = label[0 + 4*i] # x1
# annotation[0, 1] = label[1 + 4*i] # y1
# annotation[0, 2] = label[2 + 4*i] # x2
# annotation[0, 3] = label[3 + 4*i] # y2
#
# # landmarks
# annotation[0, 4] = -1.0 # l0_x
# annotation[0, 5] = -1.0 # l0_y
# annotation[0, 6] = -1.0 # l1_x
# annotation[0, 7] = -1.0 # l1_y
# annotation[0, 8] = -1.0 # l2_x
# annotation[0, 9] = -1.0 # l2_y
# annotation[0, 10] = -1.0 # l3_x
# annotation[0, 11] = -1.0 # l3_y
# annotation[0, 12] = -1.0 # l4_x
# annotation[0, 13] = -1.0 # l4_y
# annotation[0, 14] = 1
# # print(annotation)
# annotations = np.append(annotations, annotation, axis=0)
我有个问题是为什么要将无landmark设为annotation[0, 14] = -1,有landmark设为annotation[0, 14] = 1,背景又是0,检测器不是做的2分类吗?
annotation[0, 14] = -1代表face landmark被遮挡(不可用),在回归的时候不计算损失,也不会对这一块计算梯度反向传播.
@biubug6 非常感谢
找到原因啦,因为自定义数据集上(512x512)的检测框是扁平状的,我把它转换成正方形的检测框,中心点计算错了。。因为WIDERFACE上的检测框基本是正方形所以没影响。
我又使用你的RetinaFace模型在WIDER FACE上测试,第一张是把图片resize至 640 x 640后输入网络的结果,第二张是原图,可见结果差异很大。网络训练的时候size是 640 x 640,为什么这里用640训练结果这么差。 这是我resize插入的位置:
img_raw = cv2.imread(image_path, cv2.IMREAD_COLOR)
img = np.float32(img_raw)
img = cv2.resize(img,(640,640),interpolation=cv2.INTER_LINEAR)
im_height, im_width, _ = img.shape
scale = torch.Tensor([img_raw.shape[1], img_raw.shape[0], img_raw.shape[1], img_raw.shape[0]])
输入net()的是resize后的图片img,请问这里有什么不合理的地方吗。
因为训练的时候采用的是在原图0.3~1的尺度上随机裁减的正方形框,然后再等比例缩放到640640训练.相当于用大图训练, 我也重新实现了一个基于小图训练的项目https://github.com/biubug6/Face-Detector-1MB-with-landmark, 针对你提到的缩放到(640, 640)的图像会有明显的改善,可以参考一下(建议等比例大边缩放到640,而不是直接缩放到640640,会有形变压缩影响).
多谢哈
please look at this line:
pos1 = conf_t > zeros
------------------ 原始邮件 ------------------ 发件人: "zhangyuan1994511"<[email protected]>; 发送时间: 2019年11月14日(星期四) 下午4:59 收件人: "biubug6/Pytorch_Retinaface"<[email protected]>; 抄送: "Subscribed"<[email protected]>; 主题: Re: [biubug6/Pytorch_Retinaface] 你好,有关自定义数据集测试结果偏差的问题 (#36)
@biubug6 作者你好,感谢你的分享!我检查了你代码中求loss的过程,发现你似乎把annotation[0, 14] = -1的ignore当做正例返传梯度了(pos = conf_t != zeros ;conf_t[pos] = 1)。我不确定是不是我理解错了,希望你能检查确定下,谢谢!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
@hegc label = 1 表示关键点可用的人脸框(用于回归关键点) label = -1 or 1表示关键点不可用的人脸框 (用于回归人脸框及分类)
请问怎么训练自己的数据集呢,不标注人脸关键点也可以吗
@S201961152 可以的,你可以参照作者给的标注格式,把自己数据关键点都改为-1
请问前面表示box的四个数据是要自己手动标注吗
1663678924
邮箱:[email protected]
在2020年11月27日 14:43,Wang 写道:
@S201961152 可以的,你可以参照作者给的标注格式,把自己数据关键点都改为-1
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-734673308",
"url": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-734673308",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
@S201961152 是的,推荐使用LabelImg,标注左上右下顶点坐标,自己写个标注结果的转换脚本。
好的,非常感谢
1663678924
邮箱:[email protected]
在2020年12月02日 14:05,Wang 写道:
@S201961152 是的,推荐使用LabelImg,标注左上右下顶点坐标,自己写个标注结果的转换脚本。
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"url": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
您好,我还有个问题想问一下,就是我想通过检测人脸统计这个图片中人的数量,如果有的人完全没有露脸,我需要把头部也标注出来吗
1663678924
邮箱:[email protected]
在2020年12月02日 14:05,Wang 写道:
@S201961152 是的,推荐使用LabelImg,标注左上右下顶点坐标,自己写个标注结果的转换脚本。
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"url": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
统计标准视情况而定,如果是被人挡住了,完全没有露脸通常算误检;如果是带口罩面罩遮住人脸,是可以算检测正确的。
---原始邮件--- 发件人: "S201961152"<[email protected]> 发送时间: 2020年12月3日(周四) 下午2:40 收件人: "biubug6/Pytorch_Retinaface"<[email protected]>; 抄送: "Author"<[email protected]>;"Wang"<[email protected]>; 主题: Re: [biubug6/Pytorch_Retinaface] 你好,有关自定义数据集测试结果偏差的问题 (#36)
您好,我还有个问题想问一下,就是我想通过检测人脸统计这个图片中人的数量,如果有的人完全没有露脸,我需要把头部也标注出来吗
1663678924
邮箱:[email protected]
在2020年12月02日 14:05,Wang 写道:
@S201961152 是的,推荐使用LabelImg,标注左上右下顶点坐标,自己写个标注结果的转换脚本。
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"url": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
] — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
好的,了解了,谢谢您
1663678924
邮箱:[email protected]
在2020年12月03日 15:54,Wang 写道:
统计标准视情况而定,如果是被人挡住了,完全没有露脸通常算误检;如果是带口罩面罩遮住人脸,是可以算检测正确的。
---原始邮件---
发件人: "S201961152"<[email protected]>
发送时间: 2020年12月3日(周四) 下午2:40
收件人: "biubug6/Pytorch_Retinaface"<[email protected]>;
抄送: "Author"<[email protected]>;"Wang"<[email protected]>;
主题: Re: [biubug6/Pytorch_Retinaface] 你好,有关自定义数据集测试结果偏差的问题 (#36)
您好,我还有个问题想问一下,就是我想通过检测人脸统计这个图片中人的数量,如果有的人完全没有露脸,我需要把头部也标注出来吗
1663678924
邮箱:[email protected]
在2020年12月02日 14:05,Wang 写道:
@S201961152 是的,推荐使用LabelImg,标注左上右下顶点坐标,自己写个标注结果的转换脚本。
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"url": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737731173",
"url": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737731173",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
您好,我想请教一个其他问题,不知道方便吗,就是我在用resnet训练时,减小了batchsize,但是测试结果达不到那个精度,请问是还有其他参数需要修改吗
1663678924
邮箱:[email protected]
在2020年12月03日 15:54,Wang 写道:
统计标准视情况而定,如果是被人挡住了,完全没有露脸通常算误检;如果是带口罩面罩遮住人脸,是可以算检测正确的。
---原始邮件---
发件人: "S201961152"<[email protected]>
发送时间: 2020年12月3日(周四) 下午2:40
收件人: "biubug6/Pytorch_Retinaface"<[email protected]>;
抄送: "Author"<[email protected]>;"Wang"<[email protected]>;
主题: Re: [biubug6/Pytorch_Retinaface] 你好,有关自定义数据集测试结果偏差的问题 (#36)
您好,我还有个问题想问一下,就是我想通过检测人脸统计这个图片中人的数量,如果有的人完全没有露脸,我需要把头部也标注出来吗
1663678924
邮箱:[email protected]
在2020年12月02日 14:05,Wang 写道:
@S201961152 是的,推荐使用LabelImg,标注左上右下顶点坐标,自己写个标注结果的转换脚本。
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"url": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737013398",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737731173",
"url": "https://github.com/biubug6/Pytorch_Retinaface/issues/36#issuecomment-737731173",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]
@S201961152 你的测试时输入网络的图片是原图吗还是resize了?
找到原因啦,因为自定义数据集上(512x512)的检测框是扁平状的,我把它转换成正方形的检测框,中心点计算错了。。因为WIDERFACE上的检测框基本是正方形所以没影响。
您好,请问下这部分在代码的哪里修改呀,我的数据集也是扁平框