Module brevettiai.data.image.image_processor
Expand source code
import numpy as np
from pydantic import BaseModel
from abc import ABC, abstractmethod
class ImageProcessor(BaseModel, ABC):
"""
Baseclass for implementing interface for image proccessors
"""
type: str
def output_size(self, input_height, input_width):
"""Calculated output size of output after postprocessing, given input image sizes"""
return input_height, input_width
def output_channels(self, input_channels):
"""Calculated output channel number"""
return input_channels
@abstractmethod
def process(self, image):
"""Process image according to processor"""
raise NotImplementedError("process(image)-> image should be implemented")
# noinspection PyUnreachableCode
return image
@staticmethod
def affine_transform(input_height, input_width):
return np.eye(3)
Classes
class ImageProcessor (**data: Any)-
Baseclass for implementing interface for image proccessors
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Expand source code
class ImageProcessor(BaseModel, ABC): """ Baseclass for implementing interface for image proccessors """ type: str def output_size(self, input_height, input_width): """Calculated output size of output after postprocessing, given input image sizes""" return input_height, input_width def output_channels(self, input_channels): """Calculated output channel number""" return input_channels @abstractmethod def process(self, image): """Process image according to processor""" raise NotImplementedError("process(image)-> image should be implemented") # noinspection PyUnreachableCode return image @staticmethod def affine_transform(input_height, input_width): return np.eye(3)Ancestors
- pydantic.main.BaseModel
- pydantic.utils.Representation
- abc.ABC
Subclasses
Class variables
var type : str
Static methods
def affine_transform(input_height, input_width)-
Expand source code
@staticmethod def affine_transform(input_height, input_width): return np.eye(3)
Methods
def output_channels(self, input_channels)-
Calculated output channel number
Expand source code
def output_channels(self, input_channels): """Calculated output channel number""" return input_channels def output_size(self, input_height, input_width)-
Calculated output size of output after postprocessing, given input image sizes
Expand source code
def output_size(self, input_height, input_width): """Calculated output size of output after postprocessing, given input image sizes""" return input_height, input_width def process(self, image)-
Process image according to processor
Expand source code
@abstractmethod def process(self, image): """Process image according to processor""" raise NotImplementedError("process(image)-> image should be implemented") # noinspection PyUnreachableCode return image