Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
16ae5eac
Commit
16ae5eac
authored
Sep 09, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added functions to the interface that allow a user to control the relative
loss from a false alarm vs. a missed detection.
parent
aa88a574
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
14 deletions
+101
-14
structural_svm_object_detection_problem.h
dlib/svm/structural_svm_object_detection_problem.h
+49
-4
structural_svm_object_detection_problem_abstract.h
dlib/svm/structural_svm_object_detection_problem_abstract.h
+52
-10
No files found.
dlib/svm/structural_svm_object_detection_problem.h
View file @
16ae5eac
...
...
@@ -3,6 +3,7 @@
#ifndef DLIB_STRUCTURAL_SVM_ObJECT_DETECTION_PROBLEM_H__
#define DLIB_STRUCTURAL_SVM_ObJECT_DETECTION_PROBLEM_H__
#include "structural_svm_object_detection_problem_abstract.h"
#include "../matrix.h"
#include "structural_svm_problem_threaded.h"
#include <sstream>
...
...
@@ -33,7 +34,9 @@ namespace dlib
boxes_overlap
(
overlap_tester
),
images
(
images_
),
rects
(
truth_rects
),
overlap_eps
(
0
.
5
)
overlap_eps
(
0
.
5
),
loss_per_false_alarm
(
1
),
loss_per_missed_target
(
1
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
is_learning_problem
(
images_
,
truth_rects
)
&&
...
...
@@ -62,7 +65,7 @@ namespace dlib
{
// make sure requires clause is not broken
DLIB_ASSERT
(
0
<
eps
&&
eps
<
1
,
"
\t
structural_svm_object_detection_problem::set_overlap_eps(eps)"
"
\t
void
structural_svm_object_detection_problem::set_overlap_eps(eps)"
<<
"
\n\t
Invalid inputs were given to this function "
<<
"
\n\t
eps: "
<<
eps
<<
"
\n\t
this: "
<<
this
...
...
@@ -77,6 +80,48 @@ namespace dlib
return
overlap_eps
;
}
double
get_loss_per_missed_target
(
)
const
{
return
loss_per_missed_target
;
}
void
set_loss_per_missed_target
(
double
loss
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
loss
>
0
,
"
\t
void structural_svm_object_detection_problem::set_loss_per_missed_target(loss)"
<<
"
\n\t
Invalid inputs were given to this function "
<<
"
\n\t
loss: "
<<
loss
<<
"
\n\t
this: "
<<
this
);
loss_per_missed_target
=
loss
;
}
double
get_loss_per_false_alarm
(
)
const
{
return
loss_per_false_alarm
;
}
void
set_loss_per_false_alarm
(
double
loss
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
loss
>
0
,
"
\t
void structural_svm_object_detection_problem::set_loss_per_false_alarm(loss)"
<<
"
\n\t
Invalid inputs were given to this function "
<<
"
\n\t
loss: "
<<
loss
<<
"
\n\t
this: "
<<
this
);
loss_per_false_alarm
=
loss
;
}
private
:
virtual
long
get_num_dimensions
(
)
const
...
...
@@ -161,8 +206,6 @@ namespace dlib
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>
dets
;
const
double
thresh
=
current_solution
(
scanner
.
get_num_dimensions
());
const
double
loss_per_false_alarm
=
1
;
const
double
loss_per_missed_target
=
1
;
scanner
.
load
(
images
[
idx
]);
scanner
.
detect
(
current_solution
,
dets
,
thresh
-
loss_per_false_alarm
);
...
...
@@ -309,6 +352,8 @@ namespace dlib
unsigned
long
max_num_dets
;
double
overlap_eps
;
double
loss_per_false_alarm
;
double
loss_per_missed_target
;
};
// ----------------------------------------------------------------------------------------
...
...
dlib/svm/structural_svm_object_detection_problem_abstract.h
View file @
16ae5eac
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#
if
ndef DLIB_STRUCTURAL_SVM_ObJECT_DETECTION_PROBLEM_ABSTRACT_H__
#
define
DLIB_STRUCTURAL_SVM_ObJECT_DETECTION_PROBLEM_ABSTRACT_H__
#
u
ndef DLIB_STRUCTURAL_SVM_ObJECT_DETECTION_PROBLEM_ABSTRACT_H__
#
ifdef
DLIB_STRUCTURAL_SVM_ObJECT_DETECTION_PROBLEM_ABSTRACT_H__
#include "../matrix.h"
#include "structural_svm_problem_threaded_abstract.h"
...
...
@@ -45,15 +45,18 @@ namespace dlib
per image and the measure of loss is different from what is described in
the paper.
In particular, the loss is the number of false detections plus the number
of missed targets. A detection is considered a false detection if it doesn't
overlap with any of the ground truth rectangles or if it is a duplicate
detection of a truth rectangle. A detection "misses a target" if it doesn't
overlap with the truth rectangle for any target. Finally, for the purposes
of calculating loss, overlap is determined using the following formula,
rectangles A and B overlap if and only if:
In particular, the loss is measured as follows:
let FA == the number of false alarms produced by a labeling of an image.
let MT == the number of targets missed by a labeling of an image.
Then the loss for a particular labeling is the quantity:
FA*get_loss_per_false_alarm() + MT*get_loss_per_missed_target()
A detection is considered a false alarm if it doesn't overlap with any
of the ground truth rectangles or if it is a duplicate detection of a
truth rectangle. Finally, for the purposes of calculating loss, overlap
is determined using the following formula, rectangles A and B overlap
if and only if:
A.intersect(B).area()/(A+B).area() > get_overlap_eps()
!*/
public
:
...
...
@@ -81,6 +84,8 @@ namespace dlib
- This object will use num_threads threads during the optimization
procedure. You should set this parameter equal to the number of
available processing cores on your machine.
- #get_loss_per_missed_target() == 1
- #get_loss_per_false_alarm() == 1
!*/
void
set_overlap_eps
(
...
...
@@ -101,6 +106,43 @@ namespace dlib
as overlapping with a ground truth rectangle.
!*/
double
get_loss_per_missed_target
(
)
const
;
/*!
ensures
- returns the amount of loss experienced for failing to detect one of the
targets.
!*/
void
set_loss_per_missed_target
(
double
loss
);
/*!
requires
- loss > 0
ensures
- #get_loss_per_missed_target() == loss
!*/
double
get_loss_per_false_alarm
(
)
const
;
/*!
ensures
- returns the amount of loss experienced for emitting a false alarm detection.
Or in other words, the loss for generating a detection that doesn't correspond
to one of the truth rectangles.
!*/
void
set_loss_per_false_alarm
(
double
loss
);
/*!
requires
- loss > 0
ensures
- #get_loss_per_false_alarm() == loss
!*/
};
// ----------------------------------------------------------------------------------------
...
...
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