ailia  1.5.0.0
Public Member Functions | Protected Member Functions | List of all members
ailia.AiliaFeatureExtractorModel Class Reference
Inheritance diagram for ailia.AiliaFeatureExtractorModel:
Inheritance graph
[legend]
Collaboration diagram for ailia.AiliaFeatureExtractorModel:
Collaboration graph
[legend]

Public Member Functions

bool Settings (uint set_format, uint set_channel, uint set_range, uint set_distance_type, string set_layer_name)
 Model setting. More...
 
override bool OpenFile (string prototxt, string model_path)
 Create a network object from a model file. More...
 
override bool OpenEx (Ailia.ailiaFileCallback callback, IntPtr arg1, IntPtr arg2)
 Creates a network object from a file callback. More...
 
override bool OpenMem (byte[] prototxt_buf, byte[] model_buf)
 Creates network objects from memory. More...
 
float[] ComputeFromImage (Color32[] image, int image_width, int image_height)
 Acquire features from images. More...
 
float[] ComputeFromImageB2T (Color32[] image, int image_width, int image_height)
 Obtain features from the upside-down image. More...
 
float Match (float[] feature1, float[] feature2)
 Calculates the distance between features. More...
 
override void Close ()
 Destroy feature extraction quobjects. More...
 
override void Dispose ()
 Release resources. More...
 
- Public Member Functions inherited from ailia.AiliaModel
bool Environment (int type)
 Selects the specified type of calculation environment. More...
 
string EnvironmentName ()
 Displays the name of the selected environment. More...
 
int GetEnvironmentCount ()
 Get the number of available computing environments (CPU, GPU). More...
 
Ailia.AILIAEnvironment GetEnvironment (int idx)
 Obtains the computing environment for the specified index. More...
 
bool SelectEnvironment (int idx)
 Select the calculation environment. More...
 
Ailia.AILIAEnvironment GetSelectedEnvironment ()
 Retrieves the selected computing environment. More...
 
void SetMemoryMode (uint set_memory_mode)
 Sets the memory mode. More...
 
void DisableLayerFusion ()
 Disables speedup due to layer fusion. More...
 
bool Predict (float[] output_data, float[] input_data)
 Perform inference and obtain inference results. More...
 
Ailia.AILIAShape GetInputShape ()
 
uint[] GetInputShapeND ()
 Obtains the shape of the input data at the time of inference. More...
 
bool SetInputShape (Ailia.AILIAShape shape)
 Sets the shape of the input data during inference. More...
 
bool SetInputShapeND (uint[] shape, int dim)
 Change the shape of the input data during inference. More...
 
Ailia.AILIAShape GetOutputShape ()
 Obtains the shape of the output data during inference. More...
 
uint[] GetOutputShapeND ()
 Obtains the shape of the output data during inference. More...
 
Ailia.AILIAShape GetBlobShape (string layer_name)
 Obtains the shape (layer format) of the internal data (Blob) at the time of inference. (Obsolete) More...
 
int FindBlobIndexByName (string name)
 Look up and retrieve the index of the internal data (Blob) at the time of inference by name. More...
 
Ailia.AILIAShape GetBlobShape (uint idx)
 Obtains the shape (layer format) of the internal data (Blob) at the time of inference. More...
 
Ailia.AILIAShape GetBlobShape (int idx)
 
bool GetBlobData (float[] output_data, uint idx)
 Obtains internal data (Blob) at the time of inference. More...
 
bool GetBlobData (float[] output_data, int idx)
 
bool SetInputBlobData (float[] input_data, uint idx)
 Set input data to the specified Blob. More...
 
bool SetInputBlobData (float[] input_data, int idx)
 
bool SetInputBlobShape (Ailia.AILIAShape shape, uint idx)
 Sets the format of the specified input data (Blob). (4 dimensions or less) More...
 
bool SetInputBlobShape (Ailia.AILIAShape shape, int idx)
 
bool SetInputBlobShapeND (uint[] shape, uint dim, uint idx)
 Sets the format of the input data (Blob). (5D or more) More...
 
bool SetInputBlobShapeND (uint[] shape, int dim, int idx)
 
uint[] GetInputBlobList ()
 Obtains a list of the indices of the input data (Blob). More...
 
uint[] GetOutputBlobList ()
 Obtains a list of indices of the output data (Blob). More...
 
bool CopyBlobData (uint dst_blob_idx, uint src_blob_idx, AiliaModel src_model=null)
 Perform copies between blobs that specified. More...
 
bool Update ()
 Inference is performed with pre-populated data. More...
 
string GetStatusString (int status)
 Returns a string corresponding to the status code. More...
 
string GetErrorDetail ()
 Returns error details. More...
 
bool SetProfileMode (uint profile_mode)
 Enable profile mode. More...
 
string GetSummary ()
 Obtain network information and profile results. More...
 

Protected Member Functions

override void Dispose (bool disposing)
 

Additional Inherited Members

- Protected Attributes inherited from ailia.AiliaModel
IntPtr ailia = IntPtr.Zero
 
bool logging = true
 
- Properties inherited from ailia.AiliaModel
int Status [get, protected set]
 Status code @detail Get the library status code. More...
 

Member Function Documentation

◆ Close()

override void ailia.AiliaFeatureExtractorModel.Close ( )
inlinevirtual

Destroy feature extraction quobjects.

Returns
Return nothing.


Destroys the feature extractor object.

Reimplemented from ailia.AiliaModel.

356  {
357  if(ailia_feature_extractor!=IntPtr.Zero){
358  AiliaFeatureExtractor.ailiaDestroyFeatureExtractor(ailia_feature_extractor);
359  ailia_feature_extractor=IntPtr.Zero;
360  }
361  base.Close();
362  }

◆ ComputeFromImage()

float [] ailia.AiliaFeatureExtractorModel.ComputeFromImage ( Color32[]  image,
int  image_width,
int  image_height 
)
inline

Acquire features from images.

Parameters
imageImage to be extraction
image_widthImage width
image_heightImage height
Returns
Feature vector

Calculate feature vectors from images.

199  {
200  return ComputeFromImageWithFormat(image,image_width,image_height,AiliaFormat.AILIA_IMAGE_FORMAT_RGBA);
201  }

◆ ComputeFromImageB2T()

float [] ailia.AiliaFeatureExtractorModel.ComputeFromImageB2T ( Color32[]  image,
int  image_width,
int  image_height 
)
inline

Obtain features from the upside-down image.

Parameters
imageImage to be extraction
image_widthImage width
image_heightImage height
Returns
Feature vector

Calculate feature vectors from images.

225  {
226  return ComputeFromImageWithFormat(image,image_width,image_height,AiliaFormat.AILIA_IMAGE_FORMAT_RGBA_B2T);
227  }

◆ Dispose() [1/2]

override void ailia.AiliaFeatureExtractorModel.Dispose ( )
inlinevirtual

Release resources.

Reimplemented from ailia.AiliaModel.

372  {
373  Dispose(true);
374  }
override void Dispose()
Release resources.
Definition: AiliaFeatureExtractorModel.cs:371

◆ Dispose() [2/2]

override void ailia.AiliaFeatureExtractorModel.Dispose ( bool  disposing)
inlineprotectedvirtual

Reimplemented from ailia.AiliaModel.

377  {
378  if (disposing){
379  // release managed resource
380  }
381  Close(); // release unmanaged resource
382  base.Dispose(disposing);
383  }
override void Close()
Destroy feature extraction quobjects.
Definition: AiliaFeatureExtractorModel.cs:356

◆ Match()

float ailia.AiliaFeatureExtractorModel.Match ( float[]  feature1,
float[]  feature2 
)
inline

Calculates the distance between features.

Parameters
feature1Feature 1
feature2Feature 2
Returns
Calculated Distance

Calculate the distance between feature 1 and feature 2.

311  {
312  if(feature1==null || feature2==null){
313  if(logging){
314  Debug.Log("input feature is empty");
315  }
316  return float.NaN;
317  }
318 
319  float distance=0;
320 
321  GCHandle feature1_handle = GCHandle.Alloc(feature1, GCHandleType.Pinned);
322  IntPtr feature1_buf_ptr = feature1_handle.AddrOfPinnedObject();
323 
324  GCHandle feature2_handle = GCHandle.Alloc(feature2, GCHandleType.Pinned);
325  IntPtr feature2_buf_ptr = feature2_handle.AddrOfPinnedObject();
326 
327  int status=AiliaFeatureExtractor.ailiaFeatureExtractorMatch(ailia_feature_extractor,ref distance, distace_type, feature1_buf_ptr, (uint)feature1.Length*4, feature2_buf_ptr, (uint)feature2.Length*4);
328  if(status!=Ailia.AILIA_STATUS_SUCCESS){
329  if(logging){
330  Debug.Log("ailiaFeatureExtractorMatch failed "+status);
331  }
332  return float.NaN;
333  }
334 
335  feature1_handle.Free();
336  feature2_handle.Free();
337  return distance;
338  }
bool logging
Definition: AiliaModel.cs:33

◆ OpenEx()

override bool ailia.AiliaFeatureExtractorModel.OpenEx ( Ailia.ailiaFileCallback  callback,
IntPtr  arg1,
IntPtr  arg2 
)
inlinevirtual

Creates a network object from a file callback.

Parameters
callbackUser-defined file access callback function structure
alg1Argument pointer notified to AILIA_USER_API_FOPEN
alg2Argument pointer notified to AILIA_USER_API_FOPEN
Returns
If this function is successful, it returns true , or false otherwise.


Creates a network object from a file callback.

Reimplemented from ailia.AiliaModel.

121  {
122  Close();
123  bool status=base.OpenEx(callback,arg1,arg2);
124  if(status==false){
125  if(logging){
126  Debug.Log("ailiaModelOpenEx failed");
127  }
128  return false;
129  }
130  return OpenFeatureExtractor();
131  }

◆ OpenFile()

override bool ailia.AiliaFeatureExtractorModel.OpenFile ( string  prototxt,
string  model_path 
)
inlinevirtual

Create a network object from a model file.

Parameters
prototxtPath name of the prototxt file (MBSC or UTF16)
model_pathPathname of the protobuf/onnx file (MBSC or UTF16)
Returns
If this function is successful, it returns true , or false otherwise.


Create a network object from a model file.

Reimplemented from ailia.AiliaModel.

87  {
88  Close();
89  bool status=base.OpenFile(prototxt,model_path);
90  if(status==false){
91  if(logging){
92  Debug.Log("ailiaModelOpenFile failed");
93  }
94  return false;
95  }
96  return OpenFeatureExtractor();
97  }

◆ OpenMem()

override bool ailia.AiliaFeatureExtractorModel.OpenMem ( byte[]  prototxt_buf,
byte[]  model_buf 
)
inlinevirtual

Creates network objects from memory.

Parameters
prototxtPointer to data in prototxt file
model_pathPointer to data in protobuf/onnx file
Returns
If this function is successful, it returns true , or false otherwise.


Creates network objects from memory.

Reimplemented from ailia.AiliaModel.

153  {
154  Close();
155  bool status=base.OpenMem(prototxt_buf,model_buf);
156  if(status==false){
157  if(logging){
158  Debug.Log("ailiaModelOpenMem failed");
159  }
160  return false;
161  }
162  return OpenFeatureExtractor();
163  }

◆ Settings()

bool ailia.AiliaFeatureExtractorModel.Settings ( uint  set_format,
uint  set_channel,
uint  set_range,
uint  set_distance_type,
string  set_layer_name 
)
inline

Model setting.

Parameters
set_formatThe network image format (AILIA_NETWORK_IMAGE_FORMAT_*)
set_channelThe network image channel (AILIA_NETWORK_IMAGE_CHANNEL_*)
set_rangeThe network image range (AILIA_NETWORK_IMAGE_RANGE_*)
set_distance_typeThe type of the distance in feature space
set_layer_nameThe name of the layer corresponding to the feature (fc1 for VGG16 and NULL for the last layer)
Returns
Returns true on success.

Pre-process images of the network and set up distance calculations.

58  {
59  format=set_format;
60  channel=set_channel;
61  range=set_range;
62  distace_type=set_distance_type;
63  layer_name=set_layer_name;
64  return true;
65  }

The documentation for this class was generated from the following file: