aigarmic.model ============== .. py:module:: aigarmic.model .. autoapi-nested-parse:: Implementation of Model classes Classes ------- .. autoapisummary:: aigarmic.model.Model aigarmic.model.KerasModel aigarmic.model.SoftmaxModel aigarmic.model.BinaryModel aigarmic.model.BinaryNestedModel Functions --------- .. autoapisummary:: aigarmic.model.convert_cv2_to_keras Module Contents --------------- .. py:function:: convert_cv2_to_keras(image, size_x=160, size_y=160) -> numpy.ndarray Convert a cv2 image to a keras image :param image: Image loaded using cv2.imread :param size_x: Width to resize image to (pixels) :param size_y: Height to resize image to (pixels) :return: Image as a numpy array .. py:class:: Model(key: Optional[list[str]]) Bases: :py:obj:`abc.ABC` Helper class that provides a standard way to create an ABC using inheritance. .. py:method:: get_key() -> list[str] Return key to convert model output to human-readable label :return: .. py:method:: predict(image) -> dict :abstractmethod: .. py:class:: KerasModel(path: str, trained_x: int, trained_y: int, key: Optional[list[str]]) Bases: :py:obj:`Model` Helper class that provides a standard way to create an ABC using inheritance. .. py:method:: load_model(path: str) -> None Load a keras model from file :param path: path to saved model .. py:method:: predict(image: numpy.ndarray) -> dict :abstractmethod: .. py:class:: SoftmaxModel(path: str, trained_x: int, trained_y: int, key: Optional[list[str]]) Bases: :py:obj:`KerasModel` SoftmaxModel is a one-stop model when more than one growth category is present, e.g.: ['No growth', 'Poor growth', 'Good growth'] .. py:method:: predict(image: numpy.ndarray) -> dict Predict growth category from image :param image: loaded using cv2.imread :return: dictionary with keys 'prediction', 'score', 'growth_code', 'growth', 'accuracy' .. py:class:: BinaryModel(path: str, trained_x: int, trained_y: int, key: Optional[list[str]], threshold: float = 0.5) Bases: :py:obj:`KerasModel` Helper class that provides a standard way to create an ABC using inheritance. .. py:method:: predict(image: numpy.ndarray) -> dict Predict growth category from image :param image: image loaded using cv2.imread :return: dictionary with keys 'prediction', 'score', 'growth_code', 'growth', 'accuracy' .. py:class:: BinaryNestedModel(first_line_model: BinaryModel, second_line_model: BinaryModel, first_model_accuracy_acceptance: float = 0.9, suppress_first_model_accuracy_check: bool = False) Bases: :py:obj:`Model` Helper class that provides a standard way to create an ABC using inheritance. .. py:method:: predict(image: numpy.ndarray) -> dict Predict colony growth from image :param image: image loaded using cv2.imread :return: dictionary with keys 'prediction', 'score', 'growth_code', 'growth', 'accuracy'