Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.ip.dlib
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
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.ip.dlib
Commits
b8ce46cf
There was a problem fetching the pipeline summary.
Commit
b8ce46cf
authored
7 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Used the download function from bob.extension
parent
bef98d41
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!11
Fixing download
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/ip/dlib/DlibLandmarkExtraction.py
+4
-56
4 additions, 56 deletions
bob/ip/dlib/DlibLandmarkExtraction.py
bob/ip/dlib/test/test.py
+2
-2
2 additions, 2 deletions
bob/ip/dlib/test/test.py
with
6 additions
and
58 deletions
bob/ip/dlib/DlibLandmarkExtraction.py
+
4
−
56
View file @
b8ce46cf
...
...
@@ -11,39 +11,10 @@ logger = bob.core.log.setup("bob.ip.dlib")
bob
.
core
.
log
.
set_verbosity_level
(
logger
,
3
)
import
dlib
from
.utils
import
bounding_box_2_rectangle
import
bob.extension.download
from
.FaceDetector
import
FaceDetector
def
download_file
(
url
,
out_file
):
"""
Downloads a file from a given url
Parameters
----------
url : str
The url to download form.
out_file : str
Where to save the file.
"""
from
bob.io.base
import
create_directories_safe
import
os
create_directories_safe
(
os
.
path
.
dirname
(
out_file
))
import
sys
if
sys
.
version_info
[
0
]
<
3
:
# python2 technique for downloading a file
from
urllib2
import
urlopen
with
open
(
out_file
,
'
wb
'
)
as
f
:
response
=
urlopen
(
url
)
f
.
write
(
response
.
read
())
else
:
# python3 technique for downloading a file
from
urllib.request
import
urlopen
from
shutil
import
copyfileobj
with
urlopen
(
url
)
as
response
:
with
open
(
out_file
,
'
wb
'
)
as
f
:
copyfileobj
(
response
,
f
)
class
DlibLandmarkExtraction
(
object
):
"""
Binds to the DLib landmark detection using the shape_predictor_68_face_landmarks,
...
...
@@ -139,34 +110,11 @@ class DlibLandmarkExtraction(object):
"
shape_predictor_68_face_landmarks.dat.bz2
"
)
urls
=
[
# This is a private link at Idiap to save bandwidth.
"
http://
beatubulatest.lab
.idiap.ch/private/wheels/gitlab/
"
"
http://
www
.idiap.ch/private/wheels/gitlab/
"
"
shape_predictor_68_face_landmarks.dat.bz2
"
,
# this works for everybody
"
http://dlib.net/files/
"
"
shape_predictor_68_face_landmarks.dat.bz2
"
,
]
for
url
in
urls
:
try
:
logger
.
info
(
"
Downloading DLIB model from
"
"
{} ...
"
.
format
(
url
))
download_file
(
url
,
zip_file
)
break
except
Exception
:
logger
.
warning
(
"
Could not download from the %s url
"
,
url
,
exc_info
=
True
)
else
:
# else is for the for loop
if
not
os
.
path
.
isfile
(
zip_file
):
raise
RuntimeError
(
"
Could not download the zip file.
"
)
# Unzip
logger
.
info
(
"
Unziping in {0}
"
.
format
(
DlibLandmarkExtraction
.
get_modelpath
()))
t
=
bz2
.
BZ2File
(
zip_file
)
open
(
os
.
path
.
join
(
DlibLandmarkExtraction
.
get_modelpath
(),
'
shape_predictor_68_face_landmarks.dat
'
),
'
wb
'
).
write
(
t
.
read
())
t
.
close
()
os
.
unlink
(
zip_file
)
bob
.
extension
.
download
.
download_and_unzip
(
urls
,
zip_file
)
This diff is collapsed.
Click to expand it.
bob/ip/dlib/test/test.py
+
2
−
2
View file @
b8ce46cf
...
...
@@ -29,8 +29,8 @@ def test_face_detector():
del
f
result
=
FaceDetector
().
detect_single_face
(
image
)
assert
result
[
0
].
topleft
==
(
0
,
23
6
)
assert
result
[
0
].
bottomright
==
(
84
,
31
2
)
assert
result
[
0
].
topleft
==
(
0
,
23
7
)
assert
result
[
0
].
bottomright
==
(
84
,
31
3
)
def
test_landmark
():
...
...
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