Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.face
Commits
75261a6e
Commit
75261a6e
authored
May 31, 2021
by
Laurent COLBOIS
Browse files
Changed cropping examples to be directly generated by code
parent
ea461fff
Pipeline
#51128
passed with stage
in 26 minutes and 48 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/face/config/baseline/helpers.py
View file @
75261a6e
from
sklearn.pipeline
import
make_pipeline
from
bob.pipelines
import
wrap
from
bob.bio.face
.helpers
import
face_crop_solv
er
from
bob.bio.face
import
help
er
s
import
numpy
as
np
import
logging
...
...
@@ -237,7 +237,7 @@ def make_cropper(
transform_extra_arguments for wrapping the cropper with a SampleWrapper.
"""
face_cropper
=
face_crop_solver
(
face_cropper
=
helpers
.
face_crop_solver
(
cropped_image_size
=
cropped_image_size
,
cropped_positions
=
cropped_positions
,
fixed_positions
=
fixed_positions
,
...
...
doc/conf.py
View file @
75261a6e
...
...
@@ -26,7 +26,7 @@ extensions = [
'sphinx.ext.napoleon'
,
'sphinx.ext.viewcode'
,
'sphinx.ext.mathjax'
,
#
'matplotlib.sphinxext.plot_directive'
'matplotlib.sphinxext.plot_directive'
]
# Be picky about warnings
...
...
doc/faq.rst
View file @
75261a6e
...
...
@@ -38,35 +38,6 @@ There are currently three available modes :
We present hereafter a visual example of those crops for the `eyes-center` annotation type.
.. figure:: img/cropping_example_source.png
:height: 250px
:align: left
:alt: Source image
:figclass: align-center
Original face image
.. figure:: img/cropping_example_legacy.png
:height: 250px
:align: right
:alt: Legacy crop
:figclass: align-center
Legacy crop (160 x 128)
.. figure:: img/cropping_example_dnn.png
:height: 250px
:align: left
:alt: DNN crop
:figclass: align-center
DNN crop (160 x 160)
.. figure:: img/cropping_example_pad.png
:height: 250px
:align: right
:alt: PAD crop
:figclass: align-center
PAD crop (160 x 160)
.. plot:: plot/default_crops.py
:include-source: True
\ No newline at end of file
doc/img/cropping_example_dnn.png
deleted
100644 → 0
View file @
ea461fff
44.1 KB
doc/img/cropping_example_legacy.png
deleted
100644 → 0
View file @
ea461fff
34.4 KB
doc/img/cropping_example_pad.png
deleted
100644 → 0
View file @
ea461fff
42.6 KB
doc/plot/default_crops.py
0 → 100644
View file @
75261a6e
import
bob.io.image
from
bob.bio.face.helpers
import
get_default_cropped_positions
from
bob.bio.face.preprocessor
import
FaceCrop
import
matplotlib.pyplot
as
plt
src
=
bob
.
io
.
image
.
load
(
"../img/cropping_example_source.png"
)
modes
=
[
"legacy"
,
"dnn"
,
"pad"
]
cropped_images
=
[]
SIZE
=
160
# Pick cropping mode
for
mode
in
modes
:
if
mode
==
"legacy"
:
cropped_image_size
=
(
SIZE
,
4
*
SIZE
//
5
)
else
:
cropped_image_size
=
(
SIZE
,
SIZE
)
annotation_type
=
"eyes-center"
# Load default cropped positions
cropped_positions
=
get_default_cropped_positions
(
mode
,
cropped_image_size
,
annotation_type
)
# Instanciate cropper and crop
cropper
=
FaceCrop
(
cropped_image_size
=
cropped_image_size
,
cropped_positions
=
cropped_positions
,
fixed_positions
=
{
"reye"
:
(
480
,
380
),
"leye"
:
(
480
,
650
)},
color_channel
=
"rgb"
,
)
cropped_images
.
append
(
cropper
.
transform
([
src
])[
0
].
astype
(
"uint8"
))
# Visualize cropped images
fig
,
axes
=
plt
.
subplots
(
2
,
2
,
figsize
=
(
10
,
10
))
for
i
,
(
img
,
label
)
in
enumerate
(
zip
([
src
]
+
cropped_images
,
[
"original"
]
+
modes
)):
ax
=
axes
[
i
//
2
,
i
%
2
]
ax
.
axis
(
"off"
)
ax
.
imshow
(
bob
.
io
.
image
.
to_matplotlib
(
img
))
ax
.
set_title
(
label
)
Write
Preview
Supports
Markdown
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