Package ai.djl.repository.zoo
Class BaseModelLoader
- java.lang.Object
-
- ai.djl.repository.zoo.BaseModelLoader
-
- All Implemented Interfaces:
ModelLoader
public class BaseModelLoader extends java.lang.Object implements ModelLoader
Shared code for theModelLoaderimplementations.
-
-
Field Summary
Fields Modifier and Type Field Description protected TranslatorFactorydefaultFactoryprotected MRLmrl
-
Constructor Summary
Constructors Constructor Description BaseModelLoader(MRL mrl)Constructs aModelLoadergiven the repository, mrl, and version.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ModelcreateModel(java.nio.file.Path modelPath, java.lang.String name, Device device, Block block, java.util.Map<java.lang.String,java.lang.Object> arguments, java.lang.String engine)ApplicationgetApplication()Returns the application of theModelLoader.java.lang.StringgetArtifactId()Returns the artifact ID of theModelLoader.protected TranslatorFactorygetTranslatorFactory(Criteria<?,?> criteria, java.util.Map<java.lang.String,java.lang.Object> arguments)java.util.List<Artifact>listModels()Returns a list of the available artifacts that can be loaded.<I,O>
ZooModel<I,O>loadModel(Criteria<I,O> criteria)Loads the model with the given criteria.java.lang.StringtoString()
-
-
-
Field Detail
-
mrl
protected MRL mrl
-
defaultFactory
protected TranslatorFactory defaultFactory
-
-
Constructor Detail
-
BaseModelLoader
public BaseModelLoader(MRL mrl)
Constructs aModelLoadergiven the repository, mrl, and version.- Parameters:
mrl- the mrl of the model to load
-
-
Method Detail
-
getArtifactId
public java.lang.String getArtifactId()
Returns the artifact ID of theModelLoader.- Specified by:
getArtifactIdin interfaceModelLoader- Returns:
- the artifact ID of the
ModelLoader
-
getApplication
public Application getApplication()
Returns the application of theModelLoader.- Specified by:
getApplicationin interfaceModelLoader- Returns:
- the application of the
ModelLoader
-
loadModel
public <I,O> ZooModel<I,O> loadModel(Criteria<I,O> criteria) throws java.io.IOException, ModelNotFoundException, MalformedModelException
Loads the model with the given criteria.- Specified by:
loadModelin 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:
java.io.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
public java.util.List<Artifact> listModels() throws java.io.IOException
Returns a list of the available artifacts that can be loaded.- Specified by:
listModelsin interfaceModelLoader- Returns:
- a list of the available artifacts that can be loaded
- Throws:
java.io.IOException- for errors reading the artifact list
-
createModel
protected Model createModel(java.nio.file.Path modelPath, java.lang.String name, Device device, Block block, java.util.Map<java.lang.String,java.lang.Object> arguments, java.lang.String engine) throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getTranslatorFactory
protected TranslatorFactory getTranslatorFactory(Criteria<?,?> criteria, java.util.Map<java.lang.String,java.lang.Object> arguments)
-
-