pub struct ModelInfo { /* private fields */ }Expand description
The ModelInfo is an object storing artifical neural network
model metadata describing the input and output tensors. These information’s
are required by inference elements.
GLib type: Boxed type with copy-on-clone semantics.
Implementations§
Source§impl ModelInfo
impl ModelInfo
Sourcepub fn as_ptr(&self) -> *mut GstAnalyticsModelInfo
pub fn as_ptr(&self) -> *mut GstAnalyticsModelInfo
Return the inner pointer to the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut GstAnalyticsModelInfo) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GstAnalyticsModelInfo) -> &Self
Borrows the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow_mut(
ptr: &mut *mut GstAnalyticsModelInfo,
) -> &mut Self
pub unsafe fn from_glib_ptr_borrow_mut( ptr: &mut *mut GstAnalyticsModelInfo, ) -> &mut Self
Borrows the underlying C value mutably.
Source§impl ModelInfo
impl ModelInfo
Sourcepub fn dims_order(&self, tensor_name: &str) -> TensorDimOrder
pub fn dims_order(&self, tensor_name: &str) -> TensorDimOrder
Retrieve the dimension ordering for a given tensor.
The dimension ordering specifies how multi-dimensional tensor data is laid out in memory:
- Row-major (C/NumPy style): Last dimension changes fastest in memory
- Column-major (Fortran style): First dimension changes fastest in memory
If not specified in the modelinfo, defaults to row-major.
§tensor_name
The name of the tensor
§Returns
The dimension order as TensorDimOrder
Sourcepub fn id(&self, tensor_name: &str) -> Option<GString>
pub fn id(&self, tensor_name: &str) -> Option<GString>
Get the tensor ID from the modelinfo for the specified tensor name.
The tensor ID is ideally registered in the Tensor ID Registry.
§tensor_name
The name of the tensor
§Returns
The tensor ID string, or None if not found.
The caller must free this with g_free() when done.
Sourcepub fn quark_group_id(&self) -> Quark
pub fn quark_group_id(&self) -> Quark
Get the group ID as a GQuark for efficient string comparison and storage.
Using GQuark is more efficient than string comparison when you need to compare multiple group IDs.
§Returns
The GQuark of the group ID, or 0 if not found
Sourcepub fn version(&self) -> GString
pub fn version(&self) -> GString
Retrieve the version string of the modelinfo file format.
The version is in the format “Major.Minor” and is stored in the [modelinfo] section of the modelinfo file.
§Returns
The version string (e.g., “1.0”).
The caller must free this with g_free() when done.
Defaults to “1.0” if not specified.
Sourcepub fn load(model_filename: impl AsRef<Path>) -> Option<ModelInfo>
pub fn load(model_filename: impl AsRef<Path>) -> Option<ModelInfo>
Load a modelinfo file associated with the given model file.
This function attempts to load a .modelinfo file in the following order:
{model_filename}.modelinfo{model_filename_without_extension}.modelinfo
The modelinfo file contains metadata for the model’s input and output tensors, including normalization ranges, dimension ordering, tensor IDs, etc.
The loaded modelinfo must be freed with gst_analytics_modelinfo_free()
when no longer needed.
§model_filename
Path to the model file (e.g., “model.onnx”, “model.tflite”)
§Returns
A new ModelInfo instance,
or None if the modelinfo file could not be found or loaded.
Source§impl ModelInfo
impl ModelInfo
Sourcepub fn find_tensor_name(
&self,
dir: ModelInfoTensorDirection,
index: usize,
in_tensor_name: Option<&str>,
data_type: TensorDataType,
dims: &[usize],
) -> Option<GString>
pub fn find_tensor_name( &self, dir: ModelInfoTensorDirection, index: usize, in_tensor_name: Option<&str>, data_type: TensorDataType, dims: &[usize], ) -> Option<GString>
Find the name of a tensor in the modelinfo that matches the given criteria.
The function performs the following checks in order:
- If
in_tensor_nameis provided and exists in modelinfo, validate it matches - Search by index for the specified direction and validate
- Search by dimensions and data type
§dir
The tensor direction (input or output)
§index
The tensor index within the specified direction
§in_tensor_name
An optional tensor name hint to check first
§data_type
The tensor data type to match
§dims
The dimension sizes. Use -1 for dynamic dimensions.
§Returns
The tensor name if found, or None otherwise.
The caller must free this with g_free() when done.
Sourcepub fn input_scales_offsets(
&self,
tensor_name: &str,
input_mins: &[f64],
input_maxs: &[f64],
) -> Option<(Slice<f64>, Slice<f64>)>
pub fn input_scales_offsets( &self, tensor_name: &str, input_mins: &[f64], input_maxs: &[f64], ) -> Option<(Slice<f64>, Slice<f64>)>
Calculate normalization scales and offsets to transform input data to the target range.
This function calculates transformation parameters to convert from the actual input data range
[input_min, input_max] to the target range expected by the model [target_min, target_max]:
normalized_value[i] = input[i] * output_scale[i] + output_offset[i]
The target ranges are read from the modelinfo ranges field: Semicolon-separated list of
comma-separated pairs (min,max) for per-channel target ranges
(e.g., “0.0,255.0;-1.0,1.0;0.0,1.0” for RGB channels with different target ranges).
Common input ranges:
- [0.0, 255.0]: 8-bit unsigned (uint8)
- [-128.0, 127.0]: 8-bit signed (int8)
- [0.0, 65535.0]: 16-bit unsigned (uint16)
- [-32768.0, 32767.0]: 16-bit signed (int16)
- [0.0, 1.0]: Normalized float
- [-1.0, 1.0]: Normalized signed float
The number of input ranges (num_input_ranges) must equal the number of target ranges
in the modelinfo. The function will return FALSE if they don’t match.
The caller must free output_scales and output_offsets with g_free() when done.
§tensor_name
The name of the tensor
§input_mins
The minimum values of the actual input data for each channel
§input_maxs
The maximum values of the actual input data for each channel
§Returns
true on success, false on error, if ranges field is not found, or if num_input_ranges
doesn’t match the number of target ranges in the modelinfo
§output_scales
The scale values for normalization
§output_offsets
The offset values for normalization
Sourcepub fn target_ranges(
&self,
tensor_name: &str,
) -> Option<(Slice<f64>, Slice<f64>)>
pub fn target_ranges( &self, tensor_name: &str, ) -> Option<(Slice<f64>, Slice<f64>)>
Retrieve all target ranges (min/max pairs) expected by the model for a given tensor.
This function retrieves all target ranges from the ranges field in the modelinfo.
Each range represents the expected input range for a channel or dimension that the
model requires.
The function reads from the ranges field: Semicolon-separated list of
comma-separated pairs (min,max) for per-channel target ranges
(e.g., “0.0,1.0;-1.0,1.0;0.0,1.0” for RGB channels with different normalization targets).
The caller must free mins and maxs with g_free() when done.
§tensor_name
The name of the tensor
§Returns
true if range information was found and valid, false otherwise
§mins
The minimum values for each target range
§maxs
The maximum values for each target range
Trait Implementations§
Source§impl HasParamSpec for ModelInfo
impl HasParamSpec for ModelInfo
Source§impl Ord for ModelInfo
impl Ord for ModelInfo
Source§impl PartialOrd for ModelInfo
impl PartialOrd for ModelInfo
Source§impl StaticType for ModelInfo
impl StaticType for ModelInfo
Source§fn static_type() -> Type
fn static_type() -> Type
Self.impl Eq for ModelInfo
impl Send for ModelInfo
impl StructuralPartialEq for ModelInfo
impl Sync for ModelInfo
Auto Trait Implementations§
impl Freeze for ModelInfo
impl RefUnwindSafe for ModelInfo
impl Unpin for ModelInfo
impl UnwindSafe for ModelInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>
Source§impl<T> IntoClosureReturnValue for T
impl<T> IntoClosureReturnValue for T
fn into_closure_return_value(self) -> Option<Value>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PropertyGet for Twhere
T: HasParamSpec,
impl<T> PropertyGet for Twhere
T: HasParamSpec,
Source§impl<T> StaticTypeExt for Twhere
T: StaticType,
impl<T> StaticTypeExt for Twhere
T: StaticType,
Source§fn ensure_type()
fn ensure_type()
Source§impl<T> ToSendValue for T
impl<T> ToSendValue for T
Source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue clone of self.