Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
3a5c5328
提交
3a5c5328
authored
6月 11, 2020
作者:
Glenn Jocher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ONNX, BCEBlurWithLogitsLoss, plot_study updates
上级
18b4da91
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
4 行删除
+24
-4
onnx_export.py
models/onnx_export.py
+6
-3
utils.py
utils/utils.py
+18
-1
没有找到文件。
models/onnx_export.py
浏览文件 @
3a5c5328
# Exports a pytorch *.pt model to *.onnx format
"""Exports a pytorch *.pt model to *.onnx format
# Example usage (run from ./yolov5 directory):
# $ export PYTHONPATH="$PWD" && python models/onnx_export.py --weights ./weights/yolov5s.pt --img 640 --batch 1
Usage:
import torch
$ export PYTHONPATH="$PWD" && python models/onnx_export.py --weights ./weights/yolov5s.pt --img 640 --batch 1
"""
import
argparse
import
argparse
...
...
utils/utils.py
浏览文件 @
3a5c5328
...
@@ -339,6 +339,23 @@ def smooth_BCE(eps=0.1): # https://github.com/ultralytics/yolov3/issues/238#iss
...
@@ -339,6 +339,23 @@ def smooth_BCE(eps=0.1): # https://github.com/ultralytics/yolov3/issues/238#iss
return
1.0
-
0.5
*
eps
,
0.5
*
eps
return
1.0
-
0.5
*
eps
,
0.5
*
eps
class
BCEBlurWithLogitsLoss
(
nn
.
Module
):
# BCEwithLogitLoss() with reduced missing label effects.
def
__init__
(
self
,
alpha
=
0.05
):
super
(
BCEBlurWithLogitsLoss
,
self
)
.
__init__
()
self
.
loss_fcn
=
nn
.
BCEWithLogitsLoss
(
reduction
=
'none'
)
# must be nn.BCEWithLogitsLoss()
self
.
alpha
=
alpha
def
forward
(
self
,
pred
,
true
):
loss
=
self
.
loss_fcn
(
pred
,
true
)
pred
=
torch
.
sigmoid
(
pred
)
# prob from logits
dx
=
pred
-
true
# reduce only missing label effects
# dx = (pred - true).abs() # reduce missing label and false label effects
alpha_factor
=
1
-
torch
.
exp
((
dx
-
1
)
/
(
self
.
alpha
+
1e-4
))
loss
*=
alpha_factor
return
loss
.
mean
()
def
compute_loss
(
p
,
targets
,
model
):
# predictions, targets, model
def
compute_loss
(
p
,
targets
,
model
):
# predictions, targets, model
ft
=
torch
.
cuda
.
FloatTensor
if
p
[
0
]
.
is_cuda
else
torch
.
Tensor
ft
=
torch
.
cuda
.
FloatTensor
if
p
[
0
]
.
is_cuda
else
torch
.
Tensor
lcls
,
lbox
,
lobj
=
ft
([
0
]),
ft
([
0
]),
ft
([
0
])
lcls
,
lbox
,
lobj
=
ft
([
0
]),
ft
([
0
]),
ft
([
0
])
...
@@ -1009,7 +1026,7 @@ def plot_study_txt(f='study.txt', x=None): # from utils.utils import *; plot_st
...
@@ -1009,7 +1026,7 @@ def plot_study_txt(f='study.txt', x=None): # from utils.utils import *; plot_st
ax2
.
plot
(
1E3
/
np
.
array
([
209
,
140
,
97
,
58
,
35
,
18
]),
[
33.5
,
39.1
,
42.5
,
45.9
,
49.
,
50.5
],
ax2
.
plot
(
1E3
/
np
.
array
([
209
,
140
,
97
,
58
,
35
,
18
]),
[
33.5
,
39.1
,
42.5
,
45.9
,
49.
,
50.5
],
'k.-'
,
linewidth
=
2
,
markersize
=
8
,
alpha
=.
25
,
label
=
'EfficientDet'
)
'k.-'
,
linewidth
=
2
,
markersize
=
8
,
alpha
=.
25
,
label
=
'EfficientDet'
)
ax2
.
set_xlim
(
0
,
30
)
ax2
.
set_xlim
(
0
,
30
)
ax2
.
set_ylim
(
2
3
,
50
)
ax2
.
set_ylim
(
2
5
,
50
)
ax2
.
set_xlabel
(
'GPU Latency (ms)'
)
ax2
.
set_xlabel
(
'GPU Latency (ms)'
)
ax2
.
set_ylabel
(
'COCO AP val'
)
ax2
.
set_ylabel
(
'COCO AP val'
)
ax2
.
legend
(
loc
=
'lower right'
)
ax2
.
legend
(
loc
=
'lower right'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论