public class BaseModelLoader extends java.lang.Object implements ModelLoader
ModelLoader
implementations.Modifier and Type | Field and Description |
---|---|
protected java.util.Map<ai.djl.util.Pair<java.lang.reflect.Type,java.lang.reflect.Type>,TranslatorFactory<?,?>> |
factories |
protected ModelZoo |
modelZoo |
protected Resource |
resource |
Modifier | Constructor and Description |
---|---|
protected |
BaseModelLoader(Repository repository,
MRL mrl,
java.lang.String version,
ModelZoo modelZoo)
Constructs a
ModelLoader given the repository, mrl, and version. |
Modifier and Type | Method and Description |
---|---|
protected Model |
createModel(java.lang.String name,
Device device,
Artifact artifact,
java.util.Map<java.lang.String,java.lang.Object> arguments,
java.lang.String engine) |
Application |
getApplication()
Returns the application of the
ModelLoader . |
java.lang.String |
getArtifactId()
Returns the artifact ID of the
ModelLoader . |
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.String |
toString() |
protected java.util.Map<ai.djl.util.Pair<java.lang.reflect.Type,java.lang.reflect.Type>,TranslatorFactory<?,?>> factories
protected ModelZoo modelZoo
protected Resource resource
protected BaseModelLoader(Repository repository, MRL mrl, java.lang.String version, ModelZoo modelZoo)
ModelLoader
given the repository, mrl, and version.repository
- the repository to load the model frommrl
- the mrl of the model to loadversion
- the version of the model to loadmodelZoo
- the modelZoo type that is being used to get supported engine typespublic java.lang.String getArtifactId()
ModelLoader
.getArtifactId
in interface ModelLoader
ModelLoader
public Application getApplication()
ModelLoader
.getApplication
in interface ModelLoader
ModelLoader
public <I,O> ZooModel<I,O> loadModel(Criteria<I,O> criteria) throws java.io.IOException, ModelNotFoundException, MalformedModelException
loadModel
in interface ModelLoader
I
- the input data typeO
- the output data typecriteria
- the criteria to match against the loaded modeljava.io.IOException
- for various exceptions loading data from the repositoryModelNotFoundException
- if no model with the specified criteria is foundMalformedModelException
- if the model data is malformedpublic java.util.List<Artifact> listModels() throws java.io.IOException
listModels
in interface ModelLoader
java.io.IOException
- for errors reading the artifact listprotected Model createModel(java.lang.String name, Device device, Artifact artifact, java.util.Map<java.lang.String,java.lang.Object> arguments, java.lang.String engine) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object