Skip to content

Commit

Permalink
Allowing feature extraction and projection to fail, when --allow-miss…
Browse files Browse the repository at this point in the history
…ing-files is enabled
  • Loading branch information
siebenkopf committed May 11, 2016
1 parent f71b04c commit d320fbc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
27 changes: 27 additions & 0 deletions bob/bio/base/tools/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ def project(algorithm, extractor, groups = None, indices = None, allow_missing_f
feature = extractor.read_feature(feature_file)
# project feature
projected = algorithm.project(feature)

if projected is None:
if allow_missing_files:
logger.debug("... Projection for extracted file %s failed; skipping", feature_file)
continue
else:
logger.error("Projection of file '%s' was not successful", feature_file)
continue

# write it
algorithm.write_feature(projected, projected_file)

Expand Down Expand Up @@ -265,6 +274,15 @@ def enroll(algorithm, extractor, compute_zt_norm, indices = None, groups = ['dev
enroll_features = [reader.read_feature(enroll_file) for enroll_file in enroll_files]

model = algorithm.enroll(enroll_features)

if model is None:
if allow_missing_files:
logger.debug("... Enrollment for model %s failed; skipping", model_id)
continue
else:
logger.error("Enrollemnt of model '%s' was not successful", model_id)
continue

# save the model
algorithm.write_model(model, model_file)

Expand Down Expand Up @@ -303,6 +321,15 @@ def enroll(algorithm, extractor, compute_zt_norm, indices = None, groups = ['dev
t_enroll_features = [reader.read_feature(t_enroll_file) for t_enroll_file in t_enroll_files]

t_model = algorithm.enroll(t_enroll_features)

if t_model is None:
if allow_missing_files:
logger.debug("... Enrollment for T-model %s failed; skipping", t_model_id)
continue
else:
logger.error("Enrollemnt of T-model '%s' was not successful", t_model_id)
continue

# save model
algorithm.write_model(t_model, t_model_file)
else:
Expand Down
9 changes: 9 additions & 0 deletions bob/bio/base/tools/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ def extract(extractor, preprocessor, groups=None, indices = None, allow_missing_
data = preprocessor.read_data(data_file)
# extract feature
feature = extractor(data)

if feature is None:
if allow_missing_files:
logger.debug("... Feature extraction for data file %s failed; skipping", data_file)
continue
else:
logger.error("Feature extraction of file '%s' was not successful", data_file)
continue

# write feature
extractor.write_feature(feature, feature_file)
else:
Expand Down

0 comments on commit d320fbc

Please sign in to comment.