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
2e619438
Commit
2e619438
authored
Aug 24, 2012
by
Davis King
Browse files
Added an assert to check that the image_scanner_type is generating
legit feature vectors.
parent
8fc37994
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
dlib/svm/structural_svm_object_detection_problem.h
dlib/svm/structural_svm_object_detection_problem.h
+23
-0
No files found.
dlib/svm/structural_svm_object_detection_problem.h
View file @
2e619438
...
@@ -319,6 +319,9 @@ namespace dlib
...
@@ -319,6 +319,9 @@ namespace dlib
hit_truth_table
.
assign
(
hit_truth_table
.
size
(),
false
);
hit_truth_table
.
assign
(
hit_truth_table
.
size
(),
false
);
final_dets
.
clear
();
final_dets
.
clear
();
#ifdef ENABLE_ASSERTS
double
total_score
=
0
;
#endif
// Now figure out which detections jointly maximize the loss and detection score sum. We
// Now figure out which detections jointly maximize the loss and detection score sum. We
// need to take into account the fact that allowing a true detection in the output, while
// need to take into account the fact that allowing a true detection in the output, while
// initially reducing the loss, may allow us to increase the loss later with many duplicate
// initially reducing the loss, may allow us to increase the loss later with many duplicate
...
@@ -339,11 +342,17 @@ namespace dlib
...
@@ -339,11 +342,17 @@ namespace dlib
{
{
hit_truth_table
[
truth
.
second
]
=
true
;
hit_truth_table
[
truth
.
second
]
=
true
;
final_dets
.
push_back
(
dets
[
i
].
second
);
final_dets
.
push_back
(
dets
[
i
].
second
);
#ifdef ENABLE_ASSERTS
total_score
+=
dets
[
i
].
first
;
#endif
loss
-=
loss_per_missed_target
;
loss
-=
loss_per_missed_target
;
}
}
else
else
{
{
final_dets
.
push_back
(
dets
[
i
].
second
);
final_dets
.
push_back
(
dets
[
i
].
second
);
#ifdef ENABLE_ASSERTS
total_score
+=
dets
[
i
].
first
;
#endif
loss
+=
loss_per_false_alarm
;
loss
+=
loss_per_false_alarm
;
}
}
}
}
...
@@ -352,6 +361,9 @@ namespace dlib
...
@@ -352,6 +361,9 @@ namespace dlib
{
{
// didn't hit anything
// didn't hit anything
final_dets
.
push_back
(
dets
[
i
].
second
);
final_dets
.
push_back
(
dets
[
i
].
second
);
#ifdef ENABLE_ASSERTS
total_score
+=
dets
[
i
].
first
;
#endif
loss
+=
loss_per_false_alarm
;
loss
+=
loss_per_false_alarm
;
}
}
}
}
...
@@ -361,6 +373,17 @@ namespace dlib
...
@@ -361,6 +373,17 @@ namespace dlib
for
(
unsigned
long
i
=
0
;
i
<
final_dets
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
final_dets
.
size
();
++
i
)
scanner
.
get_feature_vector
(
final_dets
[
i
],
current_solution
,
psi
);
scanner
.
get_feature_vector
(
final_dets
[
i
],
current_solution
,
psi
);
#ifdef ENABLE_ASSERTS
const
double
psi_score
=
dot
(
psi
,
current_solution
);
DLIB_ASSERT
(
std
::
abs
(
psi_score
-
total_score
)
*
std
::
max
(
psi_score
,
total_score
)
<
1e-10
,
"
\t
The get_feature_vector() and detect() methods of image_scanner_type are not in sync."
<<
"
\n\t
The relative error is too large to be attributed to rounding error."
<<
"
\n\t
relative error: "
<<
std
::
abs
(
psi_score
-
total_score
)
*
std
::
max
(
psi_score
,
total_score
)
<<
"
\n\t
psi_score: "
<<
psi_score
<<
"
\n\t
total_score: "
<<
total_score
);
#endif
psi
(
scanner
.
get_num_dimensions
())
=
-
1.0
*
final_dets
.
size
();
psi
(
scanner
.
get_num_dimensions
())
=
-
1.0
*
final_dets
.
size
();
}
}
...
...
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