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
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA Builder to construct aCriteria. -
Method Summary
Modifier and TypeMethodDescriptionstatic Criteria.Builder<?,?> builder()Creates a builder to build aCriteria.voidDownloads the model artifacts that matches this criteria.Returns the application of the model.Returns the override configurations of the model loading arguments.Returns the artifactId of theModelLoaderto be searched.getBlock()Returns theDeviceof the model to be loaded on.Returns the engine name.Returns the search filters that must match the properties of the model.Returns the groupId of theModelZooto be searched.Returns the input data type.Returns the optional model name to be used forZooModel.Returns theModelZooto be searched.Returns the model loading options.Returns the output data type.ai.djl.util.ProgressReturns the optionalProgressfor the model loading.Returns the optionalTranslatorFactoryto be used forZooModel.booleanReturnstrueof the model artifacts has been downloaded.Loads theZooModelthat matches this criteria.Creates a newCriteria.Builderwhich starts with the values of thisCriteria.toString()
-
Method Details
-
isDownloaded
Returnstrueof the model artifacts has been downloaded.- Returns:
trueof the model artifacts has been downloaded- Throws:
IOException- for various exceptions loading data from the repositoryModelNotFoundException- if no model with the specified criteria is found
-
downloadModel
Downloads the model artifacts that matches this criteria.- Throws:
IOException- for various exceptions loading data from the repositoryModelNotFoundException- if no model with the specified criteria is found
-
loadModel
public ZooModel<I,O> loadModel() throws IOException, ModelNotFoundException, MalformedModelExceptionLoads theZooModelthat matches this criteria.- 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
-
getApplication
Returns the application of the model.- Returns:
- the application of the model
-
getInputClass
Returns the input data type.- Returns:
- the input data type
-
getOutputClass
Returns the output data type.- Returns:
- the output data type
-
getEngine
Returns the engine name.- Returns:
- the engine name
-
getDevice
Returns theDeviceof the model to be loaded on.- Returns:
- the
Deviceof the model to be loaded on
-
getGroupId
Returns the groupId of theModelZooto be searched.- Returns:
- the groupId of the
ModelZooto be searched
-
getArtifactId
Returns the artifactId of theModelLoaderto be searched.- Returns:
- the artifactIds of the
ModelLoaderto be searched
-
getModelZoo
Returns theModelZooto be searched.- Returns:
- the
ModelZooto be searched
-
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
Returns the override configurations of the model loading arguments.- Returns:
- the override configurations of the model loading arguments
-
getOptions
Returns the model loading options.- Returns:
- the model loading options
-
getTranslatorFactory
Returns the optionalTranslatorFactoryto be used forZooModel.- Returns:
- the optional
TranslatorFactoryto be used forZooModel
-
getBlock
-
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
-
toBuilder
Creates a newCriteria.Builderwhich starts with the values of thisCriteria.- Returns:
- a new
Criteria.Builder
-
builder
Creates a builder to build aCriteria.The methods start with
setare required fields, andoptfor optional fields.- Returns:
- a new builder
-