applied black
This commit is contained in:
parent
b818ee4724
commit
e818b05472
@ -14,6 +14,7 @@ class ImageClassifier:
|
||||
"""Combines a classifier with a preprocessing pipeline: Receives images, chunks into batches, converts to tensors,
|
||||
applies transformations and finally sends to internal classifier.
|
||||
"""
|
||||
|
||||
def __init__(self, classifier: Classifier, preprocessor: Preprocessor = None):
|
||||
self.estimator = classifier
|
||||
self.preprocessor = preprocessor if preprocessor else BasicPreprocessor()
|
||||
|
||||
@ -9,6 +9,7 @@ from image_prediction.utils import chunk_iterable
|
||||
class ExtractorClassifier:
|
||||
"""Extracts images from an object and classifies them. When called, returns an iterable of dictionaries, where
|
||||
each dictionary has a filed 'label' for the classification and possibly additional fields for metadata."""
|
||||
|
||||
def __init__(self, image_extractor: ImageExtractor, image_classifier: ImageClassifier):
|
||||
self.classifier = image_classifier
|
||||
self.extractor = image_extractor
|
||||
|
||||
@ -6,7 +6,6 @@ ImageMetadataPair = namedtuple("ImageMetadataPair", ["image", "metadata"])
|
||||
|
||||
|
||||
class ImageExtractor(abc.ABC):
|
||||
|
||||
@abc.abstractmethod
|
||||
def extract(self, obj) -> Iterable[ImageMetadataPair]:
|
||||
"""Extracts images from an object"""
|
||||
|
||||
@ -2,7 +2,6 @@ from image_prediction.image_extractor.extractor import ImageExtractor, ImageMeta
|
||||
|
||||
|
||||
class ImageExtractorMock(ImageExtractor):
|
||||
|
||||
def extract(self, image_container):
|
||||
for i, image in enumerate(image_container):
|
||||
yield ImageMetadataPair(image, {"image_id": i})
|
||||
|
||||
@ -29,7 +29,7 @@ class ParsablePDFImageExtractor(ImageExtractor):
|
||||
"x1": x1,
|
||||
"x2": x2,
|
||||
"y1": y1,
|
||||
"y2": y2
|
||||
"y2": y2,
|
||||
}
|
||||
|
||||
rounder = rcompose(round, int)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user