Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
3a0a63da
Commit
3a0a63da
authored
Dec 08, 2017
by
Davis King
Browse files
A little bit of cleanup
parent
07febbc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
python_examples/face_jitter.py
python_examples/face_jitter.py
+9
-8
No files found.
python_examples/face_jitter.py
View file @
3a0a63da
#!/usr/bin/python
#!/usr/bin/python
# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
#
#
# This example shows how faces are jittered and data augmentation using dlib's disturb_colors
# This example shows how faces were jittered and augmented to create training
# takes place during the training of a face recognition model using metric learning.
# data for dlib's face recognition model. It takes an input image and
# disturbs the colors as well as applies random translations, rotations, and
# scaling.
#
#
# COMPILING/INSTALLING THE DLIB PYTHON INTERFACE
# COMPILING/INSTALLING THE DLIB PYTHON INTERFACE
# You can install dlib using the command:
# You can install dlib using the command:
...
@@ -25,7 +28,6 @@
...
@@ -25,7 +28,6 @@
# Also note that this example requires OpenCV and Numpy which can be installed
# Also note that this example requires OpenCV and Numpy which can be installed
# via the command:
# via the command:
# pip install opencv-python numpy
# pip install opencv-python numpy
# Or downloaded from http://opencv.org/releases.html
#
#
# The image file used in this example is in the public domain:
# The image file used in this example is in the public domain:
# https://commons.wikimedia.org/wiki/File:Tom_Cruise_avp_2014_4.jpg
# https://commons.wikimedia.org/wiki/File:Tom_Cruise_avp_2014_4.jpg
...
@@ -81,16 +83,15 @@ for detection in dets:
...
@@ -81,16 +83,15 @@ for detection in dets:
# Get the aligned face image and show it
# Get the aligned face image and show it
image
=
dlib
.
get_face_chip
(
img
,
faces
[
0
],
size
=
320
)
image
=
dlib
.
get_face_chip
(
img
,
faces
[
0
],
size
=
320
)
cv_rgb_image
=
np
.
array
(
image
).
astype
(
np
.
uint8
)
cv_bgr_img
=
cv2
.
cvtColor
(
image
,
cv2
.
COLOR_RGB2BGR
)
cv_bgr_img
=
cv2
.
cvtColor
(
cv_rgb_image
,
cv2
.
COLOR_RGB2BGR
)
cv2
.
imshow
(
'image'
,
cv_bgr_img
)
cv2
.
imshow
(
'image'
,
cv_bgr_img
)
cv2
.
waitKey
(
0
)
cv2
.
waitKey
(
0
)
# Show 5 jittered images without data augmentation
# Show 5 jittered images without data augmentation
jittered_images
=
dlib
.
jitter_image
(
cv_rgb_
image
,
num_jitters
=
5
)
jittered_images
=
dlib
.
jitter_image
(
image
,
num_jitters
=
5
)
show_jittered_images
(
jittered_images
)
show_jittered_images
(
jittered_images
)
# Show 5 jittered images with data augmentation
# Show 5 jittered images with data augmentation
jittered_images
=
dlib
.
jitter_image
(
cv_rgb_
image
,
num_jitters
=
5
,
disturb_colors
=
True
)
jittered_images
=
dlib
.
jitter_image
(
image
,
num_jitters
=
5
,
disturb_colors
=
True
)
show_jittered_images
(
jittered_images
)
show_jittered_images
(
jittered_images
)
cv2
.
destroyAllWindows
()
cv2
.
destroyAllWindows
()
\ No newline at end of file
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