Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.boosting
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.learn.boosting
Commits
1a51ef4d
Commit
1a51ef4d
authored
11 years ago
by
Rakesh MEHTA
Browse files
Options
Downloads
Patches
Plain Diff
Comments added to features
parent
36f5181d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xbob/boosting/core/gaussiantrainer.py
+0
-61
0 additions, 61 deletions
xbob/boosting/core/gaussiantrainer.py
xbob/boosting/features/local_feature.py
+17
-12
17 additions, 12 deletions
xbob/boosting/features/local_feature.py
with
17 additions
and
73 deletions
xbob/boosting/core/gaussiantrainer.py
deleted
100644 → 0
+
0
−
61
View file @
36f5181d
class
GaussianMachine
():
def
__init__
(
self
,
num_classes
):
self
.
means
=
numpy
.
zeros
(
num_classes
)
self
.
variance
=
numpy
.
zeros
(
num_classes
)
self
.
selected_index
=
0
def
get_weak_scores
(
self
,
features
):
num_classes
=
self
.
means
.
shape
[
0
]
for
i
in
range
(
num_classes
):
mean_i
=
means
[
i
]
variance_i
=
variance
[
i
]
feature_i
=
features
[:,
i
]
demon
=
numpy
.
sqrt
(
2
*
numpy
.
pi
*
variance_i
)
scores
[
i
]
=
numpy
.
exp
(
-
(((
feature_i
-
mean_i
)
**
2
)
/
2
*
variance_i
))
return
scores
class
GaussianTrainer
():
def
__init__
(
self
,
num_classes
):
self
.
num_classes
=
num_classes
def
compute_weak_trainer
(
self
,
features
,
loss_grad
):
num_features
=
features
.
shape
[
1
]
means
=
numpy
.
zeros
([
num_features
,
self
.
num_classes
])
variances
=
numpy
.
zeros
([
num_features
,
self
.
num_classes
])
summed_loss
=
numpy
.
zeros
(
num_features
)
gauss_machine
=
GaussianMachine
()
for
feature_index
in
range
(
num_features
)
single_feature
=
features
[:,
feature_index
]
means
[
i
,;],
variances
[
i
,:],
loss
[
i
]
=
compute_current_loss
(
single_feature
,
classes
,
loss_grad
)
gauss_machine
.
selected_index
=
numpy
.
argmin
(
loss
)
gauss_machine
.
means
=
means
[
optimum_index
,:]
gauss_machine
.
variance
=
variances
[
optimum_index
,:]
def
compute_current_loss
(
feature
,
classes
,
loss_grad
):
num_samples
=
feature
.
shape
[
0
]
scores
=
numpy
.
zeros
([
num_samples
,
self
.
num_classes
])
for
class_index
in
range
(
self
.
num_classes
):
samples_i
=
feature
[
loss_grad
[:,
class_index
]
<
0
]
mean
[
i
]
=
numpy
.
mean
(
samples_i
)
variance
[
i
]
=
numpy
.
std
(
samples_i
)
**
2
scores
[:,
class_index
]
=
numpy
.
exp
(
-
(((
feature_i
-
mean_i
)
**
2
)
/
2
*
variance_i
))
scores_sum
=
numpy
.
sum
(
scores
)
return
mean
,
variance
,
scores_sum
This diff is collapsed.
Click to expand it.
xbob/boosting/features/local_feature.py
+
17
−
12
View file @
1a51ef4d
...
@@ -37,7 +37,7 @@ class lbp_feature():
...
@@ -37,7 +37,7 @@ class lbp_feature():
img: Input images
img: Input images
return:
return:
int
_img
: The integral image of the input image.
"""
int
egral_xy
: The integral image of the input image.
"""
integral_y
=
numpy
.
cumsum
(
img
,
0
)
integral_y
=
numpy
.
cumsum
(
img
,
0
)
integral_xy
=
numpy
.
cumsum
(
integral_y
,
1
)
integral_xy
=
numpy
.
cumsum
(
integral_y
,
1
)
...
@@ -100,14 +100,12 @@ class lbp_feature():
...
@@ -100,14 +100,12 @@ class lbp_feature():
def
lbp
(
self
,
block_sum
):
def
lbp
(
self
,
block_sum
):
"""
Function to compute the LBP for a image at single scale.
"""
Function to compute the LBP
(3x3)
for a image at single scale.
The LBP features of the given image is computed and the feature map is returned
The LBP features of the given image is computed and the feature map is returned
Inputs:
Inputs:
coord: The coordinates specify the neighbour to be considered.
block_sum: The image with each pixel representing the sum of a block.
feature_map_dimx: feature map
'
s dimension along the columns.
feature_map_dimy: Feature maps dimension along the rows.
Return:
Return:
feature_map: The lbp feature map
feature_map: The lbp feature map
...
@@ -129,9 +127,7 @@ class lbp_feature():
...
@@ -129,9 +127,7 @@ class lbp_feature():
The tLBP features of the given image is computed and the feature map is returned
The tLBP features of the given image is computed and the feature map is returned
Inputs:
Inputs:
coord: The coordinates specify the neighbour to be considered.
block_sum: The image with each pixel representing the sum of a block.
feature_map_dimx: feature map
'
s dimension along the columns.
feature_map_dimy: Feature maps dimension along the rows.
Return:
Return:
feature_map: The lbp feature map
feature_map: The lbp feature map
...
@@ -158,9 +154,7 @@ class lbp_feature():
...
@@ -158,9 +154,7 @@ class lbp_feature():
The dLBP features of the given image is computed and the feature map is returned
The dLBP features of the given image is computed and the feature map is returned
Inputs:
Inputs:
coord: The coordinates specify the neighbour to be considered.
block_sum: The image with each pixel representing the sum of a block.
feature_map_dimx: feature map
'
s dimension along the columns.
feature_map_dimy: Feature maps dimension along the rows.
Return:
Return:
feature_map: The lbp feature map
feature_map: The lbp feature map
...
@@ -189,7 +183,7 @@ class lbp_feature():
...
@@ -189,7 +183,7 @@ class lbp_feature():
The mLBP features of the given image is computed and the feature map is returned.
The mLBP features of the given image is computed and the feature map is returned.
Inputs:
Inputs:
block_sum: The image
that to apply mlbp operator on
.
block_sum: The image
with each pixel representing the sum of a block
.
Return:
Return:
feature_map: The lbp feature map
feature_map: The lbp feature map
...
@@ -234,6 +228,17 @@ class lbp_feature():
...
@@ -234,6 +228,17 @@ class lbp_feature():
return
feature_vector
.
shape
[
0
]
return
feature_vector
.
shape
[
0
]
def
get_map_dimension
(
self
,
block_sum
):
def
get_map_dimension
(
self
,
block_sum
):
"""
The function computes the dimension of the LBP (R = 1, P = 8) type feature image
The feature image returned by LBP with radius R is less than the image size by 2*R -1, for
R = 1, the feature map is smaller than the image by 2 pixel in both direction.
Input:
block_sum: The image with each pixel representing the sum of a block.
Return:
feature_map_dimx, feature_map_dimy : The dimensions of the feature map.
"""
# Initialize the size of the final feature map that will be obtained
# Initialize the size of the final feature map that will be obtained
feature_map_dimy
=
block_sum
.
shape
[
0
]
-
2
feature_map_dimy
=
block_sum
.
shape
[
0
]
-
2
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment