cgpeter96 / Focal-Loss-Pytorch

全中文注释.(The loss function of retinanet based on pytorch).(You can use it on one-stage detection task or classifical task, to solve data imbalance influence).用于one-stage目标检测算法,提升检测效果.你也可以在分类任务中使用该损失函数,解决数据不平衡问题.

Home Page:https://ptorch.com/news/253.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GIthub使用指北:

1.想将项目拷贝到自己帐号下就fork一下.

2.持续关注项目更新就star一下

3.watch是设置接收邮件提醒的.

jupyter-notebook用法例子 请见:由于Github是国外网站,加载会稍慢

retainnet的实现请见:Retinanet-pytorch


pytorch 实现 focal loss

retinanet论文损失函数

实现过程简易明了,全中文备注.

阿尔法α 参数用于调整类别权重

伽马γ 参数用于调整不同检测难易样本的权重,让模型快速关注于困难样本

交叉熵损失

cross_empty

带平衡因子的交叉熵

α-cross_empty

Focal损失

加入 (1-pt)γ 平衡难易样本的权重,通过γ缩放因子调整,retainnet默认γ=2

focal loss

带平衡因子的Focal损失

论文中最终为带平衡因子的focal loss, 本项目实现的也是这个版本

α-focal loss

最终retainnet的效果

不同γ 值收敛效果

focal loss_效果

retainnet与其他检测模型对比

retainnet对比图

About

全中文注释.(The loss function of retinanet based on pytorch).(You can use it on one-stage detection task or classifical task, to solve data imbalance influence).用于one-stage目标检测算法,提升检测效果.你也可以在分类任务中使用该损失函数,解决数据不平衡问题.

https://ptorch.com/news/253.html


Languages

Language:Jupyter Notebook 55.9%Language:Python 44.1%