custom static method
Creates a fully customizable preprocessing pipeline.
Implementation
static TensorPipeline custom({
required int height,
required int width,
InterpolationMode interpolation = InterpolationMode.bilinear,
List<double>? mean,
List<double>? std,
bool addBatchDim = true,
bool toChw = true,
}) {
final ops = <dynamic>[
ResizeOp(height: height, width: width, mode: interpolation),
];
if (toChw) {
ops.add(ToTensorOp(normalize: true));
} else {
ops.add(TypeCastOp.toFloat32());
ops.add(ScaleOp.toUnit());
}
if (mean != null && std != null) {
ops.add(NormalizeOp(mean: mean, std: std));
}
if (addBatchDim) {
ops.add(UnsqueezeOp.batch());
}
return TensorPipeline(ops.cast(), name: 'Custom');
}