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.Object
TheCriteria
class contains search criteria to look up aZooModel
.Criteria follows Builder pattern. See
Criteria.Builder
for detail. In DJL's builder convention, the methods start withset
are required fields, andopt
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 Classes Modifier and Type Class Description static class
Criteria.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
.Application
getApplication()
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.String
getArtifactId()
Returns the artifactId of theModelLoader
to be searched.Block
getBlock()
Device
getDevice()
Returns theDevice
of the model to be loaded on.java.lang.String
getEngine()
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.String
getGroupId()
Returns the groupId of theModelZoo
to be searched.java.lang.Class<I>
getInputClass()
Returns the input data type.java.lang.String
getModelName()
Returns the optional model name to be used forZooModel
.ModelZoo
getModelZoo()
Returns theModelZoo
to 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.Progress
getProgress()
Returns the optionalProgress
for the model loading.TranslatorFactory
getTranslatorFactory()
Returns the optionalTranslatorFactory
to be used forZooModel
.ZooModel<I,O>
loadModel()
Load theZooModel
that matches this criteria.Criteria.Builder<I,O>
toBuilder()
Creates a newCriteria.Builder
which starts with the values of thisCriteria
.java.lang.String
toString()
-
-
-
Method Detail
-
loadModel
public ZooModel<I,O> loadModel() throws java.io.IOException, ModelNotFoundException, MalformedModelException
Load theZooModel
that 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 theDevice
of the model to be loaded on.- Returns:
- the
Device
of the model to be loaded on
-
getGroupId
public java.lang.String getGroupId()
Returns the groupId of theModelZoo
to be searched.- Returns:
- the groupId of the
ModelZoo
to be searched
-
getArtifactId
public java.lang.String getArtifactId()
Returns the artifactId of theModelLoader
to be searched.- Returns:
- the artifactIds of the
ModelLoader
to be searched
-
getModelZoo
public ModelZoo getModelZoo()
Returns theModelZoo
to be searched.- Returns:
- the
ModelZoo
to 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 optionalTranslatorFactory
to be used forZooModel
.- Returns:
- the optional
TranslatorFactory
to 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 optionalProgress
for the model loading.- Returns:
- the optional
Progress
for the model loading
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toBuilder
public Criteria.Builder<I,O> toBuilder()
Creates a newCriteria.Builder
which 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
set
are required fields, andopt
for optional fields.- Returns:
- a new builder
-
-