public class AiliaModel
extends java.lang.Object
implements java.lang.AutoCloseable
Constructor and Description |
---|
AiliaModel(int envId,
int numThread,
byte[] streamData,
byte[] weightData)
Constructor
|
AiliaModel(int envId,
int numThread,
java.util.EnumSet<AiliaMemoryMode> memoryMode,
boolean layerFusion,
byte[] streamData,
byte[] weightData)
Constructor
|
AiliaModel(int envId,
int numThread,
java.util.EnumSet<AiliaMemoryMode> memoryMode,
boolean layerFusion,
java.lang.String streamPath,
java.lang.String weightPath)
Constructor
|
AiliaModel(int envId,
int numThread,
java.util.EnumSet<AiliaMemoryMode> memoryMode,
byte[] streamData,
byte[] weightData)
Constructor
|
AiliaModel(int envId,
int numThread,
java.util.EnumSet<AiliaMemoryMode> memoryMode,
java.lang.String streamPath,
java.lang.String weightPath)
Constructor
|
AiliaModel(int envId,
int numThread,
java.lang.String streamPath,
java.lang.String weightPath)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
close()
It destroys the network instance.
|
void |
copyBlob(int dstBlobIndex,
int srcBlobIndex,
AiliaModel srcNet)
Copy blobs between specified models.
|
AiliaClassifierModel |
createClassifier(AiliaNetworkImageFormat format,
AiliaNetworkImageChannel channel,
AiliaNetworkImageRange range)
Creates a classifier object.
|
AiliaDetectorModel |
createDetector(AiliaNetworkImageFormat format,
AiliaNetworkImageChannel channel,
AiliaNetworkImageRange range,
AiliaDetectorAlgorithm algorithm,
int categoryCount,
java.util.EnumSet<AiliaDetectorFlags> flags)
Creates a detector object.
|
AiliaDetectorModel |
createDetector(AiliaNetworkImageFormat format,
AiliaNetworkImageChannel channel,
AiliaNetworkImageRange range,
int algorithm,
int categoryCount,
int flags)
Deprecated.
Please use
#createDetector(AiliaNetworkImageFormat, AiliaNetworkImageChannel, AiliaNetworkImageRange, AiliaDetectorAlgorithm, int, EnumSet |
AiliaFeatureExtractorModel |
createFeatureExtractor(AiliaNetworkImageFormat format,
AiliaNetworkImageChannel channel,
AiliaNetworkImageRange range,
java.lang.String layerName)
Creates a feature extractor object.
|
AiliaPoseEstimatorModel |
createPoseEstimator(AiliaPoseEstimatorAlgorithm algorithm)
Creates a pose estimator object.
|
AiliaPoseEstimatorModel |
createPoseEstimator(int algorithm)
Deprecated.
|
void |
getBlobData(float[] dest,
int destSize,
int idx)
Get the output blob data.
|
int |
getBlobIndexByInputIndex(int inputBlobIndex)
Get the blob index of the input data.
|
int |
getBlobIndexByOutputIndex(int outputBlobIndex)
Get the blob index of the output data blob.
|
AiliaShape |
getBlobShape(int blobIndex)
Gets the shape of the internal data (blob) during inference.
|
int[] |
getBlobShapeND(int blobIndex)
Gets the shape of the internal data (blob) during inference.
|
static java.util.List<AiliaEnvironment> |
getEnvironments()
Gets the available computational environments.
|
long |
getHandle()
Gets A network instance handle
|
int |
getInputBlobCount()
Get the number of input data blobs.
|
AiliaShape |
getInputShape()
Gets the shape of the input data during inference.
|
int[] |
getInputShapeND()
Gets the shape of the input data during inference.
|
static java.util.EnumSet<AiliaMemoryMode> |
getMemoryMode(boolean reduceConstant,
boolean ignoreInputWithInitializer,
boolean reduceInterstage,
boolean reuseInterstage)
Create mode flags for
Ailia.SetMemoryMode(long, int) / Constructor. |
int |
getOutputBlobCount()
Get the number of output data blobs.
|
AiliaShape |
getOutputShape()
Gets the shape of the output data during inference.
|
int[] |
getOutputShapeND()
Gets the shape of the output data during inference.
|
java.lang.String |
getSummary()
Shows the name and shape of each blob.
|
void |
predict(float[] dest,
int destSize,
float[] src,
int srcSize)
Performs the inferences and provides the inference result.
|
void |
Predict(float[] dest,
int destSize,
float[] src,
int srcSize)
Deprecated.
Psease use
predict(float[], int, float[], int) |
void |
setInputBlobData(float[] src,
int srcSize,
int idx)
Set the input blob data.
|
void |
setInputBlobShape(AiliaShape shape,
int blobIndex,
int version)
Change the shape of the blob given by its index
|
void |
setInputBlobShapeND(int[] shape,
int blobIndex)
Change the shape of the blob given by its index
|
void |
setInputShape(AiliaShape shape)
Changes the shape of the input data during inference.
|
void |
setInputShapeND(int[] shape)
Changes the shape of the input data during inference.
|
void |
setProfileMode(AiliaProfileMode profileMode)
Set the profile mode.
|
void |
update()
Performs the inferences
|
public AiliaModel(int envId, int numThread, byte[] streamData, byte[] weightData) throws AiliaException
envId
- The ID of the inference backend used for computation (obtained by getEnvironments()
)numThread
- The upper limit on the number of threadsstreamData
- An array of the data in the protobuf fileweightData
- An array of the data in the protobuf/onnx fileAiliaException
- ExceptionAilia.Create(int, int)
,
Ailia.OpenStreamMem(long, byte[], int)
,
Ailia.OpenWeightMem(long, byte[], int)
public AiliaModel(int envId, int numThread, java.lang.String streamPath, java.lang.String weightPath) throws AiliaException
envId
- The ID of the inference backend used for computation (obtained by getEnvironments()
)numThread
- The upper limit on the number of threadsstreamPath
- The path name to the prototxt fileweightPath
- The path name to the protobuf/onnx fileAiliaException
- ExceptionAilia.Create(int, int)
,
Ailia.OpenStreamFile(long, String)
,
Ailia.OpenWeightFile(long, String)
public AiliaModel(int envId, int numThread, java.util.EnumSet<AiliaMemoryMode> memoryMode, byte[] streamData, byte[] weightData) throws AiliaException
envId
- The ID of the inference backend used for computation (obtained by getEnvironments()
)numThread
- The upper limit on the number of threadsmemoryMode
- Memory mode (Calucurate by getMemoryMode(boolean, boolean, boolean, boolean)
)streamData
- An array of the data in the protobuf fileweightData
- An array of the data in the protobuf/onnx fileAiliaException
- ExceptionAilia.Create(int, int)
,
Ailia.OpenStreamMem(long, byte[], int)
,
Ailia.OpenWeightMem(long, byte[], int)
public AiliaModel(int envId, int numThread, java.util.EnumSet<AiliaMemoryMode> memoryMode, java.lang.String streamPath, java.lang.String weightPath) throws AiliaException
envId
- The ID of the inference backend used for computation (obtained by getEnvironments()
)numThread
- The upper limit on the number of threadsmemoryMode
- Memory mode (Calucurate by getMemoryMode(boolean, boolean, boolean, boolean)
)streamPath
- The path name to the prototxt fileweightPath
- The path name to the protobuf/onnx fileAiliaException
- ExceptionAilia.Create(int, int)
,
Ailia.OpenStreamFile(long, String)
,
Ailia.OpenWeightFile(long, String)
public AiliaModel(int envId, int numThread, java.util.EnumSet<AiliaMemoryMode> memoryMode, boolean layerFusion, byte[] streamData, byte[] weightData) throws AiliaException
envId
- The ID of the inference backend used for computation (obtained by getEnvironments()
)numThread
- The upper limit on the number of threadsmemoryMode
- Memory mode (Calucurate by getMemoryMode(boolean, boolean, boolean, boolean)
)layerFusion
- Enable or disable layer fusion optimizationstreamData
- An array of the data in the protobuf fileweightData
- An array of the data in the protobuf/onnx fileAiliaException
Ailia#Create(int, int)}
,
Ailia#OpenStreamMem(long, byte[], int)}
,
Ailia#OpenWeightMem(long, byte[], int)}
public AiliaModel(int envId, int numThread, java.util.EnumSet<AiliaMemoryMode> memoryMode, boolean layerFusion, java.lang.String streamPath, java.lang.String weightPath) throws AiliaException
envId
- The ID of the inference backend used for computation (obtained by getEnvironments()
)numThread
- The upper limit on the number of threadsmemoryMode
- Memory mode (Calucurate by getMemoryMode(boolean, boolean, boolean, boolean)
)layerFusion
- Enable or disable layer fusion optimizationstreamPath
- The path name to the prototxt fileweightPath
- The path name to the protobuf/onnx fileAiliaException
Ailia#Create(int, int)}
,
Ailia#OpenStreamFile(long, String)}
,
Ailia#OpenWeightFile(long, String)}
public static java.util.List<AiliaEnvironment> getEnvironments() throws AiliaException
AiliaException
- Exceptionpublic static java.util.EnumSet<AiliaMemoryMode> getMemoryMode(boolean reduceConstant, boolean ignoreInputWithInitializer, boolean reduceInterstage, boolean reuseInterstage) throws AiliaException
Ailia.SetMemoryMode(long, int)
/ Constructor.reduceConstant
- Releases the intermediate buffer that is a constant such as weightignoreInputWithInitializer
- Disable the input specified initializer and release the intermediate buffer that becomes a constant such as weight.reduceInterstage
- Release intermediate buffer during inferencereuseInterstage
- Infer by sharing the intermediate buffer.AiliaMemoryMode
AiliaException
- ExceptionAilia.SetMemoryMode(long, int)
public AiliaClassifierModel createClassifier(AiliaNetworkImageFormat format, AiliaNetworkImageChannel channel, AiliaNetworkImageRange range) throws AiliaException
format
- The network image format (AiliaNetworkImageFormat
)channel
- The network image channel (AiliaNetworkImageChannel
)range
- The network image range (AiliaNetworkImageRange
)AiliaException
- ExceptionAiliaClassifier.Create(long, int, int, int)
public AiliaDetectorModel createDetector(AiliaNetworkImageFormat format, AiliaNetworkImageChannel channel, AiliaNetworkImageRange range, AiliaDetectorAlgorithm algorithm, int categoryCount, java.util.EnumSet<AiliaDetectorFlags> flags) throws AiliaException
format
- The network image format (AiliaNetworkImageFormat
)channel
- The network image channel (AiliaNetworkImageChannel
)range
- The network image range (AiliaNetworkImageRange
)algorithm
- The network algorithm AiliaDetectorAlgorithm
categoryCount
- The number of detection categories (specify 20 for VOC or 80 for COCO, etc.)flags
- Additional flags AiliaDetectorFlags
AiliaException
- ExceptionAiliaDetector.Create(long, int, int, int, int, int, int)
@Deprecated public AiliaDetectorModel createDetector(AiliaNetworkImageFormat format, AiliaNetworkImageChannel channel, AiliaNetworkImageRange range, int algorithm, int categoryCount, int flags) throws AiliaException
#createDetector(AiliaNetworkImageFormat, AiliaNetworkImageChannel, AiliaNetworkImageRange, AiliaDetectorAlgorithm, int, EnumSet)
AiliaException
public AiliaFeatureExtractorModel createFeatureExtractor(AiliaNetworkImageFormat format, AiliaNetworkImageChannel channel, AiliaNetworkImageRange range, java.lang.String layerName) throws AiliaException
format
- The network image format (AiliaNetworkImageFormat
)channel
- The network image channel (AiliaNetworkImageChannel
)range
- The network image range (AiliaNetworkImageRange
)layerName
- The name of the layer corresponding to the feature (fc1 for VGG16 and NULL for the last layer)AiliaException
- ExceptionAiliaFeatureExtractor.Create(long, int, int, int, String)
public AiliaPoseEstimatorModel createPoseEstimator(AiliaPoseEstimatorAlgorithm algorithm) throws AiliaException
algorithm
- AiliaPoseEstimatorAlgorithm
AiliaException
- ExceptionAiliaPoseEstimator.Create(long, int)
@Deprecated public AiliaPoseEstimatorModel createPoseEstimator(int algorithm) throws AiliaException
createPoseEstimator(AiliaPoseEstimatorAlgorithm)
AiliaException
public void predict(float[] dest, int destSize, float[] src, int srcSize) throws AiliaException
dest
- The result is stored in the inference result destination buffer as float data in the order of X, Y, Z, and W. The buffer has the same size as the network file outputSize.destSize
- The size of the dest (in byte)src
- The input is stored as float data in the order of the inference data X, Y, Z, and W. The input has the same size as the network file inputSize.srcSize
- The size of the src (in byte)AiliaException
- ExceptionAilia.Predict(long, float[], int, float[], int)
@Deprecated public void Predict(float[] dest, int destSize, float[] src, int srcSize) throws AiliaException
predict(float[], int, float[], int)
AiliaException
public void setInputShape(AiliaShape shape) throws AiliaException
shape
- Shape information for the input dataAiliaException
- ExceptionAilia.SetInputShape(long, AiliaShape, int)
public void setInputShapeND(int[] shape) throws AiliaException
shape
- An array of shapeAiliaException
- ExceptionAilia.SetInputShapeND(long, int[], int)
public AiliaShape getInputShape() throws AiliaException
AiliaException
- ExceptionAilia.GetInputShape(long, int)
public int[] getInputShapeND() throws AiliaException
AiliaException
- ExceptionAilia.GetInputDim(long)
,
Ailia.GetInputShapeND(long, int[], int)
public void setInputBlobShape(AiliaShape shape, int blobIndex, int version) throws AiliaException
shape
- New shape of the blobblobIndex
- Index referencing the blob to reshapeversion
- Shape version(AiliaShape.version
)AiliaException
- ExceptionAilia.SetInputBlobShape(long, AiliaShape, int, int)
public void setInputBlobShapeND(int[] shape, int blobIndex) throws AiliaException
shape
- The array of the new shape.blobIndex
- Index referencing the blob to reshapeAiliaException
- ExceptionAilia.SetInputBlobShapeND(long, int[], int, int)
public AiliaShape getBlobShape(int blobIndex) throws AiliaException
blobIndex
- Index referencing the blob to reshapeAiliaException
- ExceptionAilia.GetBlobShape(long, int, int)
public int[] getBlobShapeND(int blobIndex) throws AiliaException
blobIndex
- Index referencing the blob to reshapeAiliaException
- ExceptionAilia.GetBlobShapeND(long, int[], int, int)
public AiliaShape getOutputShape() throws AiliaException
AiliaException
- ExceptionAilia.GetOutputShape(long, int)
public int[] getOutputShapeND() throws AiliaException
AiliaException
- ExceptionAilia.GetOutputShapeND(long, int[], int)
public int getInputBlobCount() throws AiliaException
AiliaException
- ExceptionAilia.GetInputBlobCount(long)
public int getBlobIndexByInputIndex(int inputBlobIndex) throws AiliaException
inputBlobIndex
- Index among the input blobs (between 0 and getInputBlobCount()
-1)AiliaException
- ExceptionAilia.GetBlobIndexByInputIndex(long, int)
public int getOutputBlobCount() throws AiliaException
AiliaException
- ExceptionAilia.GetOutputBlobCount(long)
public int getBlobIndexByOutputIndex(int outputBlobIndex) throws AiliaException
outputBlobIndex
- Index among output blobs (between 0 and getOutputBlobCount()
-1)AiliaException
- ExceptionAilia.GetBlobIndexByOutputIndex(long, int)
public void close()
close
in interface java.lang.AutoCloseable
Ailia.Destroy(long)
public long getHandle()
public void copyBlob(int dstBlobIndex, int srcBlobIndex, AiliaModel srcNet) throws AiliaException
dstBlobIndex
- The index of destination blobsrcBlobIndex
- The index of source blobsrcNet
- The AiliaModel object that contains source blob. If specify null, then use this object as srcNet.AiliaException
public void update() throws AiliaException
AiliaException
- Exceptionpublic void setInputBlobData(float[] src, int srcSize, int idx) throws AiliaException
src
- The input is stored as float data in the order of the inference data X, Y, Z, and W. The input has the same size as the network file inputSize.srcSize
- The size of the src (in byte)idx
- The blob idxAiliaException
- Exceptionpublic void getBlobData(float[] dest, int destSize, int idx) throws AiliaException
dest
- The result is stored in the inference result destination buffer as float data in the order of X, Y, Z, and W. The buffer has the same size as the network file outputSize.destSize
- The size of the dest (in byte)idx
- The blob idxAiliaException
- Exceptionpublic void setProfileMode(AiliaProfileMode profileMode) throws AiliaException
Change the profile mode.
If a value other than AiliaProfileMode.PROFILE_DISABLE
is specified,
the profile data is added to Summary
profileMode
- Profile mode (Default :AiliaProfileMode.PROFILE_DISABLE
)AiliaException
- Exceptionpublic java.lang.String getSummary() throws AiliaException
AiliaException
- Exception