Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
67bf9a97
Unverified
提交
67bf9a97
authored
11月 10, 2020
作者:
Glenn Jocher
提交者:
GitHub
11月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace 'ground truth' with 'labels' (#1337)
* Replace 'ground truth' with 'labels' * Using torch... update
上级
1c8464e1
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
19 行增加
和
19 行删除
+19
-19
README.md
README.md
+1
-1
test.py
test.py
+5
-5
tutorial.ipynb
tutorial.ipynb
+5
-5
general.py
utils/general.py
+8
-8
没有找到文件。
README.md
浏览文件 @
67bf9a97
...
@@ -87,7 +87,7 @@ To run inference on example images in `data/images`:
...
@@ -87,7 +87,7 @@ To run inference on example images in `data/images`:
$
python detect.py
--source
data/images
--weights
yolov5s.pt
--conf
0.25
$
python detect.py
--source
data/images
--weights
yolov5s.pt
--conf
0.25
Namespace
(
agnostic_nms
=
False,
augment
=
False,
classes
=
None,
conf_thres
=
0.25,
device
=
''
,
img_size
=
640,
iou_thres
=
0.45,
output
=
'runs/detect'
,
save_conf
=
False,
save_txt
=
False,
source
=
'data/images'
,
update
=
False,
view_img
=
False,
weights
=
'yolov5s.pt'
)
Namespace
(
agnostic_nms
=
False,
augment
=
False,
classes
=
None,
conf_thres
=
0.25,
device
=
''
,
img_size
=
640,
iou_thres
=
0.45,
output
=
'runs/detect'
,
save_conf
=
False,
save_txt
=
False,
source
=
'data/images'
,
update
=
False,
view_img
=
False,
weights
=
'yolov5s.pt'
)
Using
CUDA device0 _CudaDeviceProperties
(
name
=
'Tesla V100-SXM2-16GB'
,
total_memory
=
1616
0MB
)
Using
torch 1.7.0+cu101 CUDA:0
(
Tesla V100-SXM2-16GB, 1613
0MB
)
Downloading https://github.com/ultralytics/yolov5/releases/download/v3.0/yolov5s.pt to yolov5s.pt... 100%|██████████████| 14.5M/14.5M
[
00:00<00:00, 21.3MB/s]
Downloading https://github.com/ultralytics/yolov5/releases/download/v3.0/yolov5s.pt to yolov5s.pt... 100%|██████████████| 14.5M/14.5M
[
00:00<00:00, 21.3MB/s]
...
...
test.py
浏览文件 @
67bf9a97
...
@@ -204,8 +204,8 @@ def test(data,
...
@@ -204,8 +204,8 @@ def test(data,
# Plot images
# Plot images
if
plots
and
batch_i
<
1
:
if
plots
and
batch_i
<
1
:
f
=
save_dir
/
f
'test_batch{batch_i}_
gt
.jpg'
# filename
f
=
save_dir
/
f
'test_batch{batch_i}_
labels
.jpg'
# filename
plot_images
(
img
,
targets
,
paths
,
str
(
f
),
names
)
#
ground truth
plot_images
(
img
,
targets
,
paths
,
str
(
f
),
names
)
#
labels
f
=
save_dir
/
f
'test_batch{batch_i}_pred.jpg'
f
=
save_dir
/
f
'test_batch{batch_i}_pred.jpg'
plot_images
(
img
,
output_to_target
(
output
,
width
,
height
),
paths
,
str
(
f
),
names
)
# predictions
plot_images
(
img
,
output_to_target
(
output
,
width
,
height
),
paths
,
str
(
f
),
names
)
# predictions
...
@@ -250,9 +250,9 @@ def test(data,
...
@@ -250,9 +250,9 @@ def test(data,
from
pycocotools.cocoeval
import
COCOeval
from
pycocotools.cocoeval
import
COCOeval
imgIds
=
[
int
(
Path
(
x
)
.
stem
)
for
x
in
dataloader
.
dataset
.
img_files
]
imgIds
=
[
int
(
Path
(
x
)
.
stem
)
for
x
in
dataloader
.
dataset
.
img_files
]
coco
Gt
=
COCO
(
glob
.
glob
(
'../coco/annotations/instances_val*.json'
)[
0
])
# initialize COCO ground truth
api
coco
Anno
=
COCO
(
glob
.
glob
(
'../coco/annotations/instances_val*.json'
)[
0
])
# initialize COCO annotations
api
coco
Dt
=
cocoGt
.
loadRes
(
str
(
file
))
# initialize COCO pred api
coco
Pred
=
cocoAnno
.
loadRes
(
str
(
file
))
# initialize COCO pred api
cocoEval
=
COCOeval
(
coco
Gt
,
cocoDt
,
'bbox'
)
cocoEval
=
COCOeval
(
coco
Anno
,
cocoPred
,
'bbox'
)
cocoEval
.
params
.
imgIds
=
imgIds
# image IDs to evaluate
cocoEval
.
params
.
imgIds
=
imgIds
# image IDs to evaluate
cocoEval
.
evaluate
()
cocoEval
.
evaluate
()
cocoEval
.
accumulate
()
cocoEval
.
accumulate
()
...
...
tutorial.ipynb
浏览文件 @
67bf9a97
...
@@ -605,7 +605,7 @@
...
@@ -605,7 +605,7 @@
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.25, device='', img_size=640, iou_thres=0.45, save_conf=False, save_dir='runs/detect', save_txt=False, source='data/images/', update=False, view_img=False, weights=['yolov5s.pt'])\n",
"Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.25, device='', img_size=640, iou_thres=0.45, save_conf=False, save_dir='runs/detect', save_txt=False, source='data/images/', update=False, view_img=False, weights=['yolov5s.pt'])\n",
"Using
CUDA device0 _CudaDeviceProperties(name='Tesla V100-SXM2-16GB', total_memory=
16130MB)\n",
"Using
torch 1.7.0+cu101 CUDA:0 (Tesla V100-SXM2-16GB,
16130MB)\n",
"\n",
"\n",
"Fusing layers... \n",
"Fusing layers... \n",
"Model Summary: 140 layers, 7.45958e+06 parameters, 0 gradients\n",
"Model Summary: 140 layers, 7.45958e+06 parameters, 0 gradients\n",
...
@@ -735,7 +735,7 @@
...
@@ -735,7 +735,7 @@
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"Namespace(augment=False, batch_size=32, conf_thres=0.001, data='./data/coco.yaml', device='', img_size=640, iou_thres=0.65, save_conf=False, save_dir='runs/test', save_json=True, save_txt=False, single_cls=False, task='val', verbose=False, weights=['yolov5x.pt'])\n",
"Namespace(augment=False, batch_size=32, conf_thres=0.001, data='./data/coco.yaml', device='', img_size=640, iou_thres=0.65, save_conf=False, save_dir='runs/test', save_json=True, save_txt=False, single_cls=False, task='val', verbose=False, weights=['yolov5x.pt'])\n",
"Using
CUDA device0 _CudaDeviceProperties(name='Tesla V100-SXM2-16GB', total_memory=
16130MB)\n",
"Using
torch 1.7.0+cu101 CUDA:0 (Tesla V100-SXM2-16GB,
16130MB)\n",
"\n",
"\n",
"Downloading https://github.com/ultralytics/yolov5/releases/download/v3.1/yolov5x.pt to yolov5x.pt...\n",
"Downloading https://github.com/ultralytics/yolov5/releases/download/v3.1/yolov5x.pt to yolov5x.pt...\n",
"100% 170M/170M [00:05<00:00, 32.2MB/s]\n",
"100% 170M/170M [00:05<00:00, 32.2MB/s]\n",
...
@@ -921,7 +921,7 @@
...
@@ -921,7 +921,7 @@
{
{
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"Using
CUDA device0 _CudaDeviceProperties(name='Tesla V100-SXM2-16GB', total_memory=
16130MB)\n",
"Using
torch 1.7.0+cu101 CUDA:0 (Tesla V100-SXM2-16GB,
16130MB)\n",
"\n",
"\n",
"Namespace(adam=False, batch_size=16, bucket='', cache_images=True, cfg='', data='./data/coco128.yaml', device='', epochs=3, evolve=False, global_rank=-1, hyp='data/hyp.scratch.yaml', image_weights=False, img_size=[640, 640], local_rank=-1, log_imgs=10, logdir='runs/', multi_scale=False, name='', noautoanchor=False, nosave=True, notest=False, rect=False, resume=False, single_cls=False, sync_bn=False, total_batch_size=16, weights='yolov5s.pt', workers=8, world_size=1)\n",
"Namespace(adam=False, batch_size=16, bucket='', cache_images=True, cfg='', data='./data/coco128.yaml', device='', epochs=3, evolve=False, global_rank=-1, hyp='data/hyp.scratch.yaml', image_weights=False, img_size=[640, 640], local_rank=-1, log_imgs=10, logdir='runs/', multi_scale=False, name='', noautoanchor=False, nosave=True, notest=False, rect=False, resume=False, single_cls=False, sync_bn=False, total_batch_size=16, weights='yolov5s.pt', workers=8, world_size=1)\n",
"Start Tensorboard with \"tensorboard --logdir runs/\", view at http://localhost:6006/\n",
"Start Tensorboard with \"tensorboard --logdir runs/\", view at http://localhost:6006/\n",
...
@@ -1040,7 +1040,7 @@
...
@@ -1040,7 +1040,7 @@
},
},
"source": [
"source": [
"Image(filename='runs/train/exp0/train_batch0.jpg', width=800) # train batch 0 mosaics and labels\n",
"Image(filename='runs/train/exp0/train_batch0.jpg', width=800) # train batch 0 mosaics and labels\n",
"Image(filename='runs/train/exp0/test_batch0_
gt.jpg', width=800) # test batch 0 ground truth
\n",
"Image(filename='runs/train/exp0/test_batch0_
labels.jpg', width=800) # test batch 0 labels
\n",
"Image(filename='runs/train/exp0/test_batch0_pred.jpg', width=800) # test batch 0 predictions"
"Image(filename='runs/train/exp0/test_batch0_pred.jpg', width=800) # test batch 0 predictions"
],
],
"execution_count": null,
"execution_count": null,
...
@@ -1056,7 +1056,7 @@
...
@@ -1056,7 +1056,7 @@
"`train_batch0.jpg` train batch 0 mosaics and labels\n",
"`train_batch0.jpg` train batch 0 mosaics and labels\n",
"\n",
"\n",
"> <img src=\"https://user-images.githubusercontent.com/26833433/83667626-8c37fe00-a583-11ea-997b-0923fe59b29b.jpeg\" width=\"750\"> \n",
"> <img src=\"https://user-images.githubusercontent.com/26833433/83667626-8c37fe00-a583-11ea-997b-0923fe59b29b.jpeg\" width=\"750\"> \n",
"`test_batch0_
gt.jpg` shows test batch 0 ground truth
\n",
"`test_batch0_
labels.jpg` shows test batch 0 labels
\n",
"\n",
"\n",
"> <img src=\"https://user-images.githubusercontent.com/26833433/83667635-90641b80-a583-11ea-8075-606316cebb9c.jpeg\" width=\"750\"> \n",
"> <img src=\"https://user-images.githubusercontent.com/26833433/83667635-90641b80-a583-11ea-8075-606316cebb9c.jpeg\" width=\"750\"> \n",
"`test_batch0_pred.jpg` shows test batch 0 _predictions_\n"
"`test_batch0_pred.jpg` shows test batch 0 _predictions_\n"
...
...
utils/general.py
浏览文件 @
67bf9a97
...
@@ -275,10 +275,10 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, fname='precision-re
...
@@ -275,10 +275,10 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, fname='precision-re
ap
,
p
,
r
=
np
.
zeros
(
s
),
np
.
zeros
(
s
),
np
.
zeros
(
s
)
ap
,
p
,
r
=
np
.
zeros
(
s
),
np
.
zeros
(
s
),
np
.
zeros
(
s
)
for
ci
,
c
in
enumerate
(
unique_classes
):
for
ci
,
c
in
enumerate
(
unique_classes
):
i
=
pred_cls
==
c
i
=
pred_cls
==
c
n_
gt
=
(
target_cls
==
c
)
.
sum
()
# Number of ground truth object
s
n_
l
=
(
target_cls
==
c
)
.
sum
()
# number of label
s
n_p
=
i
.
sum
()
#
Number of predicted object
s
n_p
=
i
.
sum
()
#
number of prediction
s
if
n_p
==
0
or
n_
gt
==
0
:
if
n_p
==
0
or
n_
l
==
0
:
continue
continue
else
:
else
:
# Accumulate FPs and TPs
# Accumulate FPs and TPs
...
@@ -286,7 +286,7 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, fname='precision-re
...
@@ -286,7 +286,7 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, fname='precision-re
tpc
=
tp
[
i
]
.
cumsum
(
0
)
tpc
=
tp
[
i
]
.
cumsum
(
0
)
# Recall
# Recall
recall
=
tpc
/
(
n_
gt
+
1e-16
)
# recall curve
recall
=
tpc
/
(
n_
l
+
1e-16
)
# recall curve
r
[
ci
]
=
np
.
interp
(
-
pr_score
,
-
conf
[
i
],
recall
[:,
0
])
# r at pr_score, negative x, xp because xp decreases
r
[
ci
]
=
np
.
interp
(
-
pr_score
,
-
conf
[
i
],
recall
[:,
0
])
# r at pr_score, negative x, xp because xp decreases
# Precision
# Precision
...
@@ -1076,8 +1076,8 @@ def plot_images(images, targets, paths=None, fname='images.jpg', names=None, max
...
@@ -1076,8 +1076,8 @@ def plot_images(images, targets, paths=None, fname='images.jpg', names=None, max
image_targets
=
targets
[
targets
[:,
0
]
==
i
]
image_targets
=
targets
[
targets
[:,
0
]
==
i
]
boxes
=
xywh2xyxy
(
image_targets
[:,
2
:
6
])
.
T
boxes
=
xywh2xyxy
(
image_targets
[:,
2
:
6
])
.
T
classes
=
image_targets
[:,
1
]
.
astype
(
'int'
)
classes
=
image_targets
[:,
1
]
.
astype
(
'int'
)
gt
=
image_targets
.
shape
[
1
]
==
6
# ground truth
if no conf column
labels
=
image_targets
.
shape
[
1
]
==
6
# labels
if no conf column
conf
=
None
if
gt
else
image_targets
[:,
6
]
# check for confidence presence (gt
vs pred)
conf
=
None
if
labels
else
image_targets
[:,
6
]
# check for confidence presence (label
vs pred)
boxes
[[
0
,
2
]]
*=
w
boxes
[[
0
,
2
]]
*=
w
boxes
[[
0
,
2
]]
+=
block_x
boxes
[[
0
,
2
]]
+=
block_x
...
@@ -1087,8 +1087,8 @@ def plot_images(images, targets, paths=None, fname='images.jpg', names=None, max
...
@@ -1087,8 +1087,8 @@ def plot_images(images, targets, paths=None, fname='images.jpg', names=None, max
cls
=
int
(
classes
[
j
])
cls
=
int
(
classes
[
j
])
color
=
color_lut
[
cls
%
len
(
color_lut
)]
color
=
color_lut
[
cls
%
len
(
color_lut
)]
cls
=
names
[
cls
]
if
names
else
cls
cls
=
names
[
cls
]
if
names
else
cls
if
gt
or
conf
[
j
]
>
0.3
:
# 0.3 conf thresh
if
labels
or
conf
[
j
]
>
0.3
:
# 0.3 conf thresh
label
=
'
%
s'
%
cls
if
gt
else
'
%
s
%.1
f'
%
(
cls
,
conf
[
j
])
label
=
'
%
s'
%
cls
if
labels
else
'
%
s
%.1
f'
%
(
cls
,
conf
[
j
])
plot_one_box
(
box
,
mosaic
,
label
=
label
,
color
=
color
,
line_thickness
=
tl
)
plot_one_box
(
box
,
mosaic
,
label
=
label
,
color
=
color
,
line_thickness
=
tl
)
# Draw image filename labels
# Draw image filename labels
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论