Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
mmdetection3d
Commits
faa0a6c4
Commit
faa0a6c4
authored
May 13, 2020
by
liyinhao
Browse files
change names
parent
422d3154
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
101 deletions
+49
-101
mmdet3d/core/evaluation/indoor_utils/eval.py
mmdet3d/core/evaluation/indoor_utils/eval.py
+14
-36
mmdet3d/datasets/scannet_dataset.py
mmdet3d/datasets/scannet_dataset.py
+5
-24
mmdet3d/datasets/sunrgbd_dataset.py
mmdet3d/datasets/sunrgbd_dataset.py
+20
-29
tests/test_scannet_dataset.py
tests/test_scannet_dataset.py
+5
-6
tests/test_sunrgbd_dataset.py
tests/test_sunrgbd_dataset.py
+4
-5
tools/test.py
tools/test.py
+1
-1
No files found.
mmdet3d/core/evaluation/indoor_utils/eval.py
View file @
faa0a6c4
...
...
@@ -46,27 +46,6 @@ def voc_ap(rec, prec, use_07_metric=False):
return
ap
def
boxes3d_to_bevboxes_lidar_torch
(
boxes3d
):
"""Boxes3d to Bevboxes Lidar.
Transform 3d boxes to bev boxes.
Args:
boxes3d (tensor): [x, y, z, w, l, h, ry] in LiDAR coords.
Returns:
boxes_bev (tensor): [x1, y1, x2, y2, ry].
"""
boxes_bev
=
boxes3d
.
new
(
torch
.
Size
((
boxes3d
.
shape
[
0
],
5
)))
cu
,
cv
=
boxes3d
[:,
0
],
boxes3d
[:,
1
]
half_l
,
half_w
=
boxes3d
[:,
4
]
/
2
,
boxes3d
[:,
3
]
/
2
boxes_bev
[:,
0
],
boxes_bev
[:,
1
]
=
cu
-
half_w
,
cv
-
half_l
boxes_bev
[:,
2
],
boxes_bev
[:,
3
]
=
cu
+
half_w
,
cv
+
half_l
boxes_bev
[:,
4
]
=
boxes3d
[:,
6
]
return
boxes_bev
def
get_iou_gpu
(
bb1
,
bb2
):
"""Get IoU.
...
...
@@ -201,7 +180,7 @@ def eval_det_multiprocessing(pred_all,
gt_all
,
ovthresh
=
None
,
use_07_metric
=
False
):
"""
Evaluate Detection Multiprocessing.
"""Evaluate Detection Multiprocessing.
Generic functions to compute precision/recall for object detection
for multiple classes.
...
...
@@ -321,21 +300,22 @@ class APCalculator(object):
for
key
in
sorted
(
ap
.
keys
()):
clsname
=
self
.
class2type_map
[
key
]
if
self
.
class2type_map
else
str
(
key
)
ret_dict
[
'%s Average Precision %d'
%
(
clsname
,
iou_thresh
*
100
)]
=
ap
[
key
]
ret_dict
[
'mAP%d'
%
(
iou_thresh
*
100
)]
=
np
.
mean
(
list
(
ap
.
values
()))
ret_dict
[
f
'
{
clsname
}
_AP_
{
int
(
iou_thresh
*
100
)
}
'
]
=
ap
[
key
]
ret_dict
[
f
'mAP_
{
int
(
iou_thresh
*
100
)
}
'
]
=
np
.
mean
(
list
(
ap
.
values
()))
rec_list
=
[]
for
key
in
sorted
(
ap
.
keys
()):
clsname
=
self
.
class2type_map
[
key
]
if
self
.
class2type_map
else
str
(
key
)
try
:
ret_dict
[
'%s Recall %d'
%
(
clsname
,
iou_thresh
*
100
)]
=
rec
[
key
][
-
1
]
ret_dict
[
f
'
{
clsname
}
_recall_
{
int
(
iou_thresh
*
100
)
}
'
]
=
rec
[
key
][
-
1
]
rec_list
.
append
(
rec
[
key
][
-
1
])
except
TypeError
:
ret_dict
[
'%s Recall %d'
%
(
clsname
,
iou_thresh
*
100
)]
=
0
ret_dict
[
f
'
{
clsname
}
_recall_
{
int
(
iou_thresh
*
100
)
}
'
]
=
0
rec_list
.
append
(
0
)
ret_dict
[
'AR
%d'
%
(
iou_thresh
*
100
)]
=
np
.
mean
(
rec_list
)
ret_dict
[
f
'AR
_
{
int
(
iou_thresh
*
100
)
}
'
]
=
np
.
mean
(
rec_list
)
ret
.
append
(
ret_dict
)
return
ret
...
...
@@ -373,7 +353,7 @@ def indoor_eval(gt_annos, dt_annos, metric, class2type):
Args:
gt_annos (List): GT annotations.
dt_annos (List): Detection annotations.
metric (
dict
): AP IoU thresholds.
metric (
List[float]
): AP IoU thresholds.
class2type (dict): {class: type}.
Return:
...
...
@@ -389,17 +369,15 @@ def indoor_eval(gt_annos, dt_annos, metric, class2type):
if
gt_anno
[
'gt_boxes_upright_depth'
].
shape
[
-
1
]
==
6
:
gt_anno
[
'gt_boxes_upright_depth'
]
=
np
.
pad
(
bbox_lidar_bottom
,
((
0
,
0
),
(
0
,
1
)),
'constant'
)
ap_iou_thresholds
=
metric
[
'AP_IOU_THRESHHOLDS'
]
ap_calculator
=
APCalculator
(
ap_iou_thresholds
,
class2type
)
ap_calculator
=
APCalculator
(
metric
,
class2type
)
ap_calculator
.
step
(
dt_annos
,
gt_annos
)
result_str
=
str
()
result_str
+=
'mAP'
metrics_dict
=
{}
metrics
=
ap_calculator
.
compute_metrics
()
for
i
,
iou_thresh
old
in
enumerate
(
ap_iou_thresholds
):
for
i
,
iou_thresh
in
enumerate
(
metric
):
metrics_tmp
=
metrics
[
i
]
metrics_dict
.
update
(
metrics_tmp
)
result_str
+=
'(%.2f):%s '
%
(
iou_threshold
,
metrics_dict
[
'mAP%d'
%
(
iou_threshold
*
100
)])
metric_result
=
metrics_dict
[
f
'mAP_
{
int
(
iou_thresh
*
100
)
}
'
]
result_str
+=
f
'(
{
iou_thresh
:.
2
f
}
:
{
metric_result
}
'
return
result_str
,
metrics_dict
mmdet3d/datasets/scannet_dataset.py
View file @
faa0a6c4
...
...
@@ -12,26 +12,7 @@ from .pipelines import Compose
@
DATASETS
.
register_module
()
class
ScannetDataset
(
torch_data
.
Dataset
):
type2class
=
{
'cabinet'
:
0
,
'bed'
:
1
,
'chair'
:
2
,
'sofa'
:
3
,
'table'
:
4
,
'door'
:
5
,
'window'
:
6
,
'bookshelf'
:
7
,
'picture'
:
8
,
'counter'
:
9
,
'desk'
:
10
,
'curtain'
:
11
,
'refrigerator'
:
12
,
'showercurtrain'
:
13
,
'toilet'
:
14
,
'sink'
:
15
,
'bathtub'
:
16
,
'garbagebin'
:
17
}
class2type
=
{
0
:
'cabinet'
,
1
:
'bed'
,
...
...
@@ -196,7 +177,7 @@ class ScannetDataset(torch_data.Dataset):
return
result
def
_
format_results
(
self
,
outputs
):
def
format_results
(
self
,
outputs
):
results
=
[]
for
output
in
outputs
:
result
=
self
.
_generate_annotations
(
output
)
...
...
@@ -210,11 +191,11 @@ class ScannetDataset(torch_data.Dataset):
Args:
results (List): List of result.
metric (
dict): AP_IOU_THRESHHOLDS
.
metric (
List[float]): AP IoU thresholds
.
"""
results
=
self
.
_
format_results
(
results
)
results
=
self
.
format_results
(
results
)
from
mmdet3d.core.evaluation
import
indoor_eval
assert
(
'AP_IOU_THRESHHOLDS'
in
metric
)
assert
len
(
metric
)
>
0
gt_annos
=
[
copy
.
deepcopy
(
info
[
'annos'
])
for
info
in
self
.
scannet_infos
]
...
...
mmdet3d/datasets/sunrgbd_dataset.py
View file @
faa0a6c4
...
...
@@ -12,18 +12,7 @@ from .pipelines import Compose
@
DATASETS
.
register_module
()
class
SunrgbdDataset
(
torch_data
.
Dataset
):
type2class
=
{
'bed'
:
0
,
'table'
:
1
,
'sofa'
:
2
,
'chair'
:
3
,
'toilet'
:
4
,
'desk'
:
5
,
'dresser'
:
6
,
'night_stand'
:
7
,
'bookshelf'
:
8
,
'bathtub'
:
9
}
class2type
=
{
0
:
'bed'
,
1
:
'table'
,
...
...
@@ -139,19 +128,13 @@ class SunrgbdDataset(torch_data.Dataset):
return
np
.
random
.
choice
(
pool
)
def
_generate_annotations
(
self
,
output
):
'''
transfer input_dict & pred_dicts to anno format
which is needed by AP calculator
return annos: a tuple (batch_pred_map_cls,batch_gt_map_cls)
batch_pred_map_cls is a list: i=0,1..bs-1
pred_list_i:[(pred_sem_cls,
box_params, box_score)_j]
j=0,1..num_pred_obj -1
batch_gt_map_cls is a list: i=0,1..bs-1
gt_list_i: [(sem_cls_label, box_params)_j]
j=0,1..num_gt_obj -1
'''
"""Generate Annotations.
Transform results of the model to the form of the evaluation.
Args:
output (List): The output of the model.
"""
result
=
[]
bs
=
len
(
output
)
for
i
in
range
(
bs
):
...
...
@@ -174,17 +157,25 @@ class SunrgbdDataset(torch_data.Dataset):
return
result
def
_
format_results
(
self
,
outputs
):
def
format_results
(
self
,
outputs
):
results
=
[]
for
output
in
outputs
:
result
=
self
.
_generate_annotations
(
output
)
results
.
append
(
result
)
return
results
def
evaluate
(
self
,
results
,
metric
=
None
):
results
=
self
.
_format_results
(
results
)
def
evaluate
(
self
,
results
,
metric
):
"""Evaluate.
Evaluation in indoor protocol.
Args:
results (List): List of result.
metric (List[float]): AP IoU thresholds.
"""
results
=
self
.
format_results
(
results
)
from
mmdet3d.core.evaluation
import
indoor_eval
assert
(
'AP_IOU_THRESHHOLDS'
in
metric
)
assert
len
(
metric
)
>
0
gt_annos
=
[
copy
.
deepcopy
(
info
[
'annos'
])
for
info
in
self
.
sunrgbd_infos
]
...
...
tests/test_scannet_dataset.py
View file @
faa0a6c4
...
...
@@ -107,13 +107,12 @@ def test_evaluate():
pred_boxes
[
'label_preds'
]
=
torch
.
Tensor
([
6
,
6
,
4
,
9
,
11
]).
cuda
()
pred_boxes
[
'scores'
]
=
torch
.
Tensor
([
0.5
,
1.0
,
1.0
,
1.0
,
1.0
]).
cuda
()
results
.
append
([
pred_boxes
])
metric
=
dict
()
metric
[
'AP_IOU_THRESHHOLDS'
]
=
[
0.25
,
0.5
]
metric
=
[
0.25
,
0.5
]
ap_dict
=
scannet_dataset
.
evaluate
(
results
,
metric
)
table_average_precision_25
=
ap_dict
[
'table
Average Precision
25'
]
window_average_precision_25
=
ap_dict
[
'window
Average Precision
25'
]
counter_average_precision_25
=
ap_dict
[
'counter
Average Precision
25'
]
curtain_average_precision_25
=
ap_dict
[
'curtain
Average Precision
25'
]
table_average_precision_25
=
ap_dict
[
'table
_AP_
25'
]
window_average_precision_25
=
ap_dict
[
'window
_AP_
25'
]
counter_average_precision_25
=
ap_dict
[
'counter
_AP_
25'
]
curtain_average_precision_25
=
ap_dict
[
'curtain
_AP_
25'
]
assert
abs
(
table_average_precision_25
-
0.3333
)
<
0.01
assert
abs
(
window_average_precision_25
-
1
)
<
0.01
assert
abs
(
counter_average_precision_25
-
1
)
<
0.01
...
...
tests/test_sunrgbd_dataset.py
View file @
faa0a6c4
...
...
@@ -80,12 +80,11 @@ def test_evaluate():
pred_boxes
[
'label_preds'
]
=
torch
.
Tensor
([
0
,
7
,
6
]).
cuda
()
pred_boxes
[
'scores'
]
=
torch
.
Tensor
([
0.5
,
1.0
,
1.0
]).
cuda
()
results
.
append
([
pred_boxes
])
metric
=
dict
()
metric
[
'AP_IOU_THRESHHOLDS'
]
=
[
0.25
,
0.5
]
metric
=
[
0.25
,
0.5
]
ap_dict
=
sunrgbd_dataset
.
evaluate
(
results
,
metric
)
bed_precision_25
=
ap_dict
[
'bed
Average Precision
25'
]
dresser_precision_25
=
ap_dict
[
'dresser
Average Precision
25'
]
night_stand_precision_25
=
ap_dict
[
'night_stand
Average Precision
25'
]
bed_precision_25
=
ap_dict
[
'bed
_AP_
25'
]
dresser_precision_25
=
ap_dict
[
'dresser
_AP_
25'
]
night_stand_precision_25
=
ap_dict
[
'night_stand
_AP_
25'
]
assert
abs
(
bed_precision_25
-
1
)
<
0.01
assert
abs
(
dresser_precision_25
-
1
)
<
0.01
assert
abs
(
night_stand_precision_25
-
1
)
<
0.01
tools/test.py
View file @
faa0a6c4
...
...
@@ -161,7 +161,7 @@ def main():
mmcv
.
dump
(
outputs
,
args
.
out
)
kwargs
=
{}
if
args
.
options
is
None
else
args
.
options
if
args
.
format_only
:
dataset
.
_
format_results
(
outputs
,
**
kwargs
)
dataset
.
format_results
(
outputs
,
**
kwargs
)
if
args
.
eval
:
dataset
.
evaluate
(
outputs
,
args
.
eval
,
**
kwargs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment