Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
69ff781c
提交
69ff781c
authored
8月 31, 2020
作者:
Glenn Jocher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt.img_weights bug fix (#885)
上级
987c2268
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
8 行增加
和
10 行删除
+8
-10
train.py
train.py
+8
-10
没有找到文件。
train.py
浏览文件 @
69ff781c
...
...
@@ -216,18 +216,15 @@ def train(hyp, opt, device, tb_writer=None):
model
.
train
()
# Update image weights (optional)
if
dataset
.
image
_weights
:
if
opt
.
img
_weights
:
# Generate indices
if
rank
in
[
-
1
,
0
]:
w
=
model
.
class_weights
.
cpu
()
.
numpy
()
*
(
1
-
maps
)
**
2
# class weights
image_weights
=
labels_to_image_weights
(
dataset
.
labels
,
nc
=
nc
,
class_weights
=
w
)
dataset
.
indices
=
random
.
choices
(
range
(
dataset
.
n
),
weights
=
image_weights
,
k
=
dataset
.
n
)
# rand weighted idx
cw
=
model
.
class_weights
.
cpu
()
.
numpy
()
*
(
1
-
maps
)
**
2
# class weights
iw
=
labels_to_image_weights
(
dataset
.
labels
,
nc
=
nc
,
class_weights
=
cw
)
# image weights
dataset
.
indices
=
random
.
choices
(
range
(
dataset
.
n
),
weights
=
iw
,
k
=
dataset
.
n
)
# rand weighted idx
# Broadcast if DDP
if
rank
!=
-
1
:
indices
=
torch
.
zeros
([
dataset
.
n
],
dtype
=
torch
.
int
)
if
rank
==
0
:
indices
[:]
=
torch
.
tensor
(
dataset
.
indices
,
dtype
=
torch
.
int
)
indices
=
(
torch
.
tensor
(
dataset
.
indices
)
if
rank
==
0
else
torch
.
zeros
(
dataset
.
n
))
.
int
()
dist
.
broadcast
(
indices
,
0
)
if
rank
!=
0
:
dataset
.
indices
=
indices
.
cpu
()
.
numpy
()
...
...
@@ -388,7 +385,8 @@ if __name__ == '__main__':
parser
.
add_argument
(
'--hyp'
,
type
=
str
,
default
=
''
,
help
=
'hyperparameters path, i.e. data/hyp.scratch.yaml'
)
parser
.
add_argument
(
'--epochs'
,
type
=
int
,
default
=
300
)
parser
.
add_argument
(
'--batch-size'
,
type
=
int
,
default
=
16
,
help
=
'total batch size for all GPUs'
)
parser
.
add_argument
(
'--img-size'
,
nargs
=
'+'
,
type
=
int
,
default
=
[
640
,
640
],
help
=
'train,test sizes'
)
parser
.
add_argument
(
'--img-size'
,
nargs
=
'+'
,
type
=
int
,
default
=
[
640
,
640
],
help
=
'[train, test] image sizes'
)
parser
.
add_argument
(
'--img-weights'
,
action
=
'store_true'
,
help
=
'use weighted image selection for training'
)
parser
.
add_argument
(
'--rect'
,
action
=
'store_true'
,
help
=
'rectangular training'
)
parser
.
add_argument
(
'--resume'
,
nargs
=
'?'
,
const
=
True
,
default
=
False
,
help
=
'resume most recent training'
)
parser
.
add_argument
(
'--nosave'
,
action
=
'store_true'
,
help
=
'only save final checkpoint'
)
...
...
@@ -471,7 +469,7 @@ if __name__ == '__main__':
'obj_pw'
:
(
1
,
0.5
,
2.0
),
# obj BCELoss positive_weight
'iou_t'
:
(
0
,
0.1
,
0.7
),
# IoU training threshold
'anchor_t'
:
(
1
,
2.0
,
8.0
),
# anchor-multiple threshold
# 'anchors': (1, 2.0, 10.0), # anchors per output grid (0 to ignore)
# 'anchors': (1, 2.0, 10.0), # anchors per output grid (0 to ignore)
'fl_gamma'
:
(
0
,
0.0
,
2.0
),
# focal loss gamma (efficientDet default gamma=1.5)
'hsv_h'
:
(
1
,
0.0
,
0.1
),
# image HSV-Hue augmentation (fraction)
'hsv_s'
:
(
1
,
0.0
,
0.9
),
# image HSV-Saturation augmentation (fraction)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论