ailia_tflite package¶
Classes¶
- class ailia_tflite.Interpreter(model_path=None, env_id: int = 0, memory_mode: int = 0, flags: int = 0, **kwargs)¶
Bases:
object
ailia TFLite Runtime inference interface (compatible with tf.lite.interpreter)ailia TFLite Runtime 推論用インターフェース(tf.lite.Interpreterと互換)- __init__(model_path=None, env_id: int = 0, memory_mode: int = 0, flags: int = 0, **kwargs)¶
- Constructorコンストラクタ
- Parameters:
model_path (str) –
Path to tflite modeltfliteモデルへのパスenv_id (int) –
Used when using NNAPI in Android ID in the execution environment実行環境のID、AndroidでNNAPIを使用する場合に使用memory_mode (int) –
ailia_tflite.AILIA_TFLITE_MEMORY_REDUCE_INTERSTAGE can be used by specifying the memory mode.ailia_tflite.AILIA_TFLITE_MEMORY_MODE_REDUCE_INTERSTAGEを指定することで省メモリモードが使用可能flags (int) –
You can change the reasoning mode by specifying ailia_tflite.AILIA_TFLITE_FLAG_*ailia_tflite.AILIA_TFLITE_FLAG_*を指定することで推論モードを変更可能
- allocate_tensors()¶
- Allocate tensor buffersTensorの割当を行う
- get_cpu_features()¶
- Get the CPU instrunction to use使用するCPU命令を取得する
- Returns:
- AILIA_TFLITE_CPU_FEATURES_XXX logical sumAILIA_TFLITE_CPU_FEATURES_XXXの論理和
- Return type:
int
- get_input_details()¶
- Get information of input tensor入力Tensorの情報を取得する
- Returns:
- Input tensor information array入力Tensorの情報の配列。
- Return type:
List[Dict[str, any]]
References
- index
- Tensor indexTensorのindex
- shape
- Tensor shape(numpy array)Tensorの形状(numpy array)
- shape_signature
- Tensor shape signature(numpy array) Unlike Shape, if the shape is undecided, -1 is stored.Tensorの形状(numpy array) shapeと異なり、形状が未定な場合は-1が格納される。
- dtype
- Tensor typeTensorの型
- name
- Tensor nameTensor名
- quantization
- Quantization information(deprecated)量子化情報(deprecated)
- quantization_parameters
- Quantization parameters量子化情報
- quantization_parameters.scales
- Array of scale (1 element when quantizing in tensor units)スケールの配列 (Tensor単位で量子化する場合は1要素)
- quantization_parameters.zero_points
- Array of zero point (1 element when quantizing in tensor units)ゼロポイントの配列 (Tensor単位で量子化する場合は1要素)
- quantization_parameters.quantized_dimension
- Axis of quantization (Specify when quantizing in axis units)量子化を行う軸 (axis単位で量子化する場合に指定)
- get_node_infos()¶
- Get node informationNodeの情報を取得する
- Returns:
- Node information arrayNodeの情報の配列
- Return type:
List[Dict[str, any]]
References
- index
- Node indexNodeのindex
- name
- Node nameNodeの名前
- operator
- Operator enum valueOperatorのenum値
- operator_name
- Operator nameOperatorの名前
- input_tensor_indices
- List of index of input tensor入力TensorのindexのList
- input_details
- List of information in input tensor入力Tensorの情報のList
- output_tensor_index
- Index of output tensor出力Tensorのindex
- output_detail
- Output tensor information出力Tensorの情報
- weight
- Weight (for Conv2D/DepthwiseConv2D/Fullyconnected)Weight (Conv2D/DepthwiseConv2D/FullyConnectedの場合)
- weight_detail
- Weight detail (for Conv2D/DepthwiseConv2D/Fullyconnected)Weightの情報 (Conv2D/DepthwiseConv2D/FullyConnectedの場合)
- bias
- Bias (for Conv2D/DepthwiseConv2D/Fullyconnected)Bias (Conv2D/DepthwiseConv2D/FullyConnectedの場合)
- bias_detail
- Bias detail(for Conv2D/DepthwiseConv2D/Fullyconnected)Biasの情報 (Conv2D/DepthwiseConv2D/FullyConnectedの場合)
- option
- Dict of option name and value (for Add/Conv2D/DepthwiseConv2D/FullyConnected/MaxPool2D/Softmax/Mean)オプション名と値のDict (Add/Conv2D/DepthwiseConv2D/FullyConnected/MaxPool2D/Softmax/Meanの場合)
- get_output_details()¶
- Get information of output tensor出力Tensorの情報を取得する
- Returns:
- Output tensor information array出力Tensorの情報の配列
- Return type:
List[Dict[str, any]]
References
- index
- Tensor indexTensorのindex
- shape
- Tensor shape(numpy array)Tensorの形状(numpy array)
- shape_signature
- Tensor shape signature(numpy array) Unlike Shape, if the shape is undecided, -1 is stored.Tensorの形状(numpy array) shapeと異なり、形状が未定な場合は-1が格納される。
- dtype
- Tensor typeTensorの型
- name
- Tensor nameTensor名
- quantization
- Quantization information(deprecated)量子化情報(deprecated)
- quantization_parameters
- Quantization parameters量子化情報
- quantization_parameters.scales
- Array of scale (1 element when quantizing in tensor units)スケールの配列 (Tensor単位で量子化する場合は1要素)
- quantization_parameters.zero_points
- Array of zero point (1 element when quantizing in tensor units)ゼロポイントの配列 (Tensor単位で量子化する場合は1要素)
- quantization_parameters.quantized_dimension
- Axis of quantization (Specify when quantizing in axis units)量子化を行う軸 (axis単位で量子化する場合に指定)
- get_summary()¶
- Get the summary informationサマリを取得する
- Returns:
- Summary informationサマリ情報
- Return type:
str
- get_tensor(tensor_index)¶
- Get the value of the specified tensor指定したTensorの値を取得する
- Parameters:
tensor_index (int) –
Tensor’s index (acquired with get_output_details)Tensorのindex(get_output_detailsで取得する)- Returns:
- Tensor valueTensorの値
- Return type:
np.ndarray
- invoke()¶
- Inference推論を実行する
- resize_tensor_input(tensor_index, shape, strict=False)¶
- Change input tensor shape入力Tensorの形状を変更する
- Parameters:
tensor_index (int) –
Index of Tensor (index returned by Get_input_details)Tensorのindex(get_input_detailsが返すindex)shape (Union[Tuple, nd.array, List]) –
New shape新しい形状strict (bool, optional) –
Strict mode. In the case of true, only unknown dimensions (parts that are -1 in Shape_Signature) can be changed. by default False厳格モード。Trueの場合不明な次元(shape_signatureで-1となっている部分)のみ変更可能です。デフォルトはFalseです。
- set_cpu_features(cpu_features)¶
- Set the CPU instruction to use使用するCPU命令を設定する
- Parameters:
cpu_features (int) –
AILIA_TFLITE_CPU_FEATURES_XXX logical sumAILIA_TFLITE_CPU_FEATURES_XXXの論理和
- set_profile_mode(profile_mode)¶
- Enable profile modeプロファイルモードを指定するIt must be executed immediately after creation of an interpreter. After setting the profile mode, you can get profile information by calling get_summary.Interpreterの作成直後に実行する必要がある。プロファイルモードを設定した後にget_summaryを呼び出すことで、プロファイル情報を取得可能。
- Parameters:
profile_mode (bool or int) –
Profile mode (enabled in true)プロファイルモード(Trueで有効)
- set_tensor(tensor_index, value)¶
- Set the value in the specified tensor指定したTensorに値をセットする
- Parameters:
tensor_index (int) –
TENSOR’s index (acquired with get_input_details)Tensorのindex(get_input_detailsで取得する)value (np.ndarray) –
The value to setセットする値