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
dlib
Commits
1b0ecb94
Commit
1b0ecb94
authored
Nov 23, 2013
by
Davis King
Browse files
Fixed a bug in the average precision calculation when ignore boxes were used.
parent
363d505c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
34 deletions
+14
-34
dlib/svm/cross_validate_object_detection_trainer.h
dlib/svm/cross_validate_object_detection_trainer.h
+14
-34
No files found.
dlib/svm/cross_validate_object_detection_trainer.h
View file @
1b0ecb94
...
@@ -21,6 +21,7 @@ namespace dlib
...
@@ -21,6 +21,7 @@ namespace dlib
{
{
inline
unsigned
long
number_of_truth_hits
(
inline
unsigned
long
number_of_truth_hits
(
const
std
::
vector
<
full_object_detection
>&
truth_boxes
,
const
std
::
vector
<
full_object_detection
>&
truth_boxes
,
const
std
::
vector
<
rectangle
>&
ignore
,
const
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>&
boxes
,
const
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>&
boxes
,
const
test_box_overlap
&
overlap_tester
,
const
test_box_overlap
&
overlap_tester
,
std
::
vector
<
std
::
pair
<
double
,
bool
>
>&
all_dets
,
std
::
vector
<
std
::
pair
<
double
,
bool
>
>&
all_dets
,
...
@@ -34,8 +35,10 @@ namespace dlib
...
@@ -34,8 +35,10 @@ namespace dlib
- No element of boxes is allowed to account for more than one element of truth_boxes.
- No element of boxes is allowed to account for more than one element of truth_boxes.
- The returned number is in the range [0,truth_boxes.size()]
- The returned number is in the range [0,truth_boxes.size()]
- Adds the score for each box from boxes into all_dets and labels each with
- Adds the score for each box from boxes into all_dets and labels each with
a bool indicating if it hit a truth box. Also adds the number of truth
a bool indicating if it hit a truth box. Note that we skip boxes that
boxes which didn't have any hits into missing_detections.
don't hit any truth boxes and match an ignore box.
- Adds the number of truth boxes which didn't have any hits into
missing_detections.
!*/
!*/
{
{
if
(
boxes
.
size
()
==
0
)
if
(
boxes
.
size
()
==
0
)
...
@@ -70,7 +73,11 @@ namespace dlib
...
@@ -70,7 +73,11 @@ namespace dlib
for
(
unsigned
long
i
=
0
;
i
<
boxes
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
boxes
.
size
();
++
i
)
{
{
all_dets
.
push_back
(
std
::
make_pair
(
boxes
[
i
].
first
,
used
[
i
]));
// only out put boxes if they match a truth box or are not ignored.
if
(
used
[
i
]
||
!
overlaps_any_box
(
overlap_tester
,
ignore
,
boxes
[
i
].
second
))
{
all_dets
.
push_back
(
std
::
make_pair
(
boxes
[
i
].
first
,
used
[
i
]));
}
}
}
return
count
;
return
count
;
...
@@ -78,23 +85,6 @@ namespace dlib
...
@@ -78,23 +85,6 @@ namespace dlib
// ------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------
inline
unsigned
long
count_dets_not_hitting_ignore_boxes
(
const
test_box_overlap
&
overlap_tester
,
const
std
::
vector
<
rectangle
>&
ignore
,
const
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>&
dets
)
{
unsigned
long
count
=
0
;
for
(
unsigned
long
i
=
0
;
i
<
dets
.
size
();
++
i
)
{
if
(
!
overlaps_any_box
(
overlap_tester
,
ignore
,
dets
[
i
].
second
))
{
++
count
;
}
}
return
count
;
}
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -125,7 +115,6 @@ namespace dlib
...
@@ -125,7 +115,6 @@ namespace dlib
double
correct_hits
=
0
;
double
correct_hits
=
0
;
double
total_hits
=
0
;
double
total_true_targets
=
0
;
double
total_true_targets
=
0
;
std
::
vector
<
std
::
pair
<
double
,
bool
>
>
all_dets
;
std
::
vector
<
std
::
pair
<
double
,
bool
>
>
all_dets
;
...
@@ -137,8 +126,7 @@ namespace dlib
...
@@ -137,8 +126,7 @@ namespace dlib
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>
hits
;
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>
hits
;
detector
(
images
[
i
],
hits
,
adjust_threshold
);
detector
(
images
[
i
],
hits
,
adjust_threshold
);
total_hits
+=
impl
::
count_dets_not_hitting_ignore_boxes
(
overlap_tester
,
ignore
[
i
],
hits
);
correct_hits
+=
impl
::
number_of_truth_hits
(
truth_dets
[
i
],
ignore
[
i
],
hits
,
overlap_tester
,
all_dets
,
missing_detections
);
correct_hits
+=
impl
::
number_of_truth_hits
(
truth_dets
[
i
],
hits
,
overlap_tester
,
all_dets
,
missing_detections
);
total_true_targets
+=
truth_dets
[
i
].
size
();
total_true_targets
+=
truth_dets
[
i
].
size
();
}
}
...
@@ -146,10 +134,7 @@ namespace dlib
...
@@ -146,10 +134,7 @@ namespace dlib
double
precision
,
recall
;
double
precision
,
recall
;
// If the user put an ignore box on the same spot as a truth box then we could end
double
total_hits
=
all_dets
.
size
();
// up with a total_hits value less than correct_hits. So we do this to make sure
// the precision value never goes above 1.
total_hits
=
std
::
max
(
total_hits
,
correct_hits
);
if
(
total_hits
==
0
)
if
(
total_hits
==
0
)
precision
=
1
;
precision
=
1
;
...
@@ -301,7 +286,6 @@ namespace dlib
...
@@ -301,7 +286,6 @@ namespace dlib
);
);
double
correct_hits
=
0
;
double
correct_hits
=
0
;
double
total_hits
=
0
;
double
total_true_targets
=
0
;
double
total_true_targets
=
0
;
const
long
test_size
=
images
.
size
()
/
folds
;
const
long
test_size
=
images
.
size
()
/
folds
;
...
@@ -336,8 +320,7 @@ namespace dlib
...
@@ -336,8 +320,7 @@ namespace dlib
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>
hits
;
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>
hits
;
detector
(
images
[
test_idx_set
[
i
]],
hits
,
adjust_threshold
);
detector
(
images
[
test_idx_set
[
i
]],
hits
,
adjust_threshold
);
total_hits
+=
impl
::
count_dets_not_hitting_ignore_boxes
(
overlap_tester
,
ignore
[
i
],
hits
);
correct_hits
+=
impl
::
number_of_truth_hits
(
truth_dets
[
test_idx_set
[
i
]],
ignore
[
i
],
hits
,
overlap_tester
,
all_dets
,
missing_detections
);
correct_hits
+=
impl
::
number_of_truth_hits
(
truth_dets
[
test_idx_set
[
i
]],
hits
,
overlap_tester
,
all_dets
,
missing_detections
);
total_true_targets
+=
truth_dets
[
test_idx_set
[
i
]].
size
();
total_true_targets
+=
truth_dets
[
test_idx_set
[
i
]].
size
();
}
}
...
@@ -348,10 +331,7 @@ namespace dlib
...
@@ -348,10 +331,7 @@ namespace dlib
double
precision
,
recall
;
double
precision
,
recall
;
// If the user put an ignore box on the same spot as a truth box then we could end
double
total_hits
=
all_dets
.
size
();
// up with a total_hits value less than correct_hits. So we do this to make sure
// the precision value never goes above 1.
total_hits
=
std
::
max
(
total_hits
,
correct_hits
);
if
(
total_hits
==
0
)
if
(
total_hits
==
0
)
precision
=
1
;
precision
=
1
;
...
...
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