Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bob.paper.ijcb2021_synthetic_dataset
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Show more breadcrumbs
bob
bob.paper.ijcb2021_synthetic_dataset
Commits
b5790612
Commit
b5790612
authored
3 years ago
by
Laurent COLBOIS
Browse files
Options
Downloads
Patches
Plain Diff
Add function to download TF1 inception resnet models
parent
4771ff69
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/paper/ijcb2021_synthetic_dataset/utils/download.py
+83
-0
83 additions, 0 deletions
bob/paper/ijcb2021_synthetic_dataset/utils/download.py
with
83 additions
and
0 deletions
bob/paper/ijcb2021_synthetic_dataset/utils/download.py
+
83
−
0
View file @
b5790612
import
os
import
os
import
urllib.request
import
urllib.request
import
bz2
import
bz2
import
bob.extension
import
bob.extension.download
import
bob.io.base
import
bob.extension.rc_config
from
bob.extension
import
rc
from
bob.extension
import
rc
DLIB_LMD_PATH
=
rc
[
'
sg2_morph.dlib_lmd_path
'
]
DLIB_LMD_PATH
=
rc
[
'
sg2_morph.dlib_lmd_path
'
]
SG2_PATH
=
rc
[
'
sg2_morph.sg2_path
'
]
SG2_PATH
=
rc
[
'
sg2_morph.sg2_path
'
]
VGG16_PATH
=
rc
[
'
sg2_morph.vgg16_path
'
]
VGG16_PATH
=
rc
[
'
sg2_morph.vgg16_path
'
]
FR_MODELS_PATH
=
rc
[
'
bob.bio.face_ongoing.models_path
'
]
def
makedirs
(
path
):
def
makedirs
(
path
):
folder
=
os
.
path
.
dirname
(
path
)
folder
=
os
.
path
.
dirname
(
path
)
...
@@ -47,10 +52,88 @@ def download_vgg16():
...
@@ -47,10 +52,88 @@ def download_vgg16():
else
:
else
:
print
(
"
VGG16 model already downloaded in {}
"
.
format
(
VGG16_PATH
))
print
(
"
VGG16 model already downloaded in {}
"
.
format
(
VGG16_PATH
))
def
get_fr_models
():
"""
Define the models to be downloaded
"""
class
Model
(
object
):
def
__init__
(
self
,
group
,
model_name
,
url
,
inside_file_structure
):
module
=
"
bob.bio.face_ongoing.
"
self
.
group
=
group
self
.
model_name
=
model_name
self
.
url
=
url
self
.
config_name
=
module
+
group
+
"
-
"
+
model_name
self
.
inside_file_structure
=
inside_file_structure
# MAKE AS PARAMETERS
branch
=
"
master
"
base_url
=
"
https://www.idiap.ch/software/bob/data/bob/bob.bio.face_ongoing/
"
extension
=
"
.tar.gz
"
models
=
[]
groups
=
[
"
msceleb
"
]
# Defining the models to be downloaded
for
g
in
groups
:
model_name
=
"
inception-v2_batchnorm_rgb
"
url
=
os
.
path
.
join
(
base_url
,
branch
,
g
,
model_name
+
extension
)
inside_file_structure
=
os
.
path
.
join
(
"
inception-v2_batchnorm_rgb
"
)
models
.
append
(
Model
(
g
,
model_name
,
url
,
inside_file_structure
))
return
models
def
download_fr_models
(
destination_path
=
FR_MODELS_PATH
,
**
kwargs
):
"""
Download pretrained CNN Tensorflow 1 models that are used in the package.
The models are the following:
Trained with MS-Celeb:
- inception-v2-rgb: https://gitlab.idiap.ch/bob/bob.learn.tensorflow/blob/39471f5bb2ae42cf6ef7fcc69e305d76a8b44ff9/bob/learn/tensorflow/network/InceptionResnetV2.py
"""
models
=
get_fr_models
()
# Downloading
extension
=
"
.tar.gz
"
rc
=
bob
.
extension
.
rc_config
.
_loadrc
()
for
m
in
models
:
output_path
=
os
.
path
.
join
(
destination_path
,
m
.
group
,
m
.
model_name
+
extension
)
# Downloading
model_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
output_path
),
m
.
inside_file_structure
)
if
os
.
path
.
exists
(
model_path
):
print
(
"
Model {0} already exists in {1}
"
.
format
(
m
.
model_name
,
output_path
))
else
:
print
(
3
,
"
Downloading {0} in {1}
"
.
format
(
m
.
model_name
,
output_path
))
bob
.
io
.
base
.
create_directories_safe
(
model_path
)
bob
.
extension
.
download
.
download_and_unzip
([
m
.
url
],
output_path
)
# Setting the path
rc
[
m
.
config_name
]
=
model_path
bob
.
extension
.
rc_config
.
_saverc
(
rc
)
pass
def
download_models
():
def
download_models
():
download_dlib_lmd
()
download_dlib_lmd
()
download_stylegan2
()
download_stylegan2
()
download_vgg16
()
download_vgg16
()
download_fr_models
()
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
download_models
()
download_models
()
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