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
Modifier and TypeClassDescriptionstatic final class
A Builder to construct aCriteria
. -
Method Summary
Modifier and TypeMethodDescriptionstatic Criteria.Builder<?,
?> builder()
Creates a builder to build aCriteria
.Returns the application of the model.Returns the override configurations of the model loading arguments.Returns the artifactId of theModelLoader
to be searched.getBlock()
Returns theDevice
of 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 theModelZoo
to be searched.Returns the input data type.Returns the optional model name to be used forZooModel
.Returns theModelZoo
to be searched.Returns the model loading options.Returns the output data type.ai.djl.util.Progress
Returns the optionalProgress
for the model loading.Returns the optionalTranslatorFactory
to be used forZooModel
.Load theZooModel
that matches this criteria.Creates a newCriteria.Builder
which starts with the values of thisCriteria
.toString()
-
Method Details
-
loadModel
public ZooModel<I,O> loadModel() throws IOException, ModelNotFoundException, MalformedModelExceptionLoad theZooModel
that 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 theDevice
of the model to be loaded on.- Returns:
- the
Device
of the model to be loaded on
-
getGroupId
Returns the groupId of theModelZoo
to be searched.- Returns:
- the groupId of the
ModelZoo
to be searched
-
getArtifactId
Returns the artifactId of theModelLoader
to be searched.- Returns:
- the artifactIds of the
ModelLoader
to be searched
-
getModelZoo
Returns theModelZoo
to be searched.- Returns:
- the
ModelZoo
to 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 optionalTranslatorFactory
to be used forZooModel
.- Returns:
- the optional
TranslatorFactory
to 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 optionalProgress
for the model loading.- Returns:
- the optional
Progress
for the model loading
-
toString
-
toBuilder
Creates a newCriteria.Builder
which starts with the values of thisCriteria
.- Returns:
- a new
Criteria.Builder
-
builder
Creates a builder to build aCriteria
.The methods start with
set
are required fields, andopt
for optional fields.- Returns:
- a new builder
-