From e16cb9ec330352e0aa83197d0adf731f7f10b7d5 Mon Sep 17 00:00:00 2001 From: Amir MOHAMMADI <amir.mohammadi@idiap.ch> Date: Tue, 26 Apr 2022 15:52:52 +0200 Subject: [PATCH] fix bob.io.base and bob.io.image deprecations --- bob/bio/vein/database/utfvp.py | 4 ++-- bob/bio/vein/database/verafinger_contactless.py | 4 ++-- bob/bio/vein/extractor/RepeatedLineTracking.py | 1 - bob/bio/vein/preprocessor/preprocessor.py | 4 ++-- bob/bio/vein/script/compare_rois.py | 4 ++-- bob/bio/vein/script/view_sample.py | 4 ++-- bob/bio/vein/tests/test_tools.py | 7 ++++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bob/bio/vein/database/utfvp.py b/bob/bio/vein/database/utfvp.py index 2fbcaad..203a7a1 100644 --- a/bob/bio/vein/database/utfvp.py +++ b/bob/bio/vein/database/utfvp.py @@ -10,7 +10,7 @@ from bob.bio.base.database import CSVDataset from bob.bio.base.database import CSVToSampleLoaderBiometrics from bob.extension import rc from bob.extension.download import get_file -import bob.io.image +import bob.io.base from sklearn.pipeline import make_pipeline from bob.bio.vein.database.roi_annotation import ROIAnnotation @@ -169,7 +169,7 @@ class UtfvpDatabase(CSVDataset): protocol=protocol, csv_to_sample_loader=make_pipeline( CSVToSampleLoaderBiometrics( - data_loader=bob.io.image.load, + data_loader=bob.io.base.load, dataset_original_directory=rc.get( "bob.bio.vein.utfvp.directory", "" ), diff --git a/bob/bio/vein/database/verafinger_contactless.py b/bob/bio/vein/database/verafinger_contactless.py index e2095bd..35bd8d1 100644 --- a/bob/bio/vein/database/verafinger_contactless.py +++ b/bob/bio/vein/database/verafinger_contactless.py @@ -10,7 +10,7 @@ from bob.bio.base.database import CSVDataset from bob.bio.base.database import CSVToSampleLoaderBiometrics from bob.extension import rc from bob.extension.download import get_file -import bob.io.image +import bob.io.base class VerafingerContactless(CSVDataset): @@ -64,7 +64,7 @@ class VerafingerContactless(CSVDataset): dataset_protocol_path=filename, protocol=protocol, csv_to_sample_loader=CSVToSampleLoaderBiometrics( - data_loader=bob.io.image.load, + data_loader=bob.io.base.load, dataset_original_directory=rc.get( "bob.bio.vein.verafinger_contactless.directory", "" ), diff --git a/bob/bio/vein/extractor/RepeatedLineTracking.py b/bob/bio/vein/extractor/RepeatedLineTracking.py index 89a0792..01613fb 100644 --- a/bob/bio/vein/extractor/RepeatedLineTracking.py +++ b/bob/bio/vein/extractor/RepeatedLineTracking.py @@ -7,7 +7,6 @@ import scipy.ndimage import bob.core import bob.io.base -import bob.ip.base from bob.bio.base.extractor import Extractor diff --git a/bob/bio/vein/preprocessor/preprocessor.py b/bob/bio/vein/preprocessor/preprocessor.py index be5463e..d93c401 100644 --- a/bob/bio/vein/preprocessor/preprocessor.py +++ b/bob/bio/vein/preprocessor/preprocessor.py @@ -84,7 +84,7 @@ class Preprocessor (BasePreprocessor): def write_data(self, data, filename): '''Overrides the default method implementation to handle our tuple''' - f = bob.io.base.HDF5File(filename, 'w') + f = h5py.File(filename, 'w') f.set('image', data[0]) f.set('mask', data[1]) @@ -92,5 +92,5 @@ class Preprocessor (BasePreprocessor): def read_data(self, filename): '''Overrides the default method implementation to handle our tuple''' - f = bob.io.base.HDF5File(filename, 'r') + f = h5py.File(filename, 'r') return f.read('image'), f.read('mask') diff --git a/bob/bio/vein/script/compare_rois.py b/bob/bio/vein/script/compare_rois.py index 126fa3f..d84619b 100644 --- a/bob/bio/vein/script/compare_rois.py +++ b/bob/bio/vein/script/compare_rois.py @@ -173,8 +173,8 @@ def main(user_input=None): for k in gt: gt_file = os.path.join(args['<ground-truth>'], k) db_file = os.path.join(args['<database>'], k) - gt_roi = bob.io.base.HDF5File(gt_file).read('mask') - db_roi = bob.io.base.HDF5File(db_file).read('mask') + gt_roi = h5py.File(gt_file).read('mask') + db_roi = h5py.File(db_file).read('mask') metrics.append(( k, utils.jaccard_index(gt_roi, db_roi), diff --git a/bob/bio/vein/script/view_sample.py b/bob/bio/vein/script/view_sample.py index 9216b0e..fd5a014 100644 --- a/bob/bio/vein/script/view_sample.py +++ b/bob/bio/vein/script/view_sample.py @@ -58,7 +58,7 @@ import matplotlib.pyplot as mpl from ..preprocessor import utils import bob.io.base -import bob.io.image +import bob.io.base def save_figures(title, image, mask, image_pp, binary): @@ -237,7 +237,7 @@ def main(user_input=None): image = f.load(db.original_directory, db.original_extension) pp_name = f.make_path(os.path.join(args['<processed>'], 'preprocessed'), extension='.hdf5') - pp = bob.io.base.HDF5File(pp_name) + pp = h5py.File(pp_name) mask = pp.read('mask') image_pp = pp.read('image') try: diff --git a/bob/bio/vein/tests/test_tools.py b/bob/bio/vein/tests/test_tools.py index 80b39bb..2933f81 100644 --- a/bob/bio/vein/tests/test_tools.py +++ b/bob/bio/vein/tests/test_tools.py @@ -19,7 +19,7 @@ import nose.tools import pkg_resources import bob.io.base -import bob.io.image +import bob.io.base from ..preprocessor import utils as preprocessor_utils @@ -136,8 +136,9 @@ def test_preprocessor(): #preprocessor_utils.show_mask_over_image(preproc, mask) mask_ref = bob.io.base.load(output_fvr_filename).astype('bool') - preproc_ref = bob.core.convert(bob.io.base.load(output_img_filename), - numpy.uint8, (0,255), (0.0,1.0)) + preproc_ref = bob.io.base.load(output_img_filename) + # convert range 0,255 and dtype to uint8 + preproc_ref = numpy.round(preproc_ref * 255).astype('uint8') assert numpy.mean(numpy.abs(mask ^ mask_ref)) < 1e-2 -- GitLab