lx-cly / YOLOv5_OBB_KLD

KLD实现旋转目标检测
GNU General Public License v3.0
45 stars 10 forks source link

KLD训练得到权重后,在检测时发现角度信息相差不大 #6

Open wang-TJ-20 opened 2 years ago

wang-TJ-20 commented 2 years ago

KLD训练得到权重后,在检测时发现角度信息相差不大,请问是标签或者是其他地方需要调整吗。 这是三个不同图片检测出来的结果,经过换算后,他们的角度信息几乎一致,检测结果看起来像是水平框检测 ((876.5000610351562, 768.5), (462.3126525878906, 404.125), -87.8736572265625) ((862.5, 677.5000610351562), (275.181640625, 507.555908203125), -87.9666748046875) ((696.5, 1057.5001220703125), (185.2694854736328, 233.78030395507812), -87.05175018310547)

wang-TJ-20 commented 2 years ago

您好,KLD训练后,预测时发现角度没有较大变化,无论是怎样的图片,其角度基本都在-87°~-86°左右,就很奇怪,不知道是角度信息没计算进去吗

wang-TJ-20 commented 2 years ago

您好,我想问是不是训练的数据格式应该是DOTA格式的,我用的是yolo格式的x,y,w,h,angle,是不是这块出问题了

lx-cly commented 2 years ago

训练的旋转矩形框的表示方法为长边表示法, classid x_c y_c longside shortside Θ Θ∈[0, 180)。angle是用0~180°的整形数表示的。 image

lx-cly commented 2 years ago

将DOTA数据格式转换成所需的格式,可以根据这篇文章

wang-TJ-20 commented 2 years ago

您好,很感谢您为我解答,那我的数据格式应该是没问题的,我就是先训练的那个作者的yolov5+csl,之后发现您的yolov5+kld,然后训练后完,检测时输出的角度信息不变😂

---原始邮件--- 发件人: @.> 发送时间: 2022年3月23日(周三) 下午2:46 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

将DOTA数据格式转换成所需的格式,可以根据这篇文章 。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wang-TJ-20 commented 2 years ago

我这就很疑惑,我看大家提出来的问题,好像训练过程没出现这种情况,就很奇怪,我练了好几次,都是这样,不知道是哪出问题了,令人头大

lx-cly commented 2 years ago

我刚刚看了代码,我修改kld计算loss,输出分支是xywh angle score num_classes;而csl计算loss xywh,score,num_classes,num_angles。代码在utils/general.py compute_loss_kld 中,可能是我自己只训练了一个类,没有发现问题。

lx-cly commented 2 years ago

你用kld训练修改 .\models\yolo_new.py的Detect类中初始化函数的self.angle = 1 这个了吗

wang-TJ-20 commented 2 years ago

改了,我也只有一个种类,哭了,就是感觉一切都一样,才会感觉很奇怪😂

---原始邮件--- 发件人: @.> 发送时间: 2022年3月23日(周三) 下午3:43 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

你用kld训练修改 .\models\yolo_new.py的Detect类中初始化函数的self.angle = 1 这个了吗

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

---原始邮件--- 发件人: @.> 发送时间: 2022年3月23日(周三) 下午3:43 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

你用kld训练修改 .\models\yolo_new.py的Detect类中初始化函数的self.angle = 1 这个了吗

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wang-TJ-20 commented 2 years ago

我改动就是cfg用的yolov5s

---原始邮件--- 发件人: @.> 发送时间: 2022年3月23日(周三) 下午3:43 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

你用kld训练修改 .\models\yolo_new.py的Detect类中初始化函数的self.angle = 1 这个了吗

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

detect.py的时候应该是把use_kld设置为True了吧

wang-TJ-20 commented 2 years ago

是的,改了,用你的权重测试就对着,我训练的就不行,头大😂

---原始邮件--- 发件人: @.> 发送时间: 2022年3月23日(周三) 下午3:55 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

detect.py的时候应该是把use_kld设置为True了吧

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

yolov5s 中 backbone 用的是 加了cbam注意力机制的 BottleneckCSP块 但是train.py 是冻结了backbone 所以你训练的不好

lx-cly commented 2 years ago

我当时只是想试试注意力机制有没有提升,你可以用回原来的骨干网,加载yolov5s.pt,可以选择冻结骨干网进行训练

wang-TJ-20 commented 2 years ago

这个yolov5s也试过了,我不冻结训练也尝试了,还是不行😂

---原始邮件--- 发件人: @.> 发送时间: 2022年3月23日(周三) 下午4:10 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

我当时只是想试试注意力机制有没有提升,你可以用回原来的骨干网,加载yolov5s.pt,可以选择冻结骨干网进行训练

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wang-TJ-20 commented 2 years ago

您好,我用您网盘的提供的数据训练,还是角度信息有问题,真就头大

lx-cly commented 2 years ago

你训练的loss图还有吗?

wang-TJ-20 commented 2 years ago

623d8c7a7de38577143244b596ffccb d1923c5ad344388447acf11a05dccf6

lx-cly commented 2 years ago

你好,你说过用我训练的权重测试就没问题,那应该是训练部分有问题。要不你用训练集的图片detect下试试?

lx-cly commented 2 years ago

有没有可能是opencv版本的问题?opencv-python==4.1.2.30

wang-TJ-20 commented 2 years ago

opencv的版本是对的,就是我下载你的yolo-kld权重,detect你网盘里的ship数据结果是正确的,但是我用你的数据或者我的其他数据,训练的权重,进行detect时,检测出来的角度信息有问题,就是现在我连你的结果都复现不了,就头大,感觉应该就差一点,但就是不知道哪出问题😂

---原始邮件--- 发件人: @.> 发送时间: 2022年3月24日(周四) 中午12:17 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

有没有可能是opencv版本的问题?opencv-python==4.1.2.30

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

好的,我这边git clone下来重新训练下再看看。

wang-TJ-20 commented 2 years ago

感谢感谢🤝🤝🤝

---原始邮件--- 发件人: @.> 发送时间: 2022年3月24日(周四) 中午12:47 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

好的,我这边git clone下来重新训练下再看看。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

你好,我加载yolov5s.pt训练网盘里的ship数据集的中验证集部分,确实如你所说的那样角度信息没学好;不过我换成yolov5m.pt,使用adam优化器,训练结果就可以了。下图是训练100epoch的结果。 P0262__1__1260___0

wang-TJ-20 commented 2 years ago

哇,太感谢您了,那我试试换adam优化器训练下,主要有模型大小要求,yolov5m权重对我来说太大了😂

---原始邮件--- 发件人: @.> 发送时间: 2022年3月25日(周五) 下午2:33 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

你好,我加载yolov5s.pt训练网盘里的ship数据集的中验证集部分,确实如你所说的那样角度信息没学好;不过我换成yolov5m.pt,使用adam优化器,训练结果就可以了。下图是训练100epoch的结果。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

我待会儿会重新上传下代码,把原来输出分支是xywh angle score num_classes 改成跟cls: xywh,score,num_classes,num_angles 一样。你可以重新试一下。对于你的数据集,你可能需要调调超参数。

wang-TJ-20 commented 2 years ago

感谢感谢,大佬太好了

---原始邮件--- 发件人: @.> 发送时间: 2022年3月25日(周五) 下午2:39 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

我待会儿会重新上传下代码,把原来输出分支是xywh angle score num_classes 改成跟cls: xywh,score,num_classes,num_angles 一样。你可以重新试一下。对于你的数据集,你可能需要调调超参数。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

感谢感谢,大佬太好了 ---原始邮件--- 发件人: @.> 发送时间: 2022年3月25日(周五) 下午2:39 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6) 我待会儿会重新上传下代码,把原来输出分支是xywh angle score num_classes 改成跟cls: xywh,score,num_classes,num_angles 一样。你可以重新试一下。对于你的数据集,你可能需要调调超参数。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

别这么说,我不厉害。希望能帮得到你。

wang-TJ-20 commented 2 years ago

您好,想问一下您新上传的代码有修改吗,训练方式有改变吗,我用yolov5m训练ship的val数据,用adam优化器,损失降不下来,最后的预测结果角度也有问题。并且之前下载下来你的yolov5~kld权重,预测时角度也有了偏差。第一张图是我用yolov5m训练时的损失变化,第二张图时是我用之前下载你的yolov5m-kld权重在新下载的代码上预测时的结果。

------------------ 原始邮件 ------------------ 发件人: "lx-cly/YOLOv5_OBB_KLD" @.>; 发送时间: 2022年3月25日(星期五) 下午2:33 @.>; 抄送: " @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

你好,我加载yolov5s.pt训练网盘里的ship数据集的中验证集部分,确实如你所说的那样角度信息没学好;不过我换成yolov5m.pt,使用adam优化器,训练结果就可以了。下图是训练100epoch的结果。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

您好,想问一下您新上传的代码有修改吗,训练方式有改变吗,我用yolov5m训练ship的val数据,用adam优化器,损失降不下来,最后的预测结果角度也有问题。并且之前下载下来你的yolov5~kld权重,预测时角度也有了偏差。第一张图是我用yolov5m训练时的损失变化,第二张图时是我用之前下载你的yolov5m-kld权重在新下载的代码上预测时的结果。 ------------------ 原始邮件 ------------------ 发件人: "lx-cly/YOLOv5_OBB_KLD" @.>; 发送时间: 2022年3月25日(星期五) 下午2:33 @.>; 抄送: " @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6) 你好,我加载yolov5s.pt训练网盘里的ship数据集的中验证集部分,确实如你所说的那样角度信息没学好;不过我换成yolov5m.pt,使用adam优化器,训练结果就可以了。下图是训练100epoch的结果。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

代码更新了,所以以前训练好的权重预测结果会不对。但是新的训练方式应该没问题吧。

wang-TJ-20 commented 2 years ago

好的,感谢,我再去试试

---原始邮件--- 发件人: @.> 发送时间: 2022年3月27日(周日) 晚上11:24 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

您好,想问一下您新上传的代码有修改吗,训练方式有改变吗,我用yolov5m训练ship的val数据,用adam优化器,损失降不下来,最后的预测结果角度也有问题。并且之前下载下来你的yolov5~kld权重,预测时角度也有了偏差。第一张图是我用yolov5m训练时的损失变化,第二张图时是我用之前下载你的yolov5m-kld权重在新下载的代码上预测时的结果。 … ------------------ 原始邮件 ------------------ 发件人: "lx-cly/YOLOv5_OBB_KLD" @.>; 发送时间: 2022年3月25日(星期五) 下午2:33 @.>; 抄送: " @.@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6) 你好,我加载yolov5s.pt训练网盘里的ship数据集的中验证集部分,确实如你所说的那样角度信息没学好;不过我换成yolov5m.pt,使用adam优化器,训练结果就可以了。下图是训练100epoch的结果。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

代码更新了,所以以前训练好的权重预测结果会不对。但是新的训练方式应该没问题吧。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

以前训练好的模型 detect.py 将 函数rotate_non_max_suppression 换成rotate_non_max_suppression_test 应该可以实现以前的预测结果了。

wang-TJ-20 commented 2 years ago

好的,感谢,我明早去课题组再试一试😂

---原始邮件--- 发件人: @.> 发送时间: 2022年3月27日(周日) 晚上11:36 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

以前训练好的模型 detect.py 将 函数rotate_non_max_suppression 换成rotate_non_max_suppression_test 应该可以实现以前的预测结果了。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wang-TJ-20 commented 2 years ago

您好,我要裂开了,他这个练完还是角度信息有问题,所有的角度都是这个样子,这是什么原因呢,太难了

------------------ 原始邮件 ------------------ 发件人: "lx-cly/YOLOv5_OBB_KLD" @.>; 发送时间: 2022年3月27日(星期天) 晚上11:36 @.>; 抄送: " @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

以前训练好的模型 detect.py 将 函数rotate_non_max_suppression 换成rotate_non_max_suppression_test 应该可以实现以前的预测结果了。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

你再更新下model/yolo.py和model.yolo-new.py试试

lx-cly commented 2 years ago

我重新在val集中训练kld的权重文件放在网盘中了,yolov5_kld_new_val.pt。你可以下载下来看看

wang-TJ-20 commented 2 years ago

好的好的,感谢哥🤝🤝🤝

---原始邮件--- 发件人: @.> 发送时间: 2022年3月28日(周一) 下午3:24 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

我重新在val集中训练kld的权重文件放在网盘中了,yolov5_kld_new_val.pt。你可以下载下来看看

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wang-TJ-20 commented 2 years ago

害,太难了,你的权重确实没问题,我训练的权重就有问题,角度信息一直学不到,麻了,只能等等下个有缘人能不能练出来,真不知道问题出哪了😂

---原始邮件--- 发件人: @.> 发送时间: 2022年3月28日(周一) 下午3:24 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

我重新在val集中训练kld的权重文件放在网盘中了,yolov5_kld_new_val.pt。你可以下载下来看看

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

你好,你如果想要复现我的结果。数据集是dota_ship_val,加载yolov5m.pt,冻结骨干网,使用adam优化,lr=0.001,batch_size=8,epoch=300。

wang-TJ-20 commented 2 years ago

感谢感谢,又燃起希望,再冲一遍😂

---原始邮件--- 发件人: @.> 发送时间: 2022年3月28日(周一) 晚上11:19 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

你好,你如果想要复现我的结果。数据集是dota_ship_val,加载yolov5m.pt,冻结骨干网,使用adam优化,lr=0.001,batch_size=8,epoch=300。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

lx-cly commented 2 years ago

你好,请问训练可以吗?

wang-TJ-20 commented 2 years ago

您好,我的还是没成功,我出现的问题就是损失降不下去,一直在波动,我在你的权重文件里看到你的损失一直是下降的,但我训练时损失降不下来,一直是0.9左右。 第一张图是我训练完的结果图,第二张是我的结果的txt文件。

------------------ 原始邮件 ------------------ 发件人: "lx-cly/YOLOv5_OBB_KLD" @.>; 发送时间: 2022年3月29日(星期二) 上午10:53 @.>; 抄送: " @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

你好,请问训练可以吗?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wang-TJ-20 commented 2 years ago

您好,您的代码没问题,之前是我训练的epochs数太少了,我yolov5s,1000epoch后,效果不错,感谢您的代码🤝

---原始邮件--- 发件人: @.> 发送时间: 2022年3月29日(周二) 上午10:53 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

你好,请问训练可以吗?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wang-TJ-20 commented 2 years ago

有的,第一个是用你提供的ship数据,第二个是我数据

---原始邮件--- 发件人: @.> 发送时间: 2022年3月24日(周四) 上午9:04 收件人: @.>; 抄送: @.**@.>; 主题: Re: [lx-cly/YOLOv5_OBB_KLD] KLD训练得到权重后,在检测时发现角度信息相差不大 (Issue #6)

你训练的loss图还有吗?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wang-TJ-20 commented 1 year ago

时隔一年再次来评论,之前没仔细看论文作者的解读,KLD损失确实下降较慢,网络收敛较慢,所以需要增多epoch