Class Criteria<I,O>

java.lang.Object
ai.djl.repository.zoo.Criteria<I,O>
Type Parameters:
I - the model input type
O - the model output type

public class Criteria<I,O> extends Object
The Criteria class contains search criteria to look up a ZooModel.

Criteria follows Builder pattern. See Criteria.Builder for detail. In DJL's builder convention, the methods start with set are required fields, and opt for optional fields.

Examples

 Criteria<Image, Classifications> criteria = Criteria.builder()
         .setTypes(Image.class, Classifications.class) // defines input and output data type
         .optTranslator(ImageClassificationTranslator.builder().setSynsetArtifactName("synset.txt").build())
         .optModelUrls("file:///var/models/my_resnet50") // search models in specified path
         .optModelName("resnet50") // specify model file prefix
         .build();
 

See Model loading for more detail.

  • Method Details

    • loadModel

      Load the ZooModel that matches this criteria.
      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
    • getApplication

      public Application getApplication()
      Returns the application of the model.
      Returns:
      the application of the model
    • getInputClass

      public Class<I> getInputClass()
      Returns the input data type.
      Returns:
      the input data type
    • getOutputClass

      public Class<O> getOutputClass()
      Returns the output data type.
      Returns:
      the output data type
    • getEngine

      public String getEngine()
      Returns the engine name.
      Returns:
      the engine name
    • getDevice

      public Device getDevice()
      Returns the Device of the model to be loaded on.
      Returns:
      the Device of the model to be loaded on
    • getGroupId

      public String getGroupId()
      Returns the groupId of the ModelZoo to be searched.
      Returns:
      the groupId of the ModelZoo to be searched
    • getArtifactId

      public String getArtifactId()
      Returns the artifactId of the ModelLoader to be searched.
      Returns:
      the artifactIds of the ModelLoader to be searched
    • getModelZoo

      public ModelZoo getModelZoo()
      Returns the ModelZoo to be searched.
      Returns:
      the ModelZoo to be searched
    • getFilters

      public Map<String,String> getFilters()
      Returns the search filters that must match the properties of the model.
      Returns:
      the search filters that must match the properties of the model.
    • getArguments

      public Map<String,Object> getArguments()
      Returns the override configurations of the model loading arguments.
      Returns:
      the override configurations of the model loading arguments
    • getOptions

      public Map<String,String> getOptions()
      Returns the model loading options.
      Returns:
      the model loading options
    • getTranslatorFactory

      public TranslatorFactory getTranslatorFactory()
      Returns the optional TranslatorFactory to be used for ZooModel.
      Returns:
      the optional TranslatorFactory to be used for ZooModel
    • getBlock

      public Block getBlock()
      Returns the optional Block to be used for ZooModel.
      Returns:
      the optional Block to be used for ZooModel
    • getModelName

      public String getModelName()
      Returns the optional model name to be used for ZooModel.
      Returns:
      the optional model name to be used for ZooModel
    • getProgress

      public ai.djl.util.Progress getProgress()
      Returns the optional Progress for the model loading.
      Returns:
      the optional Progress for the model loading
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toBuilder

      public Criteria.Builder<I,O> toBuilder()
      Creates a new Criteria.Builder which starts with the values of this Criteria.
      Returns:
      a new Criteria.Builder
    • builder

      public static Criteria.Builder<?,?> builder()
      Creates a builder to build a Criteria.

      The methods start with set are required fields, and opt for optional fields.

      Returns:
      a new builder