Package ai.djl.repository.zoo
Class ModelZoo
- java.lang.Object
-
- ai.djl.repository.zoo.ModelZoo
-
- Direct Known Subclasses:
DefaultModelZoo
public abstract class ModelZoo extends java.lang.ObjectAn interface represents a collection of models.
-
-
Constructor Summary
Constructors Constructor Description ModelZoo()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddModel(MRL mrl)protected voidaddModel(ModelLoader loader)abstract java.lang.StringgetGroupId()Returns the global unique identifier of theModelZoo.ModelLoadergetModelLoader(java.lang.String name)Returns theModelLoaderbased on the model name.java.util.Collection<ModelLoader>getModelLoaders()Lists the available model families in the ModelZoo.static ModelZoogetModelZoo(java.lang.String groupId)Returns theModelZoowith thegroupId.abstract java.util.Set<java.lang.String>getSupportedEngines()Returns all supported engine names.static booleanhasModelZoo(java.lang.String groupId)Returns whether a model zoo with the group id is available.static java.util.Map<Application,java.util.List<Artifact>>listModels()Returns the availableApplicationand their model artifact metadata.static java.util.Map<Application,java.util.List<Artifact>>listModels(Criteria<?,?> criteria)Returns the availableApplicationand their model artifact metadata.static java.util.Collection<ModelZoo>listModelZoo()Returns available model zoos.static <I,O>
ZooModel<I,O>loadModel(Criteria<I,O> criteria)Load theZooModelthat matches this criteria.static voidregisterModelZoo(ZooProvider provider)Refreshes model zoo.
-
-
-
Method Detail
-
getGroupId
public abstract java.lang.String getGroupId()
Returns the global unique identifier of theModelZoo.We recommend to use reverse DNS name as your model zoo group ID to make sure it's not conflict with other ModelZoos.
- Returns:
- the global unique identifier of the
ModelZoo
-
getModelLoaders
public java.util.Collection<ModelLoader> getModelLoaders()
Lists the available model families in the ModelZoo.- Returns:
- the list of all available model families
-
getModelLoader
public ModelLoader getModelLoader(java.lang.String name)
Returns theModelLoaderbased on the model name.- Parameters:
name- the name of the model- Returns:
- the
ModelLoaderof the model
-
getSupportedEngines
public abstract java.util.Set<java.lang.String> getSupportedEngines()
Returns all supported engine names.- Returns:
- all supported engine names
-
addModel
protected final void addModel(MRL mrl)
-
addModel
protected final void addModel(ModelLoader loader)
-
registerModelZoo
public static void registerModelZoo(ZooProvider provider)
Refreshes model zoo.- Parameters:
provider- theZooProvider
-
listModelZoo
public static java.util.Collection<ModelZoo> listModelZoo()
Returns available model zoos.- Returns:
- a list of model zoo
-
getModelZoo
public static ModelZoo getModelZoo(java.lang.String groupId)
Returns theModelZoowith thegroupId.- Parameters:
groupId- the model zoo group id to check for- Returns:
- the
ModelZoowith thegroupId
-
hasModelZoo
public static boolean hasModelZoo(java.lang.String groupId)
Returns whether a model zoo with the group id is available.- Parameters:
groupId- the model zoo group id to check for- Returns:
- whether a model zoo with the group id is available
-
loadModel
public static <I,O> ZooModel<I,O> loadModel(Criteria<I,O> criteria) throws java.io.IOException, ModelNotFoundException, MalformedModelException
Load theZooModelthat matches this criteria.- Type Parameters:
I- the input data type for preprocessingO- the output data type after postprocessing- Parameters:
criteria- the requirements for the model- Returns:
- the model that matches the criteria
- 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 static java.util.Map<Application,java.util.List<Artifact>> listModels() throws java.io.IOException, ModelNotFoundException
Returns the availableApplicationand their model artifact metadata.- Returns:
- the available
Applicationand their model artifact metadata - Throws:
java.io.IOException- if failed to download to repository metadataModelNotFoundException- if failed to parse repository metadata
-
listModels
public static java.util.Map<Application,java.util.List<Artifact>> listModels(Criteria<?,?> criteria) throws java.io.IOException, ModelNotFoundException
Returns the availableApplicationand their model artifact metadata.- Parameters:
criteria- the requirements for the model- Returns:
- the available
Applicationand their model artifact metadata - Throws:
java.io.IOException- if failed to download to repository metadataModelNotFoundException- if failed to parse repository metadata
-
-