Package ai.djl.modality
Class Input
- java.lang.Object
-
- ai.djl.modality.Input
-
- Direct Known Subclasses:
Output
public class Input extends java.lang.ObjectA class stores the generic input data for inference.
-
-
Constructor Summary
Constructors Constructor Description Input()Constructs a newInputinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(byte[] data)Appends an item at the end of the input.voidadd(int index, java.lang.String key, BytesSupplier data)Inserts the specified element at the specified position in the input.voidadd(BytesSupplier data)Appends an item at the end of the input.voidadd(java.lang.String data)Appends an item at the end of the input.voidadd(java.lang.String key, byte[] data)Adds a key/value pair to the input content.voidadd(java.lang.String key, BytesSupplier data)Adds a key/value pair to the input content.voidadd(java.lang.String key, java.lang.String data)Adds a key/value pair to the input content.voidaddProperty(java.lang.String key, java.lang.String value)Adds a property to the input.BytesSupplierget(int index)Returns the element at the specified position in theInput.BytesSupplierget(java.lang.String key)Returns the element for the first key found in theInput.byte[]getAsBytes(int index)Returns the value asbyte[]at the specified position in theInput.byte[]getAsBytes(java.lang.String key)Returns the value asbyte[]for the first key found in theInput.NDArraygetAsNDArray(NDManager manager, int index)Returns the value asNDArrayat the specified position in theInput.NDArraygetAsNDArray(NDManager manager, java.lang.String key)Returns the value asNDArrayfor the first key found in theInput.NDListgetAsNDList(NDManager manager, int index)Returns the value asNDListat the specified position in theInput.NDListgetAsNDList(NDManager manager, java.lang.String key)Returns the value asNDListfor the first key found in theInput.java.lang.StringgetAsString(int index)Returns the value asbyte[]at the specified position in theInput.java.lang.StringgetAsString(java.lang.String key)Returns the value asbyte[]for the first key found in theInput.ai.djl.util.PairList<java.lang.String,BytesSupplier>getContent()Returns the content of the input.BytesSuppliergetData()Returns the default data item.NDListgetDataAsNDList(NDManager manager)Returns the default data asNDList.java.util.Map<java.lang.String,java.lang.String>getProperties()Returns the properties of the input.java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)Returns the value to which the specified key is mapped.voidsetContent(ai.djl.util.PairList<java.lang.String,BytesSupplier> content)Sets the content of the input.voidsetProperties(java.util.Map<java.lang.String,java.lang.String> properties)Sets the properties of the input.java.lang.StringtoString()*
-
-
-
Method Detail
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
Returns the properties of the input.- Returns:
- the properties of the input
-
setProperties
public void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
Sets the properties of the input.- Parameters:
properties- the properties of the input
-
addProperty
public void addProperty(java.lang.String key, java.lang.String value)Adds a property to the input.- Parameters:
key- key with which the specified value is to be addedvalue- value to be added with the specified key
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)Returns the value to which the specified key is mapped.- Parameters:
key- the key whose associated value is to be returneddefaultValue- the default mapping of the key- Returns:
- the value to which the specified key is mapped
-
getContent
public ai.djl.util.PairList<java.lang.String,BytesSupplier> getContent()
Returns the content of the input.A
Inputmay contains multiple data.- Returns:
- the content of the input
-
setContent
public void setContent(ai.djl.util.PairList<java.lang.String,BytesSupplier> content)
Sets the content of the input.- Parameters:
content- the content of the input
-
add
public void add(byte[] data)
Appends an item at the end of the input.- Parameters:
data- data to be added
-
add
public void add(java.lang.String data)
Appends an item at the end of the input.- Parameters:
data- data to be added
-
add
public void add(BytesSupplier data)
Appends an item at the end of the input.- Parameters:
data- data to be added
-
add
public void add(java.lang.String key, byte[] data)Adds a key/value pair to the input content.- Parameters:
key- key with which the specified data is to be addeddata- data to be added with the specified key
-
add
public void add(java.lang.String key, java.lang.String data)Adds a key/value pair to the input content.- Parameters:
key- key with which the specified data is to be addeddata- data to be added with the specified key
-
add
public void add(java.lang.String key, BytesSupplier data)Adds a key/value pair to the input content.- Parameters:
key- key with which the specified data is to be addeddata- data to be added with the specified key
-
add
public void add(int index, java.lang.String key, BytesSupplier data)Inserts the specified element at the specified position in the input.- Parameters:
index- the index at which the specified element is to be insertedkey- key with which the specified data is to be addeddata- data to be added with the specified key
-
getData
public BytesSupplier getData()
Returns the default data item.- Returns:
- the default data item
-
getDataAsNDList
public NDList getDataAsNDList(NDManager manager)
Returns the default data asNDList.- Parameters:
manager-NDManagerused to create thisNDArray- Returns:
- the default data as
NDList
-
get
public BytesSupplier get(java.lang.String key)
Returns the element for the first key found in theInput.- Parameters:
key- the key of the element to get- Returns:
- the element for the first key found in the
Input
-
get
public BytesSupplier get(int index)
Returns the element at the specified position in theInput.- Parameters:
index- the index of the element to return- Returns:
- the element at the specified position in the
Input
-
getAsBytes
public byte[] getAsBytes(java.lang.String key)
Returns the value asbyte[]for the first key found in theInput.- Parameters:
key- the key of the element to get- Returns:
- the value as
byte[]for the first key found in theInput
-
getAsBytes
public byte[] getAsBytes(int index)
Returns the value asbyte[]at the specified position in theInput.- Parameters:
index- the index of the element to return- Returns:
- the value as
byte[]at the specified position in theInput
-
getAsString
public java.lang.String getAsString(java.lang.String key)
Returns the value asbyte[]for the first key found in theInput.- Parameters:
key- the key of the element to get- Returns:
- the value as
byte[]for the first key found in theInput
-
getAsString
public java.lang.String getAsString(int index)
Returns the value asbyte[]at the specified position in theInput.- Parameters:
index- the index of the element to return- Returns:
- the value as
byte[]at the specified position in theInput
-
getAsNDArray
public NDArray getAsNDArray(NDManager manager, java.lang.String key)
Returns the value asNDArrayfor the first key found in theInput.- Parameters:
manager-NDManagerused to create thisNDArraykey- the key of the element to get- Returns:
- the value as
NDArrayfor the first key found in theInput
-
getAsNDArray
public NDArray getAsNDArray(NDManager manager, int index)
Returns the value asNDArrayat the specified position in theInput.- Parameters:
manager-NDManagerused to create thisNDArrayindex- the index of the element to return- Returns:
- the value as
NDArrayat the specified position in theInput
-
getAsNDList
public NDList getAsNDList(NDManager manager, java.lang.String key)
Returns the value asNDListfor the first key found in theInput.- Parameters:
manager-NDManagerused to create thisNDArraykey- the key of the element to get- Returns:
- the value as
NDListfor the first key found in theInput
-
getAsNDList
public NDList getAsNDList(NDManager manager, int index)
Returns the value asNDListat the specified position in theInput.- Parameters:
manager-NDManagerused to create thisNDArrayindex- the index of the element to return- Returns:
- the value as
NDListat the specified position in theInput
-
toString
public java.lang.String toString()
*- Overrides:
toStringin classjava.lang.Object
-
-