Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
3a0a63da
Commit
3a0a63da
authored
Dec 08, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A little bit of cleanup
parent
07febbc9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
face_jitter.py
python_examples/face_jitter.py
+9
-9
No files found.
python_examples/face_jitter.py
View file @
3a0a63da
#!/usr/bin/python
# 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
# takes place during the training of a face recognition model using metric learning.
# This example shows how faces were jittered and augmented to create training
# 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
# You can install dlib using the command:
...
...
@@ -25,7 +28,6 @@
# Also note that this example requires OpenCV and Numpy which can be installed
# via the command:
# 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:
# https://commons.wikimedia.org/wiki/File:Tom_Cruise_avp_2014_4.jpg
...
...
@@ -81,16 +83,15 @@ for detection in dets:
# Get the aligned face image and show it
image
=
dlib
.
get_face_chip
(
img
,
faces
[
0
],
size
=
320
)
cv_rgb_image
=
np
.
array
(
image
)
.
astype
(
np
.
uint8
)
cv_bgr_img
=
cv2
.
cvtColor
(
cv_rgb_image
,
cv2
.
COLOR_RGB2BGR
)
cv_bgr_img
=
cv2
.
cvtColor
(
image
,
cv2
.
COLOR_RGB2BGR
)
cv2
.
imshow
(
'image'
,
cv_bgr_img
)
cv2
.
waitKey
(
0
)
# 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 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
)
cv2
.
destroyAllWindows
()
\ No newline at end of file
cv2
.
destroyAllWindows
()
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