Package ai.djl.modality
Class Input
- java.lang.Object
-
- ai.djl.modality.Input
-
- Direct Known Subclasses:
Output
public class Input extends java.lang.Object
A class stores the generic input data for inference.
-
-
Constructor Summary
Constructors Constructor Description Input()
Constructs a newInput
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(byte[] data)
Appends an item at the end of the input.void
add(int index, java.lang.String key, BytesSupplier data)
Inserts the specified element at the specified position in the input.void
add(BytesSupplier data)
Appends an item at the end of the input.void
add(java.lang.String data)
Appends an item at the end of the input.void
add(java.lang.String key, byte[] data)
Adds a key/value pair to the input content.void
add(java.lang.String key, BytesSupplier data)
Adds a key/value pair to the input content.void
add(java.lang.String key, java.lang.String data)
Adds a key/value pair to the input content.void
addProperty(java.lang.String key, java.lang.String value)
Adds a property to the input.BytesSupplier
get(int index)
Returns the element at the specified position in theInput
.BytesSupplier
get(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
.NDArray
getAsNDArray(NDManager manager, int index)
Returns the value asNDArray
at the specified position in theInput
.NDArray
getAsNDArray(NDManager manager, java.lang.String key)
Returns the value asNDArray
for the first key found in theInput
.NDList
getAsNDList(NDManager manager, int index)
Returns the value asNDList
at the specified position in theInput
.NDList
getAsNDList(NDManager manager, java.lang.String key)
Returns the value asNDList
for the first key found in theInput
.java.lang.String
getAsString(int index)
Returns the value asbyte[]
at the specified position in theInput
.java.lang.String
getAsString(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.BytesSupplier
getData()
Returns the default data item.NDList
getDataAsNDList(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.String
getProperty(java.lang.String key, java.lang.String defaultValue)
Returns the value to which the specified key is mapped.void
setContent(ai.djl.util.PairList<java.lang.String,BytesSupplier> content)
Sets the content of the input.void
setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
Sets the properties of the input.java.lang.String
toString()
*
-
-
-
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
Input
may 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
-NDManager
used 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 asNDArray
for the first key found in theInput
.- Parameters:
manager
-NDManager
used to create thisNDArray
key
- the key of the element to get- Returns:
- the value as
NDArray
for the first key found in theInput
-
getAsNDArray
public NDArray getAsNDArray(NDManager manager, int index)
Returns the value asNDArray
at the specified position in theInput
.- Parameters:
manager
-NDManager
used to create thisNDArray
index
- the index of the element to return- Returns:
- the value as
NDArray
at the specified position in theInput
-
getAsNDList
public NDList getAsNDList(NDManager manager, java.lang.String key)
Returns the value asNDList
for the first key found in theInput
.- Parameters:
manager
-NDManager
used to create thisNDArray
key
- the key of the element to get- Returns:
- the value as
NDList
for the first key found in theInput
-
getAsNDList
public NDList getAsNDList(NDManager manager, int index)
Returns the value asNDList
at the specified position in theInput
.- Parameters:
manager
-NDManager
used to create thisNDArray
index
- the index of the element to return- Returns:
- the value as
NDList
at the specified position in theInput
-
toString
public java.lang.String toString()
*- Overrides:
toString
in classjava.lang.Object
-
-