Package ai.djl.repository.zoo
Class Criteria<I,O>
- java.lang.Object
-
- ai.djl.repository.zoo.Criteria<I,O>
-
- Type Parameters:
I- the model input typeO- the model output type
public class Criteria<I,O> extends java.lang.ObjectTheCriteriaclass contains search criteria to look up aZooModel.Criteria follows Builder pattern. See
Criteria.Builderfor detail. In DJL's builder convention, the methods start withsetare required fields, andoptfor 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCriteria.Builder<I,O>A Builder to construct aCriteria.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Criteria.Builder<?,?>builder()Creates a builder to build aCriteria.ApplicationgetApplication()Returns the application of the model.java.util.Map<java.lang.String,java.lang.Object>getArguments()Returns the override configurations of the model loading arguments.java.lang.StringgetArtifactId()Returns the artifactId of theModelLoaderto be searched.BlockgetBlock()DevicegetDevice()Returns theDeviceof the model to be loaded on.java.lang.StringgetEngine()Returns the engine name.java.util.Map<java.lang.String,java.lang.String>getFilters()Returns the search filters that must match the properties of the model.java.lang.StringgetGroupId()Returns the groupId of theModelZooto be searched.java.lang.Class<I>getInputClass()Returns the input data type.java.lang.StringgetModelName()Returns the optional model name to be used forZooModel.ModelZoogetModelZoo()Returns theModelZooto be searched.java.util.Map<java.lang.String,java.lang.String>getOptions()Returns the model loading options.java.lang.Class<O>getOutputClass()Returns the output data type.ai.djl.util.ProgressgetProgress()Returns the optionalProgressfor the model loading.TranslatorFactorygetTranslatorFactory()Returns the optionalTranslatorFactoryto be used forZooModel.ZooModel<I,O>loadModel()Load theZooModelthat matches this criteria.Criteria.Builder<I,O>toBuilder()Creates a newCriteria.Builderwhich starts with the values of thisCriteria.java.lang.StringtoString()
-
-
-
Method Detail
-
loadModel
public ZooModel<I,O> loadModel() throws java.io.IOException, ModelNotFoundException, MalformedModelException
Load theZooModelthat matches this criteria.- 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
-
getApplication
public Application getApplication()
Returns the application of the model.- Returns:
- the application of the model
-
getInputClass
public java.lang.Class<I> getInputClass()
Returns the input data type.- Returns:
- the input data type
-
getOutputClass
public java.lang.Class<O> getOutputClass()
Returns the output data type.- Returns:
- the output data type
-
getEngine
public java.lang.String getEngine()
Returns the engine name.- Returns:
- the engine name
-
getDevice
public Device getDevice()
Returns theDeviceof the model to be loaded on.- Returns:
- the
Deviceof the model to be loaded on
-
getGroupId
public java.lang.String getGroupId()
Returns the groupId of theModelZooto be searched.- Returns:
- the groupId of the
ModelZooto be searched
-
getArtifactId
public java.lang.String getArtifactId()
Returns the artifactId of theModelLoaderto be searched.- Returns:
- the artifactIds of the
ModelLoaderto be searched
-
getModelZoo
public ModelZoo getModelZoo()
Returns theModelZooto be searched.- Returns:
- the
ModelZooto be searched
-
getFilters
public java.util.Map<java.lang.String,java.lang.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 java.util.Map<java.lang.String,java.lang.Object> getArguments()
Returns the override configurations of the model loading arguments.- Returns:
- the override configurations of the model loading arguments
-
getOptions
public java.util.Map<java.lang.String,java.lang.String> getOptions()
Returns the model loading options.- Returns:
- the model loading options
-
getTranslatorFactory
public TranslatorFactory getTranslatorFactory()
Returns the optionalTranslatorFactoryto be used forZooModel.- Returns:
- the optional
TranslatorFactoryto be used forZooModel
-
getModelName
public java.lang.String getModelName()
Returns the optional model name to be used forZooModel.- Returns:
- the optional model name to be used for
ZooModel
-
getProgress
public ai.djl.util.Progress getProgress()
Returns the optionalProgressfor the model loading.- Returns:
- the optional
Progressfor the model loading
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toBuilder
public Criteria.Builder<I,O> toBuilder()
Creates a newCriteria.Builderwhich starts with the values of thisCriteria.- Returns:
- a new
Criteria.Builder
-
builder
public static Criteria.Builder<?,?> builder()
Creates a builder to build aCriteria.The methods start with
setare required fields, andoptfor optional fields.- Returns:
- a new builder
-
-