Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
aad99b63
Unverified
提交
aad99b63
authored
5月 25, 2021
作者:
Glenn Jocher
提交者:
GitHub
5月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TensorBoard DP/DDP graph fix (#3325)
上级
407dc500
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
9 行增加
和
3 行删除
+9
-3
train.py
train.py
+3
-3
torch_utils.py
utils/torch_utils.py
+6
-0
没有找到文件。
train.py
浏览文件 @
aad99b63
...
@@ -32,7 +32,7 @@ from utils.general import labels_to_class_weights, increment_path, labels_to_ima
...
@@ -32,7 +32,7 @@ from utils.general import labels_to_class_weights, increment_path, labels_to_ima
from
utils.google_utils
import
attempt_download
from
utils.google_utils
import
attempt_download
from
utils.loss
import
ComputeLoss
from
utils.loss
import
ComputeLoss
from
utils.plots
import
plot_images
,
plot_labels
,
plot_results
,
plot_evolution
from
utils.plots
import
plot_images
,
plot_labels
,
plot_results
,
plot_evolution
from
utils.torch_utils
import
ModelEMA
,
select_device
,
intersect_dicts
,
torch_distributed_zero_first
,
is
_parallel
from
utils.torch_utils
import
ModelEMA
,
select_device
,
intersect_dicts
,
torch_distributed_zero_first
,
de
_parallel
from
utils.wandb_logging.wandb_utils
import
WandbLogger
,
check_wandb_resume
from
utils.wandb_logging.wandb_utils
import
WandbLogger
,
check_wandb_resume
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -331,7 +331,7 @@ def train(hyp, opt, device, tb_writer=None):
...
@@ -331,7 +331,7 @@ def train(hyp, opt, device, tb_writer=None):
f
=
save_dir
/
f
'train_batch{ni}.jpg'
# filename
f
=
save_dir
/
f
'train_batch{ni}.jpg'
# filename
Thread
(
target
=
plot_images
,
args
=
(
imgs
,
targets
,
paths
,
f
),
daemon
=
True
)
.
start
()
Thread
(
target
=
plot_images
,
args
=
(
imgs
,
targets
,
paths
,
f
),
daemon
=
True
)
.
start
()
if
tb_writer
:
if
tb_writer
:
tb_writer
.
add_graph
(
torch
.
jit
.
trace
(
model
,
imgs
,
strict
=
False
),
[])
# add
model graph
tb_writer
.
add_graph
(
torch
.
jit
.
trace
(
de_parallel
(
model
),
imgs
,
strict
=
False
),
[])
#
model graph
# tb_writer.add_image(f, result, dataformats='HWC', global_step=epoch)
# tb_writer.add_image(f, result, dataformats='HWC', global_step=epoch)
elif
plots
and
ni
==
10
and
wandb_logger
.
wandb
:
elif
plots
and
ni
==
10
and
wandb_logger
.
wandb
:
wandb_logger
.
log
({
"Mosaics"
:
[
wandb_logger
.
wandb
.
Image
(
str
(
x
),
caption
=
x
.
name
)
for
x
in
wandb_logger
.
log
({
"Mosaics"
:
[
wandb_logger
.
wandb
.
Image
(
str
(
x
),
caption
=
x
.
name
)
for
x
in
...
@@ -390,7 +390,7 @@ def train(hyp, opt, device, tb_writer=None):
...
@@ -390,7 +390,7 @@ def train(hyp, opt, device, tb_writer=None):
ckpt
=
{
'epoch'
:
epoch
,
ckpt
=
{
'epoch'
:
epoch
,
'best_fitness'
:
best_fitness
,
'best_fitness'
:
best_fitness
,
'training_results'
:
results_file
.
read_text
(),
'training_results'
:
results_file
.
read_text
(),
'model'
:
deepcopy
(
model
.
module
if
is_parallel
(
model
)
else
model
)
.
half
(),
'model'
:
deepcopy
(
de_parallel
(
model
)
)
.
half
(),
'ema'
:
deepcopy
(
ema
.
ema
)
.
half
(),
'ema'
:
deepcopy
(
ema
.
ema
)
.
half
(),
'updates'
:
ema
.
updates
,
'updates'
:
ema
.
updates
,
'optimizer'
:
optimizer
.
state_dict
(),
'optimizer'
:
optimizer
.
state_dict
(),
...
...
utils/torch_utils.py
浏览文件 @
aad99b63
...
@@ -134,9 +134,15 @@ def profile(x, ops, n=100, device=None):
...
@@ -134,9 +134,15 @@ def profile(x, ops, n=100, device=None):
def
is_parallel
(
model
):
def
is_parallel
(
model
):
# Returns True if model is of type DP or DDP
return
type
(
model
)
in
(
nn
.
parallel
.
DataParallel
,
nn
.
parallel
.
DistributedDataParallel
)
return
type
(
model
)
in
(
nn
.
parallel
.
DataParallel
,
nn
.
parallel
.
DistributedDataParallel
)
def
de_parallel
(
model
):
# De-parallelize a model: returns single-GPU model if model is of type DP or DDP
return
model
.
module
if
is_parallel
(
model
)
else
model
def
intersect_dicts
(
da
,
db
,
exclude
=
()):
def
intersect_dicts
(
da
,
db
,
exclude
=
()):
# Dictionary intersection of matching keys and shapes, omitting 'exclude' keys, using da values
# Dictionary intersection of matching keys and shapes, omitting 'exclude' keys, using da values
return
{
k
:
v
for
k
,
v
in
da
.
items
()
if
k
in
db
and
not
any
(
x
in
k
for
x
in
exclude
)
and
v
.
shape
==
db
[
k
]
.
shape
}
return
{
k
:
v
for
k
,
v
in
da
.
items
()
if
k
in
db
and
not
any
(
x
in
k
for
x
in
exclude
)
and
v
.
shape
==
db
[
k
]
.
shape
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论