Package ai.djl.repository.zoo
Class ModelZoo
java.lang.Object
ai.djl.repository.zoo.ModelZoo
- Direct Known Subclasses:
DefaultModelZoo
An interface represents a collection of models.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
protected final void
addModel
(ModelLoader loader) abstract String
Returns the global unique identifier of theModelZoo
.getModelLoader
(String name) Returns theModelLoader
based on the model name.Lists the available model families in the ModelZoo.static ModelZoo
getModelZoo
(String groupId) Returns theModelZoo
with thegroupId
.Returns all supported engine names.static boolean
hasModelZoo
(String groupId) Returns whether a model zoo with the group id is available.static Map<Application,
List<Artifact>> Returns the availableApplication
and their model artifact metadata.static Map<Application,
List<Artifact>> listModels
(Criteria<?, ?> criteria) Returns the availableApplication
and their model artifact metadata.static Collection<ModelZoo>
Returns available model zoos.static <I,
O> ZooModel<I, O> Load theZooModel
that matches this criteria.static void
registerModelZoo
(ZooProvider provider) Refreshes model zoo.static void
setModelZooResolver
(ModelZooResolver resolver) Sets theModelZooResolver
.
-
Constructor Details
-
ModelZoo
public ModelZoo()
-
-
Method Details
-
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
Lists the available model families in the ModelZoo.- Returns:
- the list of all available model families
-
getModelLoader
Returns theModelLoader
based on the model name.- Parameters:
name
- the name of the model- Returns:
- the
ModelLoader
of the model
-
getSupportedEngines
Returns all supported engine names.- Returns:
- all supported engine names
-
addModel
-
addModel
-
setModelZooResolver
Sets theModelZooResolver
.- Parameters:
resolver
- theModelZooResolver
-
registerModelZoo
Refreshes model zoo.- Parameters:
provider
- theZooProvider
-
listModelZoo
Returns available model zoos.- Returns:
- a list of model zoo
-
getModelZoo
Returns theModelZoo
with thegroupId
.- Parameters:
groupId
- the model zoo group id to check for- Returns:
- the
ModelZoo
with thegroupId
-
hasModelZoo
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 IOException, ModelNotFoundException, MalformedModelExceptionLoad theZooModel
that 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:
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 Map<Application,List<Artifact>> listModels() throws IOException, ModelNotFoundExceptionReturns the availableApplication
and their model artifact metadata.- Returns:
- the available
Application
and their model artifact metadata - Throws:
IOException
- if failed to download to repository metadataModelNotFoundException
- if failed to parse repository metadata
-
listModels
public static Map<Application,List<Artifact>> listModels(Criteria<?, ?> criteria) throws IOException, ModelNotFoundExceptionReturns the availableApplication
and their model artifact metadata.- Parameters:
criteria
- the requirements for the model- Returns:
- the available
Application
and their model artifact metadata - Throws:
IOException
- if failed to download to repository metadataModelNotFoundException
- if failed to parse repository metadata
-