Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.face
Commits
7e74b2f0
Commit
7e74b2f0
authored
Apr 24, 2020
by
Tiago de Freitas Pereira
Browse files
Removing traces of functools
parent
b1aff89f
Pipeline
#39178
failed with stage
in 4 minutes and 59 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/face/config/preprocessor/face_detect.py
View file @
7e74b2f0
#!/usr/bin/env python
import
bob.bio.face
import
functools
# Detects the face and eye landmarks crops it using the detected eyes
preprocessor
=
functools
.
partial
(
bob
.
bio
.
face
.
preprocessor
.
FaceDetect
,
preprocessor
=
bob
.
bio
.
face
.
preprocessor
.
FaceDetect
(
face_cropper
=
'face-crop-eyes'
,
use_flandmark
=
True
)
# Detects the face amd crops it without eye detection
preprocessor_no_eyes
=
functools
.
partial
(
bob
.
bio
.
face
.
preprocessor
.
FaceDetect
,
preprocessor_no_eyes
=
bob
.
bio
.
face
.
preprocessor
.
FaceDetect
(
face_cropper
=
'face-crop-eyes'
,
use_flandmark
=
False
)
bob/bio/face/preprocessor/utils.py
View file @
7e74b2f0
import
bob.bio.base
import
six
import
functools
def
load_cropper
(
face_cropper
):
from
.FaceCrop
import
FaceCrop
from
.FaceDetect
import
FaceDetect
if
face_cropper
is
None
:
cropper
=
None
elif
isinstance
(
face_cropper
,
six
.
string_types
):
cropper
=
bob
.
bio
.
base
.
load_resource
(
face_cropper
,
'preprocessor'
)
# In Dask, face_cropper is a functools. TODO: check that the object inside functool is valid
elif
isinstance
(
face_cropper
,
(
FaceCrop
,
FaceDetect
,
functools
.
partial
)):
cropper
=
face_cropper
else
:
raise
ValueError
(
"The given face cropper type is not understood"
)
assert
cropper
is
None
or
isinstance
(
cropper
,
(
FaceCrop
,
FaceDetect
))
or
isinstance
(
cropper
,
functools
.
partial
)
return
cropper
from
.FaceCrop
import
FaceCrop
from
.FaceDetect
import
FaceDetect
if
face_cropper
is
None
:
cropper
=
None
elif
isinstance
(
face_cropper
,
six
.
string_types
):
cropper
=
bob
.
bio
.
base
.
load_resource
(
face_cropper
,
"preprocessor"
)
else
:
raise
ValueError
(
"The given face cropper type is not understood"
)
assert
(
cropper
is
None
or
isinstance
(
cropper
,
(
FaceCrop
,
FaceDetect
))
or
isinstance
(
cropper
,
functools
.
partial
)
)
return
cropper
def
load_cropper_only
(
face_cropper
):
from
.FaceCrop
import
FaceCrop
if
face_cropper
is
None
:
cropper
=
None
elif
isinstance
(
face_cropper
,
six
.
string_types
):
cropper
=
bob
.
bio
.
base
.
load_resource
(
face_cropper
,
'preprocessor'
)
elif
isinstance
(
face_cropper
,
FaceCrop
):
cropper
=
face_cropper
else
:
raise
ValueError
(
"The given face cropper type is not understood"
)
assert
cropper
is
None
or
isinstance
(
cropper
,
FaceCrop
)
return
cropper
from
.FaceCrop
import
FaceCrop
if
face_cropper
is
None
:
cropper
=
None
elif
isinstance
(
face_cropper
,
six
.
string_types
):
cropper
=
bob
.
bio
.
base
.
load_resource
(
face_cropper
,
"preprocessor"
)
elif
isinstance
(
face_cropper
,
FaceCrop
):
cropper
=
face_cropper
else
:
raise
ValueError
(
"The given face cropper type is not understood"
)
assert
cropper
is
None
or
isinstance
(
cropper
,
FaceCrop
)
return
cropper
bob/bio/face/test/test_preprocessors.py
View file @
7e74b2f0
...
...
@@ -119,7 +119,6 @@ def test_face_crop():
def
test_face_detect
():
image
,
annotation
=
_image
(),
None
cropper
=
bob
.
bio
.
base
.
load_resource
(
'face-detect'
,
'preprocessor'
,
preferred_package
=
'bob.bio.face'
)
assert
isinstance
(
cropper
,
bob
.
bio
.
face
.
preprocessor
.
FaceDetect
)
assert
isinstance
(
cropper
,
bob
.
bio
.
face
.
preprocessor
.
Base
)
...
...
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