此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 类
  • CalibrationPreprocessing
  • 函数
  • apply_calibration_preprocessing
  • channels_last_4d_layout
  • channels_last_image_layout
  • input_preprocessing_required
  • is_user_calibration_tensor
  • normalization_required
  • read_user_calibration_tensor
  • reorder_layout
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

preprocessing

最后更新
Python API: modelconverter.utils.preprocessing外部化输入预处理的校准端表示。将预处理移动到 NN Archive 会将其从转换配置中清除,但校准仍然需要它:量化器会看到源模型的输入,而不是携带预处理节点的模型的输入。

类

CalibrationPreprocessing

仅校准准备所需的不可变预处理。

方法

requires_input_preprocessing
Python
1def requires_input_preprocessing(*, reverse_only: bool = False) -> bool:
此快照是否包含非同一性预处理。

属性

data_type
encoding_from
encoding_mismatch
源模型及其预处理输入是否不同。
encoding_to
is_image
mean_values
normalization_required
均值减法或尺度除法是否为非同一性。
scale_values

函数

apply_calibration_preprocessing

Python
1def apply_calibration_preprocessing(array: np.ndarray, preprocessing: CalibrationPreprocessing, *, layout: str) -> np.ndarray:
将外部化颜色转换和归一化应用于数组。layout 描述了数组在此时的存在方式。它可能会省略单例批次轴,即使配置的模型布局有一个,这是解码图像通常到达的方式。

channels_last_4d_layout

Python
1def channels_last_4d_layout(layout: str) -> str:
在四维布局中将唯一的通道轴移到最后。

channels_last_image_layout

Python
1def channels_last_image_layout(layout: str) -> str:
返回图像布局的 NHWC/HWC 对应项。不描述图像的布局将保持不变。

input_preprocessing_required

Python
1def input_preprocessing_required(*, encoding_from: Encoding, encoding_to: Encoding, mean_values: Sequence[float] | None, scale_values: Sequence[float] | None, reverse_only: bool = False) -> bool:
输入的颜色转换或归一化是否为非同一性。

is_user_calibration_tensor

Python
1def is_user_calibration_tensor(path: Path, calib: ImageCalibrationConfig) -> bool:
张量文件是否使用后端就绪的校准约定。

normalization_required

Python
1def normalization_required(mean_values: Sequence[float] | None, scale_values: Sequence[float] | None) -> bool:
均值减法或尺度除法是否为非同一性。

read_user_calibration_tensor

Python
1def read_user_calibration_tensor(path: Path, *, raw_shape: list[int] | tuple[int, ...] | None = None, data_type: DataType, input_name: str) -> np.ndarray:
以后端所需的样本形状加载不透明的用户张量。NumPy 文件带有自己的形状,并保持不变。原始缓冲区需要 raw_shape,并在验证其元素计数后进行重塑而不重新排序。

reorder_layout

Python
1def reorder_layout(array: np.ndarray, source_layout: str, target_layout: str) -> np.ndarray:
重新排序轴,仅添加或删除单例批次维度。