Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.pad.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.pad.face
Commits
6a40f750
Commit
6a40f750
authored
3 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
Remove deprecated PadFile
parent
5c662e1c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!121
Remove deprecated PadFile
Pipeline
#58891
failed
3 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bob/pad/face/database/database.py
+0
-1
0 additions, 1 deletion
bob/pad/face/database/database.py
bob/pad/face/script/statistics.py
+47
-31
47 additions, 31 deletions
bob/pad/face/script/statistics.py
bob/pad/face/utils/load_utils.py
+8
-8
8 additions, 8 deletions
bob/pad/face/utils/load_utils.py
with
55 additions
and
40 deletions
bob/pad/face/database/database.py
+
0
−
1
View file @
6a40f750
from
functools
import
partial
import
os
from
bob.pad.base.database
import
PadFile
import
bob.bio.video
from
bob.db.base.annotations
import
read_annotation_file
from
sklearn.preprocessing
import
FunctionTransformer
...
...
This diff is collapsed.
Click to expand it.
bob/pad/face/script/statistics.py
+
47
−
31
View file @
6a40f750
...
...
@@ -5,21 +5,35 @@ import click
import
numpy
as
np
from
os.path
import
expanduser
from
bob.extension.scripts.click_helper
import
(
verbosity_option
,
ConfigCommand
,
ResourceOption
)
verbosity_option
,
ConfigCommand
,
ResourceOption
,
)
from
bob.bio.face.annotator
import
(
bounding_box_from_annotation
,
expected_eye_positions
,
BoundingBox
)
bounding_box_from_annotation
,
expected_eye_positions
,
BoundingBox
,
)
logger
=
logging
.
getLogger
(
__name__
)
BF
=
'
Bona Fide
'
PA
=
'
Presentation Attack
'
@click.command
(
entry_point_group
=
'
bob.bio.config
'
,
cls
=
ConfigCommand
)
@click.option
(
'
--database
'
,
'
-d
'
,
required
=
True
,
cls
=
ResourceOption
,
entry_point_group
=
'
bob.pad.database
'
)
@click.option
(
'
-o
'
,
'
--output
'
,
default
=
'
face_sizes.png
'
)
@click.option
(
'
--database-directories-file
'
,
cls
=
ResourceOption
,
default
=
expanduser
(
'
~/.bob_bio_databases.txt
'
))
BF
=
"
Bona Fide
"
PA
=
"
Presentation Attack
"
@click.command
(
entry_point_group
=
"
bob.bio.config
"
,
cls
=
ConfigCommand
)
@click.option
(
"
--database
"
,
"
-d
"
,
required
=
True
,
cls
=
ResourceOption
,
entry_point_group
=
"
bob.pad.database
"
,
)
@click.option
(
"
-o
"
,
"
--output
"
,
default
=
"
face_sizes.png
"
)
@click.option
(
"
--database-directories-file
"
,
cls
=
ResourceOption
,
default
=
expanduser
(
"
~/.bob_bio_databases.txt
"
),
)
@verbosity_option
(
cls
=
ResourceOption
)
def
statistics
(
database
,
output
,
database_directories_file
,
**
kwargs
):
"""
Statistics on face size in video databases.
...
...
@@ -46,10 +60,10 @@ def statistics(database, output, database_directories_file, **kwargs):
command-line (see below) will override the values of
configuration files.
"""
logger
.
debug
(
'
database: %s
'
,
database
)
logger
.
debug
(
'
output: %s
'
,
output
)
logger
.
debug
(
'
database_directories_file: %s
'
,
database_directories_file
)
logger
.
debug
(
'
kwargs: %s
'
,
kwargs
)
logger
.
debug
(
"
database: %s
"
,
database
)
logger
.
debug
(
"
output: %s
"
,
output
)
logger
.
debug
(
"
database_directories_file: %s
"
,
database_directories_file
)
logger
.
debug
(
"
kwargs: %s
"
,
kwargs
)
# Some databases need their original_directory to be replaced
database
.
replace_directories
(
database_directories_file
)
...
...
@@ -63,7 +77,7 @@ def statistics(database, output, database_directories_file, **kwargs):
for
i
,
biofile
in
enumerate
(
biofiles
):
for
annot
in
database
.
annotations
(
biofile
).
values
():
# get the bounding box
for
source
in
(
'
direct
'
,
'
eyes
'
,
None
):
for
source
in
(
"
direct
"
,
"
eyes
"
,
None
):
try
:
bbx
=
bounding_box_from_annotation
(
source
=
source
,
**
annot
)
break
...
...
@@ -80,6 +94,7 @@ def statistics(database, output, database_directories_file, **kwargs):
if
output
:
import
matplotlib.pyplot
as
plt
# from matplotlib.backends.backend_pdf import PdfPages
# pp = PdfPages(output)
...
...
@@ -88,20 +103,21 @@ def statistics(database, output, database_directories_file, **kwargs):
face_sizes
=
np
.
array
(
face_sizes
)
# get statistics on the face sizes
for
name
,
array
in
(
(
'
Height
'
,
face_sizes
[:,
0
]),
(
'
Width
'
,
face_sizes
[:,
1
]),
(
"
Height
"
,
face_sizes
[:,
0
]),
(
"
Width
"
,
face_sizes
[:,
1
]),
):
click
.
echo
(
'
min: {}, mean: {}, max: {}, std: {:.1f} for {}
'
.
format
(
array
.
min
(),
int
(
array
.
mean
()),
array
.
max
(),
array
.
std
(),
name
))
click
.
echo
(
"
min: {}, mean: {}, max: {}, std: {:.1f} for {}
"
.
format
(
array
.
min
(),
int
(
array
.
mean
()),
array
.
max
(),
array
.
std
(),
name
)
)
# print the average eye distance assuming bounding boxes are from
# bob.ip.facedetect or the annotations had eye locations in them
bbx
=
BoundingBox
((
0
,
0
),
face_sizes
.
mean
(
axis
=
0
))
annot
=
expected_eye_positions
(
bbx
)
eye_distance
=
np
.
linalg
.
norm
(
np
.
array
(
annot
[
'
reye
'
])
-
np
.
array
(
annot
[
'
leye
'
]))
click
.
echo
(
'
Average eye locations: {}
'
.
format
(
annot
))
click
.
echo
(
'
Average eye distance: {}
'
.
format
(
int
(
eye_distance
)))
eye_distance
=
np
.
linalg
.
norm
(
np
.
array
(
annot
[
"
reye
"
])
-
np
.
array
(
annot
[
"
leye
"
]))
click
.
echo
(
"
Average eye locations: {}
"
.
format
(
annot
))
click
.
echo
(
"
Average eye distance: {}
"
.
format
(
int
(
eye_distance
)))
if
not
output
:
continue
...
...
@@ -124,12 +140,12 @@ def statistics(database, output, database_directories_file, **kwargs):
# ax = Axes3D(fig)
# ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis)
plt
.
hist
(
face_sizes
[:,
1
],
density
=
True
,
bins
=
'
auto
'
,
label
=
attack_type
,
alpha
=
0.5
)
plt
.
hist
(
face_sizes
[:,
1
],
density
=
True
,
bins
=
"
auto
"
,
label
=
attack_type
,
alpha
=
0.5
)
if
output
:
plt
.
xlabel
(
'
Width of faces
'
)
plt
.
ylabel
(
'
Probability Density
'
)
plt
.
xlabel
(
"
Width of faces
"
)
plt
.
ylabel
(
"
Probability Density
"
)
plt
.
tight_layout
()
plt
.
legend
()
...
...
This diff is collapsed.
Click to expand it.
bob/pad/face/utils/load_utils.py
+
8
−
8
View file @
6a40f750
from
bob.bio.face.annotator
import
min_face_size_validator
from
bob.bio.video.annotator
import
normalize_annotations
from
imageio
import
get_reader
from
bob.ip.base
import
scale
,
block
,
block_output_shape
,
block_generator
from
bob.ip.color
import
rgb_to_yuv
,
rgb_to_hsv
from
bob.bio.face.annotator
import
bounding_box_from_annotation
import
random
from
collections
import
OrderedDict
from
functools
import
partial
import
numpy
import
random
import
bob.io.image
import
numpy
from
bob.bio.face.annotator
import
bounding_box_from_annotation
,
min_face_size_validator
from
bob.bio.video.annotator
import
normalize_annotations
from
bob.ip.base
import
block
,
block_generator
,
block_output_shape
,
scale
from
bob.ip.color
import
rgb_to_hsv
,
rgb_to_yuv
from
imageio
import
get_reader
def
frames
(
path
):
...
...
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