Interface ModelLoader<T>
-
- Type Parameters:
T- the type of loaded model (e.g., OrtSession, SavedModelBundle)
- All Known Implementing Classes:
OnnxModelLoader
public interface ModelLoader<T>Interface for loading ML models from various sources.Implementations handle the specifics of loading different model formats (ONNX, TensorFlow, PyTorch, etc.) from various storage systems (file system, HDFS, S3, HTTP, etc.).
Responsibilities:
- Load models from configured paths
- Validate model format and integrity
- Extract model metadata
- Handle different storage backends
Implementation Example:
{@code public class OnnxModelLoader implements ModelLoader{ - Since:
- 1.0.0
- Author:
- Nestor Martourez, Sr Software and Data Streaming Engineer @ CodedStreams
- See Also:
ModelConfig,ModelMetadata
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ModelMetadatagetModelMetadata(T model)Extracts metadata from a loaded model.ModelFormat[]getSupportedFormats()Gets the model formats supported by this loader.TloadModel(ModelConfig config)Loads a model from the path specified in configuration.TloadModel(InputStream inputStream, ModelConfig config)Loads a model from an input stream.booleanvalidateModel(T model, ModelConfig config)Validates that a loaded model matches the configuration.
-
-
-
Method Detail
-
loadModel
T loadModel(ModelConfig config) throws ModelLoadException
Loads a model from the path specified in configuration.- Parameters:
config- model configuration containing path and options- Returns:
- loaded model instance
- Throws:
ModelLoadException- if loading fails
-
loadModel
T loadModel(InputStream inputStream, ModelConfig config) throws ModelLoadException
Loads a model from an input stream.Useful for loading models from non-file sources.
- Parameters:
inputStream- stream containing model dataconfig- model configuration- Returns:
- loaded model instance
- Throws:
ModelLoadException- if loading fails
-
validateModel
boolean validateModel(T model, ModelConfig config)
Validates that a loaded model matches the configuration.- Parameters:
model- the loaded modelconfig- model configuration- Returns:
- true if model is valid
-
getSupportedFormats
ModelFormat[] getSupportedFormats()
Gets the model formats supported by this loader.- Returns:
- array of supported formats
-
getModelMetadata
ModelMetadata getModelMetadata(T model)
Extracts metadata from a loaded model.- Parameters:
model- the loaded model- Returns:
- model metadata including inputs, outputs, and format
-
-