Model Utilities

load_yzlite_model

load_yzlite_model(model, test=False, print_not_found_err=False, logger=None, reload=True)[source]

Find a YZLITE model with the given name and instantiate its corresponding yzlite.core.YZLiteModel object

Parameters:
  • model (str) – Name of YZLITE model or path to YZLITE model’s python specification script or archive. Append -test to the YZLITE model name to load into “testing” mode (this is the same as setting the argument: test=True)

  • test (bool) – If the YZLITE model should be loaded in “testing” mode

  • print_not_found_err – If true and the YZLITE model is not found, then print an error

  • reload (bool) – If the given model is a python script then reload the module if necessary

  • logger (Optional[Logger]) –

Return type:

YZLiteModel

Returns:

Load model object

load_yzlite_model_with_path

load_yzlite_model_with_path(model_path, test=False, logger=None, reload=True)[source]

Instantiate a YZLiteModel object from the given model path The model path can be a .py model specificaton or a model archive .yzlite.zip.

Return type:

YZLiteModel

Parameters:
  • model_path (str) –

  • test (bool) –

  • logger (Optional[Logger]) –

  • reload (bool) –

list_yzlite_models

list_yzlite_models(test=False, for_utests=False, logger=None)[source]

Return a list of all found YZLITE model names

Return type:

List[str]

Parameters:
  • test (bool) –

  • logger (Optional[Logger]) –

load_tflite_or_keras_model

load_tflite_or_keras_model(model, model_type=None, weights=None, logger=None)[source]

Instantiate a Keras or TfliteModel object

IF model is an yzlite.core.YZLiteModel instance OR a model archive .yzlite.zip, AND model_type is:

ELSE model should be the file path to a .tflite or .h5 model file.

Return type:

Union[TfliteModel, Model]

Parameters:
  • model (Union[YZLiteModel, str]) –

  • model_type (Optional[str]) –

  • weights (Optional[str]) –

  • logger (Optional[Logger]) –

load_tflite_model

load_tflite_model(model, build=False, print_not_found_err=False, return_tflite_path=False, test=False, logger=None)[source]

Return the path to a .tflite model file or a TfliteModel instance

Parameters:
  • model (Union[str, YZLiteModel, TfliteModel]) – One of the following: - An YZLiteModel model instance - An TfliteModel model instance - The path to a .tflite - The path to a .yzlite.zip model archive - The path to a .py YZLITE model specification - The name of an YZLITE model

  • build (bool) – If the given YZLite model should be built into a .tflite

  • print_not_found_err (bool) – If the model model is not found, print possible alternatives and exit

  • return_tflite_path (bool) – If true, return the file path to the .tflite, otherwise return a TfliteModel instance

  • test (bool) – If a “test” model is provided

  • logger (Optional[Logger]) – Optional logger

Return type:

Union[TfliteModel, str]

Returns:

The corresponding TfliteModel if return_tflite_path=False or the path to the .tflite if return_tflite_path=True