added estimator preprocessor and removed adapter and adapter patch

This commit is contained in:
Matthias Bisping 2022-03-25 18:08:54 +01:00
parent 981d7816a0
commit d97b477208
5 changed files with 10 additions and 34 deletions

View File

@ -1,10 +0,0 @@
import abc
class EstimatorAdapter(abc.ABC):
def __init__(self, estimator):
self.estimator = estimator
@abc.abstractmethod
def predict(self, batch):
pass

View File

@ -1,22 +0,0 @@
from image_prediction.estimator.adapter.adapter import EstimatorAdapter
from image_prediction.estimator.estimator import Estimator
class EstimatorAdapterPatch(EstimatorAdapter):
def __init__(self, estimator: Estimator):
super().__init__(estimator=estimator)
self.__output_batch = None
@property
def output_batch(self):
return self.__output_batch
@output_batch.setter
def output_batch(self, output_batch):
self.__output_batch = output_batch
def predict(self, batch):
# Call the internal estimator, so mechanical issues would surface
self.estimator.predict(batch)
# but discard the returned values for the purposes of testing the interface that calls the adapter
return self.__output_batch

View File

@ -0,0 +1,9 @@
from image_prediction.estimator.estimator import Estimator
class EstimatorPreprocessor:
def __init__(self, estimator: Estimator):
self.estimator = estimator
def predict(self, batch):
return self.estimator.predict(batch)

View File

@ -2,14 +2,13 @@ from typing import Mapping, List
import numpy as np
from image_prediction.estimator.adapter.adapter import EstimatorAdapter
from image_prediction.utils import get_logger
logger = get_logger()
class ServiceEstimator:
def __init__(self, estimator_adapter: EstimatorAdapter, classes: Mapping[int, str]):
def __init__(self, estimator_adapter, classes: Mapping[int, str]):
self.__estimator_adapter = estimator_adapter
self.__classes = classes