diff --git a/bob/bio/vein/algorithm/MiuraMatch.py b/bob/bio/vein/algorithm/MiuraMatch.py index 463342593629d3b112333cc31e8ce9d6d819beef..774c8f239127af0286e26e803b5ff5cc388f4482 100644 --- a/bob/bio/vein/algorithm/MiuraMatch.py +++ b/bob/bio/vein/algorithm/MiuraMatch.py @@ -103,7 +103,9 @@ class MiuraMatch(BioAlgorithm): # yields best results. Otherwise, you may try the other options bellow # -> check our test_correlation() method on the test units for more # details and benchmarks. - Nm = scipy.signal.fftconvolve(image_, numpy.rot90(crop_R, k=2), "valid") + Nm = scipy.signal.fftconvolve( + image_, numpy.rot90(crop_R, k=2), "valid" + ) # 2nd best: use convolve2d or correlate2d directly; # Nm = scipy.signal.convolve2d(I, numpy.rot90(crop_R, k=2), 'valid') # 3rd best: use correlate2d diff --git a/bob/bio/vein/config/maximum_curvature.py b/bob/bio/vein/config/maximum_curvature.py index 32f816dfacc40969ed59a83c0ec29931c5c9a50b..3935beccab847f5abdfa943ec45aa5e71f1ed881 100644 --- a/bob/bio/vein/config/maximum_curvature.py +++ b/bob/bio/vein/config/maximum_curvature.py @@ -17,7 +17,7 @@ import tempfile from sklearn.pipeline import make_pipeline -from bob.bio.base.pipelines import BioAlgorithmLegacy, PipelineSimple +from bob.bio.base.pipelines import PipelineSimple from bob.bio.base.transformers import ( ExtractorTransformer, PreprocessorTransformer, diff --git a/bob/bio/vein/config/principal_curvature.py b/bob/bio/vein/config/principal_curvature.py index 47cbe722d6bbaf0a26b2127e5d296b7084a44661..e761cd6aba8dd847dadd29a26c32f700de918ec6 100644 --- a/bob/bio/vein/config/principal_curvature.py +++ b/bob/bio/vein/config/principal_curvature.py @@ -76,7 +76,7 @@ else: legacy_temp_dir = tempfile.TemporaryDirectory().name -from bob.bio.base.pipelines import BioAlgorithmLegacy, PipelineSimple +from bob.bio.base.pipelines import PipelineSimple biometric_algorithm = MiuraMatch(ch=18, cw=28) diff --git a/bob/bio/vein/config/repeated_line_tracking.py b/bob/bio/vein/config/repeated_line_tracking.py index 7407bd497bf84d8e51f4086fe3f9bc9598a1d1c3..b5853eababfc0ac0a4c0be5ce010e010507a7a85 100644 --- a/bob/bio/vein/config/repeated_line_tracking.py +++ b/bob/bio/vein/config/repeated_line_tracking.py @@ -16,7 +16,7 @@ import tempfile from sklearn.pipeline import make_pipeline -from bob.bio.base.pipelines import BioAlgorithmLegacy, PipelineSimple +from bob.bio.base.pipelines import PipelineSimple from bob.bio.base.transformers import ( ExtractorTransformer, PreprocessorTransformer, diff --git a/bob/bio/vein/config/wide_line_detector.py b/bob/bio/vein/config/wide_line_detector.py index d88d50566e7d5ca5b016dc66c51759966b47564d..5c3be3add46acb72fee103119fe0f7feaab2de32 100644 --- a/bob/bio/vein/config/wide_line_detector.py +++ b/bob/bio/vein/config/wide_line_detector.py @@ -16,7 +16,7 @@ import tempfile from sklearn.pipeline import make_pipeline -from bob.bio.base.pipelines import BioAlgorithmLegacy, PipelineSimple +from bob.bio.base.pipelines import PipelineSimple from bob.bio.base.transformers import ( ExtractorTransformer, PreprocessorTransformer, diff --git a/bob/bio/vein/database/fv3d.py b/bob/bio/vein/database/fv3d.py index b51d4772c5b3b4014f4cef85c5a97d213cd341f3..7c60331ccd24934a220907f3fcc8be61029f6a63 100644 --- a/bob/bio/vein/database/fv3d.py +++ b/bob/bio/vein/database/fv3d.py @@ -7,7 +7,6 @@ import numpy from bob.bio.base.database import BioDatabase, BioFile -from ..preprocessor.utils import poly_to_mask from . import AnnotatedArray diff --git a/bob/bio/vein/database/verafinger.py b/bob/bio/vein/database/verafinger.py index ea3db172d6acbfa2037565d722cb7764b88759ef..397bb4a147e96f0d1651e23d407310a9b32ac15f 100644 --- a/bob/bio/vein/database/verafinger.py +++ b/bob/bio/vein/database/verafinger.py @@ -6,7 +6,6 @@ import os from bob.bio.base.database import BioDatabase, BioFile -from ..preprocessor.utils import poly_to_mask from . import AnnotatedArray diff --git a/bob/bio/vein/extractor/MaximumCurvature.py b/bob/bio/vein/extractor/MaximumCurvature.py index 5248d972cfd18730ec85c41a838de2cf7089459c..518d5620f6102fc2bea09b79e528d56c72a30b0d 100644 --- a/bob/bio/vein/extractor/MaximumCurvature.py +++ b/bob/bio/vein/extractor/MaximumCurvature.py @@ -6,8 +6,6 @@ import math import numpy import scipy.ndimage -import bob.io.base - from bob.bio.base.extractor import Extractor diff --git a/bob/bio/vein/extractor/NormalisedCrossCorrelation.py b/bob/bio/vein/extractor/NormalisedCrossCorrelation.py index df445606b02a9ef7beafa0e5fc481aca65833b68..b1a73e4091b04bc76947e97f1b5f31461d123efd 100644 --- a/bob/bio/vein/extractor/NormalisedCrossCorrelation.py +++ b/bob/bio/vein/extractor/NormalisedCrossCorrelation.py @@ -3,8 +3,6 @@ import numpy -import bob.io.base - from bob.bio.base.extractor import Extractor diff --git a/bob/bio/vein/extractor/PrincipalCurvature.py b/bob/bio/vein/extractor/PrincipalCurvature.py index 84c1bbea95819d6b1baa22a2c469084c8b69d912..45297ecea0d4842ab85d802fec9cb92955246032 100644 --- a/bob/bio/vein/extractor/PrincipalCurvature.py +++ b/bob/bio/vein/extractor/PrincipalCurvature.py @@ -5,8 +5,6 @@ import numpy from scipy.ndimage import gaussian_filter -import bob.io.base - from bob.bio.base.extractor import Extractor diff --git a/bob/bio/vein/extractor/__init__.py b/bob/bio/vein/extractor/__init__.py index 4f5cbfb48b9d6ec39ae4129d498b25943579cd7a..e50ec98d3b7ee4213fed23e51c701b5363b781ac 100644 --- a/bob/bio/vein/extractor/__init__.py +++ b/bob/bio/vein/extractor/__init__.py @@ -1,9 +1,9 @@ # isort: skip_file -from .NormalisedCrossCorrelation import NormalisedCrossCorrelation -from .PrincipalCurvature import PrincipalCurvature -from .RepeatedLineTracking import RepeatedLineTracking -from .WideLineDetector import WideLineDetector -from .MaximumCurvature import MaximumCurvature +from .NormalisedCrossCorrelation import NormalisedCrossCorrelation # noqa: F401 +from .PrincipalCurvature import PrincipalCurvature # noqa: F401 +from .RepeatedLineTracking import RepeatedLineTracking # noqa: F401 +from .WideLineDetector import WideLineDetector # noqa: F401 +from .MaximumCurvature import MaximumCurvature # noqa: F401 # gets sphinx autodoc done right - don't remove it __all__ = [_ for _ in dir() if not _.startswith("_")] diff --git a/bob/bio/vein/preprocessor/crop.py b/bob/bio/vein/preprocessor/crop.py index 4ca5b2d56d80d090d79f5d81f9f45e123f1225d8..d8bffde80ae66b813040102d8d23286790addf1b 100644 --- a/bob/bio/vein/preprocessor/crop.py +++ b/bob/bio/vein/preprocessor/crop.py @@ -4,8 +4,6 @@ """Base utilities for pre-cropping images""" -import numpy - class Cropper(object): """This is the base class for all croppers diff --git a/bob/bio/vein/preprocessor/filters.py b/bob/bio/vein/preprocessor/filters.py index 9ef0a9c013a117a8fd24972d4e433f02d3dfb13f..6714c4cfad445f100cf1e56e2db3290d07486a0c 100644 --- a/bob/bio/vein/preprocessor/filters.py +++ b/bob/bio/vein/preprocessor/filters.py @@ -3,8 +3,6 @@ """Base utilities for post-filtering vein images""" -import numpy - class Filter(object): """Objects of this class filter the input image""" diff --git a/bob/bio/vein/preprocessor/mask.py b/bob/bio/vein/preprocessor/mask.py index 01dd15d79b28b16cd96a95fe49459a381b478029..3e146fbd7f1487fc138075f337f152bef4b0e6e3 100644 --- a/bob/bio/vein/preprocessor/mask.py +++ b/bob/bio/vein/preprocessor/mask.py @@ -7,8 +7,6 @@ import math import numpy import scipy.ndimage -import skimage.filters -import skimage.morphology from .utils import poly_to_mask diff --git a/bob/bio/vein/preprocessor/preprocessor.py b/bob/bio/vein/preprocessor/preprocessor.py index c172f131ecfaabac1304a9f09c788ef8d3eb38a5..5d7fb5fc4a2ef9ba95f9076b569ec7a91f6a9108 100644 --- a/bob/bio/vein/preprocessor/preprocessor.py +++ b/bob/bio/vein/preprocessor/preprocessor.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # vim: set fileencoding=utf-8 : - -import bob.io.base +import h5py from bob.bio.base.preprocessor import Preprocessor as BasePreprocessor diff --git a/bob/bio/vein/script/blame.py b/bob/bio/vein/script/blame.py index 2423684f23d44fa5e5c447ef385508d3c2f3b296..eb2cfde6dde14843797548538fb5f11e2234ddeb 100644 --- a/bob/bio/vein/script/blame.py +++ b/bob/bio/vein/script/blame.py @@ -73,7 +73,7 @@ def main(user_input=None): cases = int(args["--cases"]) # generates a huge - from bob.bio.base.score.load import get_negatives_positives, load_score + from bob.bio.base.score.load import load_score scores = [] names = {} diff --git a/bob/bio/vein/script/compare_rois.py b/bob/bio/vein/script/compare_rois.py index 9f94384ad9579d38f0db8c16d99b6f28bbe012c8..7eb79816774ba10d9e6774221e5c4f75cb71e4aa 100644 --- a/bob/bio/vein/script/compare_rois.py +++ b/bob/bio/vein/script/compare_rois.py @@ -48,6 +48,7 @@ import operator import os import sys +import h5py import numpy import bob.extension.log diff --git a/bob/bio/vein/script/validate.py b/bob/bio/vein/script/validate.py index aa46ac7c771f73dbe0df3723a20e25bd06808f37..b338959a7cbd3b579eb3ab7fdd7ec2f3205c64af 100644 --- a/bob/bio/vein/script/validate.py +++ b/bob/bio/vein/script/validate.py @@ -172,8 +172,6 @@ def open_multipage_pdf_file(s): schema.SchemaError: if the path exists """ - import matplotlib.pyplot as mpl - from matplotlib.backends.backend_pdf import PdfPages return PdfPages(s) diff --git a/bob/bio/vein/script/view_sample.py b/bob/bio/vein/script/view_sample.py index 4c7dd42a97c2b6ba582b63ce6a5a7adaa92d4e60..16a2dafa95ffe66a70b8b21fab1c6c047c1b90f3 100644 --- a/bob/bio/vein/script/view_sample.py +++ b/bob/bio/vein/script/view_sample.py @@ -47,6 +47,7 @@ import os import sys import docopt +import h5py import numpy import schema @@ -88,8 +89,6 @@ def save_figures(title, image, mask, image_pp, binary): bob.io.base.save(image, os.path.join(title, "original.png")) # add preprocessed image - from ..preprocessor import utils - img = utils.draw_mask_over_image(image_pp, mask) img = numpy.array(img).transpose(2, 0, 1) bob.io.base.save(img[:3], os.path.join(title, "preprocessed.png")) @@ -140,8 +139,6 @@ def proof_figure(title, image, mask, image_pp, binary=None): mpl.imshow(image, cmap="gray") # add preprocessed image - from ..preprocessor import utils - img = utils.draw_mask_over_image(image_pp, mask) mpl.subplot(images, 1, 2) mpl.title("Preprocessed") @@ -223,7 +220,7 @@ def main(user_input=None): try: from .validate import setup_logger - logger = setup_logger("bob.bio.vein", args["--verbose"]) + setup_logger("bob.bio.vein", args["--verbose"]) args = validate(args) except schema.SchemaError as e: sys.exit(e) @@ -258,7 +255,7 @@ def main(user_input=None): binary = numpy.rot90(binary, k=1) except Exception: binary = None - fig = proof_figure(stem, image, mask, image_pp, binary) + proof_figure(stem, image, mask, image_pp, binary) if args["--save"]: save_figures(args["--save"], image, mask, image_pp, binary) else: diff --git a/bob/bio/vein/tests/test_tools.py b/bob/bio/vein/tests/test_tools.py index 01abd105f01fbeb30e085b4add0f3f2f9397833f..0f0570cc2cc3aada6ded9da2ebd911344ff38951 100644 --- a/bob/bio/vein/tests/test_tools.py +++ b/bob/bio/vein/tests/test_tools.py @@ -248,7 +248,7 @@ def test_max_curvature_HE(): from ..extractor.MaximumCurvature import MaximumCurvature MC = MaximumCurvature(sigma=5) - extr_data = MC(preproc_data) + MC(preproc_data) # preprocessor_utils.show_image((255.*extr_data).astype('uint8')) @@ -317,7 +317,7 @@ def test_repeated_line_tracking_HE(): profile_w=PROFILE_WIDTH, seed=0, ) - extr_data = RLT(preproc_data) + RLT(preproc_data) def test_wide_line_detector(): @@ -384,7 +384,7 @@ def test_wide_line_detector_HE(): g=SUM_NEIGHBOURHOOD, rescale=RESCALE, ) - extr_data = WLD(preproc_data) + WLD(preproc_data) def test_miura_match(): @@ -416,16 +416,16 @@ def test_correlate(): template_filename = F(("algorithms", "0001_2_1_120509-135338.mat.hdf5")) probe_gen_filename = F(("algorithms", "0001_2_2_120509-135558.mat.hdf5")) - probe_imp_filename = F(("algorithms", "0003_2_1_120509-141255.mat.hdf5")) + # probe_imp_filename = F(("algorithms", "0003_2_1_120509-141255.mat.hdf5")) template_vein = bob.io.base.load(template_filename) probe_gen_vein = bob.io.base.load(probe_gen_filename) - probe_imp_vein = bob.io.base.load(probe_imp_filename) + # probe_imp_vein = bob.io.base.load(probe_imp_filename) from ..algorithm.Correlate import Correlate C = Correlate() - score_gen = C.score(template_vein, probe_gen_vein) + C.score(template_vein, probe_gen_vein) # we don't check here - no templates @@ -545,14 +545,14 @@ def test_mask_to_image(): def _check_float(n): conv = preprocessor_utils.mask_to_image(sample, "float%d" % n) nose.tools.eq_(conv.dtype, getattr(numpy, "float%d" % n)) - assert numpy.array_equal(conv, [0, 1.0]), "%r != %r" % (conv, target) + assert numpy.array_equal(conv, [0, 1.0]), "%r != %r" % (conv, [0, 1.0]) _check_float(32) _check_float(64) # This should be unsupported try: - conv = preprocessor_utils.mask_to_image(sample, "int16") + preprocessor_utils.mask_to_image(sample, "int16") except TypeError as e: assert "int16" in str(e) else: diff --git a/doc/conf.py b/doc/conf.py index 867321210db7a447c75e6d7fb9f971d14d19a6bd..755aff1c6ef86a0ec4c156634d6014630547b395 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,9 +1,7 @@ #!/usr/bin/env python # vim: set fileencoding=utf-8 : -import glob import os -import sys import pkg_resources diff --git a/matlab/compare.py b/matlab/compare.py index 3abc531ffd4ef3774632a29380e4ba8a716110b4..ee378c93f38d4d70093da77a854d42d742d96c64 100644 --- a/matlab/compare.py +++ b/matlab/compare.py @@ -29,8 +29,6 @@ G_matlab = bob.io.base.load("mc_g_matlab.hdf5") G_matlab = G_matlab.T # Apply Python implementation -from bob.bio.vein.extractor.MaximumCurvature import MaximumCurvature - MC = MaximumCurvature(3) kappa = MC.detect_valleys(image, region) # OK