Class ModelZoo

java.lang.Object
ai.djl.repository.zoo.ModelZoo
Direct Known Subclasses:
DefaultModelZoo

public abstract class ModelZoo extends Object
An interface represents a collection of models.
  • Constructor Details

    • ModelZoo

      public ModelZoo()
  • Method Details

    • getGroupId

      public abstract String getGroupId()
      Returns the global unique identifier of the ModelZoo.

      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 Collection<ModelLoader> getModelLoaders()
      Lists the available model families in the ModelZoo.
      Returns:
      the list of all available model families
    • getModelLoader

      public ModelLoader getModelLoader(String name)
      Returns the ModelLoader based on the model name.
      Parameters:
      name - the name of the model
      Returns:
      the ModelLoader of the model
    • getSupportedEngines

      public abstract Set<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)
    • setModelZooResolver

      public static void setModelZooResolver(ModelZooResolver resolver)
      Sets the ModelZooResolver.
      Parameters:
      resolver - the ModelZooResolver
    • registerModelZoo

      public static void registerModelZoo(ZooProvider provider)
      Refreshes model zoo.
      Parameters:
      provider - the ZooProvider
    • listModelZoo

      public static Collection<ModelZoo> listModelZoo()
      Returns available model zoos.
      Returns:
      a list of model zoo
    • getModelZoo

      public static ModelZoo getModelZoo(String groupId)
      Returns the ModelZoo with the groupId.
      Parameters:
      groupId - the model zoo group id to check for
      Returns:
      the ModelZoo with the groupId
    • hasModelZoo

      public static boolean hasModelZoo(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 IOException, ModelNotFoundException, MalformedModelException
      Load the ZooModel that matches this criteria.
      Type Parameters:
      I - the input data type for preprocessing
      O - 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 repository
      ModelNotFoundException - if no model with the specified criteria is found
      MalformedModelException - if the model data is malformed
    • listModels

      public static Map<Application,List<Artifact>> listModels() throws IOException, ModelNotFoundException
      Returns the available Application and their model artifact metadata.
      Returns:
      the available Application and their model artifact metadata
      Throws:
      IOException - if failed to download to repository metadata
      ModelNotFoundException - if failed to parse repository metadata
    • listModels

      public static Map<Application,List<Artifact>> listModels(Criteria<?,?> criteria) throws IOException, ModelNotFoundException
      Returns the available Application 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 metadata
      ModelNotFoundException - if failed to parse repository metadata