• Stars
    star
    450
  • Rank 96,455 (Top 2 %)
  • Language
    Jupyter Notebook
  • Created about 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

全中文注释.(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目标检测算法,提升检测效果.你也可以在分类任务中使用该损失函数,解决数据不平衡问题.

GIthub使用指北:

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

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

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

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

retainnet的实现请见:Retinanet-pytorch


pytorch 实现 focal loss

retinanet论文损失函数

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

参数说明

  • alpha参数,是类别损失权重。

    用于调节各类别对损失的影响,具体作用与torch实现的CrossEntropyLoss中的weight参数一致。

    你可以输入一个float,比如0.25,则最终的alpha将是[0.25, 0.75, 0.75, 0.75, ...],这种情况一般用于目标检测,用来抑制背景类对损失的影响;你也可以直接输入一个列表,直接为每一类指定损失权重。

  • gamma参数,是难易度系数,也是focal loss不同于交叉熵的最大区别。

    用于调整训练过程中难识别样本与易识别样本对损失的影响

参数设置

通常情况下,设置好num_classes直接调用就可以了。

  • alhpa参数

    可以参考各类别样本数据量比例,来设置alpha参数。

    但更建议的是,进行多次训练:

    1. 初次训练时,可以将alpha设置为一个值全为1的列表,使各个类别平等的去影响损失。

    2. 测试结果后,针对想提高的类别,给予一个较其他类大的权重值,加大该类对损失的影响,继续训练模型,使模型在训练时更倾向于该类。例如5分类任务中,设置alpha=[1, 1, 2, 3, 1],加大第三类、第四类对损失的影响,提高这两类的分类精度。

  • gamma参数

    gamma参数只推荐设置为2

交叉熵损失

cross_empty

带平衡因子的交叉熵

α-cross_empty

Focal损失

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

focal loss

带平衡因子的Focal损失

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

α-focal loss

最终retainnet的效果

不同γ 值收敛效果

focal loss_效果

retainnet与其他检测模型对比

retainnet对比图

More Repositories

1

ISAT_with_segment_anything

Labeling tool with SAM(segment anything model),supports SAM, SAM2, sam-hq, MobileSAM EdgeSAM etc.交互式半自动图像标注工具
Python
1,181
star
2

SSD-Pytorch

SSD目标检测算法(Single Shot MultiBox Detector)(简单,明了,易用,全中文注释,单机多卡训练,视频检测)( If you train the model on a single computer and mutil GPU, this program will be your best choice , easier to use and easier to understand )
Python
392
star
3

Retinanet-Pytorch

Retinanet目标检测算法(简单,明了,易用,全中文注释,单机多卡训练,视频检测)(based on pytorch,Simple, Clear, Mutil GPU)
Python
264
star
4

ISAT

ISAT - Image segmentation annotation tool.(图像分割标注工具,支持语义分割与实例分割)
Python
45
star
5

PSAT

PSAT - Point cloud segmentation annotation tool. (点云分割标注工具,同时支持语义分割与实例分割)
Python
28
star
6

pointnet2

pointnet2(点云分割, 基于pytorch,全中文注释)
Python
24
star
7

Simple-Local-QA

用最简单的代码带你实现基于大模型的本地知识库问答系统
Python
22
star
8

darknet19-pytorch

中英文注释,采用torchvision.models中模型的实现结构.带权重
Python
13
star
9

dota2-autochess-KG

dota2游廊自走棋关系图谱
Python
13
star
10

Changeable

基于pytorch的目标检测数据增强工具包。
Python
12
star
11

leetcode-python

python刷leetcode记录。项目含有详细的代码注释和解题思路,并配有对应的leetcode中英文题目。The project contains detailed code comments and solution ideas(chinese), and has corresponding leetcode question content(Chinese and English).
Python
12
star
12

Machine-Learning

机器学习算法实现(python)(详细的实现过程备注以及丰富的例子)
Jupyter Notebook
10
star
13

freeproxy

可扩展的自动化个人代理ip池
Python
5
star
14

Patterns-Python

设计模式python版本
Python
4
star
15

website

一个基于flask编写的内容分享网站,练手项目。你可以以此项目作为入门flask的学习项目。flask + bootstrap + 七牛云 + nginx + uwsgi
TypeScript
2
star
16

FarmTogetherTool

Farm Together resource modification tool
Python
2
star
17

Sorting-Algorithm-python

排序算法实现(基于python, 带动图展示)All Sorting-Algorithm Implementation based on Python. (GIF display)
Jupyter Notebook
1
star
18

flask-learning

flask学习笔记以及对应的代码.涵盖了狗书、狼书等.
Python
1
star
19

IDAT

IDAT(图像目标检测标注工具)
Python
1
star
20

navigate

个人导航页面- 基于WebStack-Hugo
JavaScript
1
star