public abstract class BaseModelLoader<I,O> extends java.lang.Object implements ModelLoader<I,O>
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 MRL |
mrl |
protected Repository |
repository |
protected java.lang.String |
version |
| 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) |
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.
|
<S,T> ZooModel<S,T> |
loadModel(Criteria<S,T> criteria)
Loads the model with the given criteria.
|
protected Artifact |
match(java.util.Map<java.lang.String,java.lang.String> criteria)
Returns the first artifact that matches a given criteria.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetApplication, loadModel, loadModel, loadModel, loadModel, loadModelprotected Repository repository
protected MRL mrl
protected java.lang.String version
protected java.util.Map<ai.djl.util.Pair<java.lang.reflect.Type,java.lang.reflect.Type>,TranslatorFactory<?,?>> factories
protected ModelZoo modelZoo
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<I,O>ModelLoaderpublic <S,T> ZooModel<S,T> loadModel(Criteria<S,T> criteria) throws java.io.IOException, ModelNotFoundException, MalformedModelException
loadModel in interface ModelLoader<I,O>S - the input data typeT - 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, ModelNotFoundException
listModels in interface ModelLoader<I,O>java.io.IOException - for errors reading the artifact listModelNotFoundException - if models with the mrl defined within this loader are foundprotected 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.IOExceptionprotected Artifact match(java.util.Map<java.lang.String,java.lang.String> criteria) throws java.io.IOException, ModelNotFoundException
criteria - the criteria to match againstjava.io.IOException - for errors while loading the modelModelNotFoundException - if the metadata to get artifacts from is not foundpublic java.lang.String toString()
toString in class java.lang.Object