Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.base
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Show more breadcrumbs
bob
bob.bio.base
Commits
fe38ce3f
Commit
fe38ce3f
authored
4 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Created a wrapper that wraps vanilla biometrics pipelines to checkpointin.
parent
da5069ed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!192
Redoing baselines
,
!180
[dask] Preparing bob.bio.base for dask pipelines
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/bio/base/pipelines/vanilla_biometrics/wrappers.py
+21
-3
21 additions, 3 deletions
bob/bio/base/pipelines/vanilla_biometrics/wrappers.py
with
21 additions
and
3 deletions
bob/bio/base/pipelines/vanilla_biometrics/wrappers.py
+
21
−
3
View file @
fe38ce3f
...
...
@@ -11,7 +11,8 @@ import h5py
import
cloudpickle
from
.zt_norm
import
ZTNormPipeline
,
ZTNormDaskWrapper
from
.legacy
import
BioAlgorithmLegacy
from
bob.bio.base.transformers
import
PreprocessorTransformer
,
ExtractorTransformer
,
AlgorithmTransformer
from
bob.pipelines.wrappers
import
SampleWrapper
class
BioAlgorithmCheckpointWrapper
(
BioAlgorithm
):
"""
Wrapper used to checkpoint enrolled and Scoring samples.
...
...
@@ -278,13 +279,30 @@ def checkpoint_vanilla_biometrics(pipeline, base_dir):
sk_pipeline
=
pipeline
.
transformer
for
i
,
name
,
estimator
in
sk_pipeline
.
_iter
():
# If they are legacy objects, we need to hook their load/save functions
save_func
=
None
load_func
=
None
if
not
isinstance
(
estimator
,
SampleWrapper
):
raise
ValueError
(
f
"
{
estimator
}
needs to be the type `SampleWrapper` to be checkpointed
"
)
if
isinstance
(
estimator
.
estimator
,
PreprocessorTransformer
):
save_func
=
estimator
.
estimator
.
instance
.
write_data
load_func
=
estimator
.
estimator
.
instance
.
read_data
elif
any
([
isinstance
(
estimator
.
estimator
,
ExtractorTransformer
),
isinstance
(
estimator
.
estimator
,
AlgorithmTransformer
)]):
save_func
=
estimator
.
estimator
.
instance
.
write_feature
load_func
=
estimator
.
estimator
.
instance
.
read_feature
wraped_estimator
=
bob
.
pipelines
.
wrap
(
[
"
checkpoint
"
],
estimator
,
features_dir
=
os
.
path
.
join
(
base_dir
,
name
)
[
"
checkpoint
"
],
estimator
,
features_dir
=
os
.
path
.
join
(
base_dir
,
name
),
load_func
=
load_func
,
save_func
=
save_func
)
sk_pipeline
.
steps
[
i
]
=
(
name
,
wraped_estimator
)
if
isinstance
(
pipeline
.
biometric_algorithm
,
BioAlgorithmLegacy
):
if
isinstance
(
pipeline
.
biometric_algorithm
,
BioAlgorithmLegacy
):
pipeline
.
biometric_algorithm
.
base_dir
=
base_dir
else
:
pipeline
.
biometric_algorithm
=
BioAlgorithmCheckpointWrapper
(
...
...
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