added estimator preprocessor and removed adapter and adapter patch
This commit is contained in:
parent
981d7816a0
commit
d97b477208
@ -1,10 +0,0 @@
|
||||
import abc
|
||||
|
||||
|
||||
class EstimatorAdapter(abc.ABC):
|
||||
def __init__(self, estimator):
|
||||
self.estimator = estimator
|
||||
|
||||
@abc.abstractmethod
|
||||
def predict(self, batch):
|
||||
pass
|
||||
@ -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
|
||||
9
image_prediction/estimator/preprocessor/preprocessor.py
Normal file
9
image_prediction/estimator/preprocessor/preprocessor.py
Normal 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)
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user