Skip to content
Snippets Groups Projects
Commit 79e11f30 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Fixing the temp directory path for legacy algorithms IF checkpointing is off

parent 1d4aca34
No related branches found
No related tags found
1 merge request!94Fixing the temp directory path for legacy algorithms IF checkpointing is off
Pipeline #46794 passed
......@@ -70,16 +70,9 @@ def get_pipeline(face_cropper, transform_extra_arguments):
)
# Set default temporary directory
default_temp = (
os.path.join("/idiap", "temp", os.environ["USER"])
if "USER" in os.environ
else "~/temp"
tempdir = bob.bio.base.pipelines.vanilla_biometrics.legacy.get_temp_directory(
"gabor_graph"
)
if os.path.exists(default_temp):
tempdir = os.path.join(default_temp, "bob_bio_base_tmp")
else:
# if /idiap/temp/<USER> does not exist, use /tmp/tmpxxxxxxxx
tempdir = tempfile.TemporaryDirectory().name
algorithm = BioAlgorithmLegacy(gabor_jet, base_dir=tempdir)
return VanillaBiometricsPipeline(transformer, algorithm)
......
......@@ -38,18 +38,10 @@ def load(annotation_type, fixed_positions=None):
face_cropper=face_cropper, dtype=np.float64
)
#### FEATURE EXTRACTOR ######
# Set default temporary directory
user_env_var = os.getenv("USER", None)
if user_env_var:
default_temp = os.path.join("/idiap","temp",user_env_var)
if user_env_var and os.path.exists(default_temp):
tempdir = os.path.join(default_temp, "bob_bio_base_tmp", "lda")
else:
# if /idiap/temp/<USER> does not exist, use /tmp/tmpxxxxxxxx
tempdir = tempfile.TemporaryDirectory().name
tempdir = bob.bio.base.pipelines.vanilla_biometrics.legacy.get_temp_directory("lda")
lda = bob.bio.base.algorithm.LDA(use_pinv=True, pca_subspace_dimension=0.90)
......@@ -57,26 +49,25 @@ def load(annotation_type, fixed_positions=None):
lda, projector_file=os.path.join(tempdir, "Projector.hdf5")
)
transformer = make_pipeline(
wrap(
["sample"], preprocessor, transform_extra_arguments=transform_extra_arguments,
["sample"],
preprocessor,
transform_extra_arguments=transform_extra_arguments,
),
SampleLinearize(),
wrap(["sample"], lda_transformer),
)
### BIOMETRIC ALGORITHM
algorithm = BioAlgorithmLegacy(
lda,
base_dir=tempdir,
projector_file=os.path.join(tempdir, "Projector.hdf5"),
lda, base_dir=tempdir, projector_file=os.path.join(tempdir, "Projector.hdf5"),
)
return VanillaBiometricsPipeline(transformer, algorithm)
pipeline = load(annotation_type, fixed_positions)
transformer = pipeline.transformer
......@@ -9,7 +9,6 @@ import numpy as np
import bob.bio.face
from sklearn.pipeline import make_pipeline
from bob.pipelines import wrap
import tempfile
import bob.math
......@@ -21,6 +20,7 @@ else:
annotation_type = None
fixed_positions = None
def get_cropper(annotation_type, fixed_positions=None):
# Cropping
face_cropper, transform_extra_arguments = crop_80x64(
......@@ -28,6 +28,7 @@ def get_cropper(annotation_type, fixed_positions=None):
)
return face_cropper, transform_extra_arguments
def get_pipeline(face_cropper, transform_extra_arguments):
preprocessor = bob.bio.face.preprocessor.TanTriggs(
face_cropper=face_cropper, dtype=np.float64
......@@ -37,40 +38,44 @@ def get_pipeline(face_cropper, transform_extra_arguments):
lgbphs = bob.bio.face.extractor.LGBPHS(
# block setup
block_size = 8,
block_overlap = 0,
block_size=8,
block_overlap=0,
# Gabor parameters
gabor_sigma = math.sqrt(2.) * math.pi,
gabor_sigma=math.sqrt(2.0) * math.pi,
# LBP setup (we use the defaults)
# histogram setup
sparse_histogram = True
sparse_histogram=True,
)
transformer = make_pipeline(
wrap(
["sample"], preprocessor, transform_extra_arguments=transform_extra_arguments,
["sample"],
preprocessor,
transform_extra_arguments=transform_extra_arguments,
),
wrap(["sample"], lgbphs),
)
### BIOMETRIC ALGORITHM
histogram = bob.bio.face.algorithm.Histogram(
distance_function = bob.math.histogram_intersection,
is_distance_function = False
distance_function=bob.math.histogram_intersection, is_distance_function=False
)
tempdir = tempfile.TemporaryDirectory()
algorithm = BioAlgorithmLegacy(histogram, base_dir=tempdir.name)
tempdir = bob.bio.base.pipelines.vanilla_biometrics.legacy.get_temp_directory(
"LGBPHS"
)
algorithm = BioAlgorithmLegacy(histogram, base_dir=tempdir)
return VanillaBiometricsPipeline(transformer, algorithm)
def load(annotation_type, fixed_positions=None):
####### SOLVING THE FACE CROPPER TO BE USED ##########
face_cropper, transform_extra_arguments = get_cropper(annotation_type, fixed_positions)
face_cropper, transform_extra_arguments = get_cropper(
annotation_type, fixed_positions
)
return get_pipeline(face_cropper, transform_extra_arguments)
pipeline = load(annotation_type, fixed_positions)
transformer = pipeline.transformer
\ No newline at end of file
transformer = pipeline.transformer
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment