Package ai.djl.repository.zoo
Class BaseModelLoader
java.lang.Object
ai.djl.repository.zoo.BaseModelLoader
- All Implemented Interfaces:
ModelLoader
Shared code for the
ModelLoader
implementations.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBaseModelLoader
(MRL mrl) Constructs aModelLoader
given the repository, mrl, and version. -
Method Summary
Modifier and TypeMethodDescriptionprotected Model
createModel
(Path modelPath, String name, Device device, Block block, Map<String, Object> arguments, String engine) Returns the application of theModelLoader
.Returns the artifact ID of theModelLoader
.protected TranslatorFactory
getTranslatorFactory
(Criteria<?, ?> criteria, Map<String, Object> arguments) Returns a list of the available artifacts that can be loaded.<I,
O> ZooModel<I, O> Loads the model with the given criteria.toString()
-
Field Details
-
mrl
-
defaultFactory
-
-
Constructor Details
-
BaseModelLoader
Constructs aModelLoader
given the repository, mrl, and version.- Parameters:
mrl
- the mrl of the model to load
-
-
Method Details
-
getArtifactId
Returns the artifact ID of theModelLoader
.- Specified by:
getArtifactId
in interfaceModelLoader
- Returns:
- the artifact ID of the
ModelLoader
-
getApplication
Returns the application of theModelLoader
.- Specified by:
getApplication
in interfaceModelLoader
- Returns:
- the application of the
ModelLoader
-
loadModel
public <I,O> ZooModel<I,O> loadModel(Criteria<I, O> criteria) throws IOException, ModelNotFoundException, MalformedModelExceptionLoads the model with the given criteria.- Specified by:
loadModel
in interfaceModelLoader
- Type Parameters:
I
- the input data typeO
- the output data type- Parameters:
criteria
- the criteria to match against the loaded model- Returns:
- the loaded model
- Throws:
IOException
- for various exceptions loading data from the repositoryModelNotFoundException
- if no model with the specified criteria is foundMalformedModelException
- if the model data is malformed
-
listModels
Returns a list of the available artifacts that can be loaded.- Specified by:
listModels
in interfaceModelLoader
- Returns:
- a list of the available artifacts that can be loaded
- Throws:
IOException
- for errors reading the artifact list
-
createModel
protected Model createModel(Path modelPath, String name, Device device, Block block, Map<String, Object> arguments, String engine) throws IOException- Throws:
IOException
-
toString
-
getTranslatorFactory
protected TranslatorFactory getTranslatorFactory(Criteria<?, ?> criteria, Map<String, Object> arguments)
-