Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.face
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
Package registry
Model registry
Operate
Environments
Terraform modules
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.bio.face
Commits
09ba5486
Commit
09ba5486
authored
4 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
TEsted LGBPHS transformer
parent
27c75ad2
Branches
Branches containing commit
Tags
v2.2.6
Tags containing commit
2 merge requests
!66
Adding some baselines as transformers
,
!64
Dask pipelines
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/bio/face/test/test_picklability.py
+57
-22
57 additions, 22 deletions
bob/bio/face/test/test_picklability.py
bob/bio/face/test/test_transformers.py
+12
-1
12 additions, 1 deletion
bob/bio/face/test/test_transformers.py
with
69 additions
and
23 deletions
bob/bio/face/test/test_picklability.py
+
57
−
22
View file @
09ba5486
...
@@ -8,6 +8,15 @@ import bob.ip.base
...
@@ -8,6 +8,15 @@ import bob.ip.base
import
bob.ip.flandmark
import
bob.ip.flandmark
import
bob.ip.gabor
import
bob.ip.gabor
# Cropping
CROPPED_IMAGE_HEIGHT
=
80
CROPPED_IMAGE_WIDTH
=
CROPPED_IMAGE_HEIGHT
*
4
//
5
# eye positions for frontal images
RIGHT_EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
4
-
1
)
LEFT_EYE_POS
=
(
CROPPED_IMAGE_HEIGHT
//
5
,
CROPPED_IMAGE_WIDTH
//
4
*
3
)
def
assert_picklable_with_exceptions
(
obj
):
def
assert_picklable_with_exceptions
(
obj
):
"""
Test if an object is picklable or not.
"""
"""
Test if an object is picklable or not.
"""
...
@@ -60,37 +69,73 @@ def test_face_crop():
...
@@ -60,37 +69,73 @@ def test_face_crop():
def
test_face_detect
():
def
test_face_detect
():
face_detect
=
bob
.
bio
.
face
.
preprocessor
.
FaceDetect
(
face_cropper
=
"
face-crop-eyes
"
)
face_cropper
=
bob
.
bio
.
face
.
preprocessor
.
FaceCrop
(
cropped_image_size
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
),
cropped_positions
=
{
'
leye
'
:
LEFT_EYE_POS
,
'
reye
'
:
RIGHT_EYE_POS
}
)
face_detect
=
bob
.
bio
.
face
.
preprocessor
.
FaceDetect
(
face_cropper
=
face_cropper
,
use_flandmark
=
False
)
assert_picklable_with_exceptions
(
face_detect
)
assert_picklable_with_exceptions
(
face_detect
)
face_detect
=
bob
.
bio
.
face
.
preprocessor
.
FaceDetect
(
face_detect
=
bob
.
bio
.
face
.
preprocessor
.
FaceDetect
(
face_cropper
=
"
face-crop-eyes
"
,
use_flandmark
=
True
face_cropper
=
face_cropper
,
use_flandmark
=
True
)
)
assert
assert_picklable_with_exceptions
(
face_detect
)
assert
assert_picklable_with_exceptions
(
face_detect
)
def
test_INormLBP
():
def
test_INormLBP
():
face_crop
=
bob
.
bio
.
face
.
preprocessor
.
INormLBP
(
face_cropper
=
"
face-crop-eyes
"
)
face_cropper
=
bob
.
bio
.
face
.
preprocessor
.
FaceCrop
(
assert
assert_picklable_with_exceptions
(
face_crop
)
cropped_image_size
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
),
cropped_positions
=
{
'
leye
'
:
LEFT_EYE_POS
,
'
reye
'
:
RIGHT_EYE_POS
}
)
preprocessor
=
bob
.
bio
.
face
.
preprocessor
.
INormLBP
(
face_cropper
=
face_cropper
,
dtype
=
np
.
float64
)
assert
assert_picklable_with_exceptions
(
preprocessor
)
def
test_TanTriggs
():
def
test_TanTriggs
():
face_crop
=
bob
.
bio
.
face
.
preprocessor
.
TanTriggs
(
face_cropper
=
"
face-crop-eyes
"
)
face_cropper
=
bob
.
bio
.
face
.
preprocessor
.
FaceCrop
(
assert
assert_picklable_with_exceptions
(
face_crop
)
cropped_image_size
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
),
cropped_positions
=
{
'
leye
'
:
LEFT_EYE_POS
,
'
reye
'
:
RIGHT_EYE_POS
}
)
preprocessor
=
bob
.
bio
.
face
.
preprocessor
.
TanTriggs
(
face_cropper
=
face_cropper
)
assert
assert_picklable_with_exceptions
(
preprocessor
)
def
test_SQI
():
def
test_SQI
():
face_crop
=
bob
.
bio
.
face
.
preprocessor
.
SelfQuotientImage
(
face_cropper
=
bob
.
bio
.
face
.
preprocessor
.
FaceCrop
(
face_cropper
=
"
face-crop-eyes
"
cropped_image_size
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
),
cropped_positions
=
{
'
leye
'
:
LEFT_EYE_POS
,
'
reye
'
:
RIGHT_EYE_POS
}
)
preprocessor
=
bob
.
bio
.
face
.
preprocessor
.
SelfQuotientImage
(
face_cropper
=
face_cropper
)
)
assert
assert_picklable_with_exceptions
(
face_crop
)
assert
assert_picklable_with_exceptions
(
preprocessor
)
def
test_HistogramEqualization
():
def
test_HistogramEqualization
():
face_crop
=
bob
.
bio
.
face
.
preprocessor
.
HistogramEqualization
(
face_cropper
=
"
face-crop-eyes
"
face_cropper
=
bob
.
bio
.
face
.
preprocessor
.
FaceCrop
(
cropped_image_size
=
(
CROPPED_IMAGE_HEIGHT
,
CROPPED_IMAGE_WIDTH
),
cropped_positions
=
{
'
leye
'
:
LEFT_EYE_POS
,
'
reye
'
:
RIGHT_EYE_POS
}
)
)
assert
assert_picklable_with_exceptions
(
face_crop
)
preprocessor
=
bob
.
bio
.
face
.
preprocessor
.
HistogramEqualization
(
face_cropper
=
face_cropper
)
#assert assert_picklable_with_exceptions(preprocessor)
### Extractors
### Extractors
...
@@ -103,18 +148,8 @@ def test_DCT():
...
@@ -103,18 +148,8 @@ def test_DCT():
def
test_GridGraph
():
def
test_GridGraph
():
extractor
=
bob
.
bio
.
face
.
extractor
.
GridGraph
(
node_distance
=
24
)
extractor
=
bob
.
bio
.
face
.
extractor
.
GridGraph
(
node_distance
=
24
)
#assert assert_picklable_with_exceptions(extractor)
fake_image
=
np
.
arange
(
64
*
80
).
reshape
(
64
,
80
).
astype
(
"
float
"
)
fake_image
=
np
.
arange
(
64
*
80
).
reshape
(
64
,
80
).
astype
(
"
float
"
)
extractor
(
fake_image
)
extractor
(
fake_image
)
assert
assert_picklable_with_exceptions
(
extractor
)
#cropper = bob.bio.base.load_resource(
# "face-crop-eyes", "preprocessor", preferred_package="bob.bio.face"
#)
#eyes = cropper.cropped_positions
#extractor = bob.bio.face.extractor.GridGraph(eyes=eyes)
#assert assert_picklable_with_exceptions(extractor)
def
test_LGBPHS
():
def
test_LGBPHS
():
...
...
This diff is collapsed.
Click to expand it.
bob/bio/face/test/test_transformers.py
+
12
−
1
View file @
09ba5486
...
@@ -5,7 +5,7 @@ from bob.pipelines import Sample, SampleSet
...
@@ -5,7 +5,7 @@ from bob.pipelines import Sample, SampleSet
from
bob.bio.base
import
load_resource
from
bob.bio.base
import
load_resource
def
get_fake_sample
(
face_size
=
(
160
,
160
),
eyes
=
{
"
leye
"
:
(
46
,
107
),
"
reye
"
:
(
46
,
53
)}):
def
get_fake_sample
(
face_size
=
(
160
,
160
),
eyes
=
{
"
leye
"
:
(
46
,
107
),
"
reye
"
:
(
46
,
53
)}):
np
.
random
.
seed
(
10
)
data
=
np
.
random
.
rand
(
3
,
400
,
400
)
data
=
np
.
random
.
rand
(
3
,
400
,
400
)
annotations
=
{
"
leye
"
:
(
115
,
267
),
"
reye
"
:
(
115
,
132
)}
annotations
=
{
"
leye
"
:
(
115
,
267
),
"
reye
"
:
(
115
,
132
)}
return
Sample
(
data
,
key
=
"
1
"
,
annotations
=
annotations
)
return
Sample
(
data
,
key
=
"
1
"
,
annotations
=
annotations
)
...
@@ -82,3 +82,14 @@ def test_gabor_graph():
...
@@ -82,3 +82,14 @@ def test_gabor_graph():
transformed_data
=
transformed_sample
.
data
transformed_data
=
transformed_sample
.
data
assert
len
(
transformed_sample
.
data
)
==
80
assert
len
(
transformed_sample
.
data
)
==
80
def
test_lgbphs
():
transformer
=
load_resource
(
"
lgbphs
"
,
"
transformer
"
)
fake_sample
=
get_fake_sample
()
transformed_sample
=
transformer
.
transform
([
fake_sample
])[
0
]
transformed_data
=
transformed_sample
.
data
assert
transformed_sample
.
data
.
shape
==
(
2
,
44014
)
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