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.YZLiteModelobject- 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” modeprint_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 necessarylogger (Optional[Logger]) –
- Return type:
- 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
.pymodel specificaton or a model archive.yzlite.zip.- Return type:
- Parameters:
model_path (str) –
test (bool) –
logger (Optional[Logger]) –
reload (bool) –
list_yzlite_models¶
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.YZLiteModelinstance OR a model archive .yzlite.zip, AND model_type is:None-> return builtyzlite.core.KerasModelfrom model specificationtflite-> return loadedyzlite.core.TfliteModelfrom model archiveh5-> return loadedyzlite.core.KerasModelfrom model archive
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 modelbuild (
bool) – If the given YZLite model should be built into a .tfliteprint_not_found_err (
bool) – If the model model is not found, print possible alternatives and exitreturn_tflite_path (
bool) – If true, return the file path to the .tflite, otherwise return a TfliteModel instancetest (
bool) – If a “test” model is providedlogger (
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