ClikaRT::processor::ImageProcessor
class
Header: ClikaRT/processor/processor.h
A config-driven static image preprocessor. Move-only.
Every fallible operation returns Result<T>; the library never throws. Turn a failure into an exception on your own side with .value_or_throw(), or inspect .ok() / .status() / .message().
Static member functions
from_huggingface()
static ImageProcessor from_huggingface(
std::string_view path,
StreamOrDevice where = {},
ClikaRT::Span<const std::string_view> consumed_keys = {}
)
Load a HuggingFace image preprocessor (preprocessor_config.json). path is the model directory OR the json file itself (its parent directory is used). where binds the default placement for process. path is copied, not retained.
HuggingFace-file semantics (see ImageProcessorConfig::from_json, the parse this loader runs): a missing key takes ClikaRT's documented default, not the per-processor-class default the file's image_processor_type would imply in HuggingFace; unrecognized keys are ignored with a logged warning naming them. Verify the effective steps with ImageProcessorConfig::from_json(<file text>) + its getters / to_json.
consumed_keys names top-level config keys the caller consumes above this processor (a model's own tiling or geometry keys); they join the recognized set, so a clean load logs no unknown-key warning. Keys neither recognized nor named still warn. Read during the call, not retained.
Declared in ClikaRT/processor/processor.h, line 113
from_directory()
static ImageProcessor from_directory(
std::string_view path,
StreamOrDevice where = {},
ClikaRT::Span<const std::string_view> consumed_keys = {}
)
Load from a model directory, detecting the preprocessor format present (currently HuggingFace). path is copied, not retained. consumed_keys extends the recognized key set exactly as on from_huggingface; read during the call, not retained.
Declared in ClikaRT/processor/processor.h, line 123
from_config()
static ImageProcessor from_config(const ImageProcessorConfig& config, StreamOrDevice where = {})
Build from an explicit config; no config file needed. where binds the default placement for process. config is read during the call.
Declared in ClikaRT/processor/processor.h, line 129
from_args()
static ImageProcessor from_args(
std::optional<std::pair<std::int64_t, std::int64_t>> resize = {},
std::optional<std::pair<std::int64_t, std::int64_t>> crop = {},
std::optional<double> rescale = {},
std::optional<ClikaRT::Span<const float>> mean = {},
std::optional<ClikaRT::Span<const float>> std = {},
StreamOrDevice where = {}
)
Build directly from the COMMON knobs: no config file, no config object. Pass {} for any knob to take its default; override only what you care about. For full control (pad, crop kinds, target dtype, resize order) build an ImageProcessorConfig and use from_config.
resize{height, width}to resize to;{}= the config default (resize on, driven by the model config when loaded; here{}leaves resize at its default-off-for-args state, see below).crop{height, width}center-crop;{}= no crop.rescalepixel scale;{}=kImageRescaleFactor(1/255).mean/stdper-channel normalize operands (length 1 or 3); BOTH{}= no normalize, BOTH present = normalize on. Read during the call.
Declared in ClikaRT/processor/processor.h, line 143
Member functions
ImageProcessor()
ImageProcessor(ImageProcessor&&) noexcept
move-construct (the source becomes an empty shell)
Declared in ClikaRT/processor/processor.h, line 159
operator=()
ImageProcessor& operator=(ImageProcessor&&) noexcept
move-assign
Declared in ClikaRT/processor/processor.h, line 160
~ImageProcessor()
~ImageProcessor()
destructor
Declared in ClikaRT/processor/processor.h, line 161
process(string_view, StreamOrDevice)
Tensor process(std::string_view path, StreamOrDevice where = {}) const
Preprocess one image from a file path → [H, W, C] Float32. path is read during the call, not retained. where overrides the bound placement ({} = bound).
Declared in ClikaRT/processor/processor.h, line 167
process(Span< uint8_t>, StreamOrDevice)
Tensor process(ClikaRT::Span<const std::uint8_t> bytes, StreamOrDevice where = {}) const
Preprocess one image from a file path → [H, W, C] Float32. path is read during the call, not retained. where overrides the bound placement ({} = bound).
Declared in ClikaRT/processor/processor.h, line 171
process(Tensor, StreamOrDevice)
Tensor process(const Tensor& image, StreamOrDevice where = {}) const
Preprocess one image from a file path → [H, W, C] Float32. path is read during the call, not retained. where overrides the bound placement ({} = bound).
Declared in ClikaRT/processor/processor.h, line 175
process_batch(Span< Span< uint8_t>>, StreamOrDevice)
Tensor process_batch(
ClikaRT::Span<const ClikaRT::Span<const std::uint8_t>> images,
StreamOrDevice where = {}
) const
Preprocess a batch of encoded images → [N, H, W, C] Float32 (all images must preprocess to the same [H, W, C]; fix the output size in the config).
Declared in ClikaRT/processor/processor.h, line 179
process(string_view, ImageProcessOptions, StreamOrDevice)
Tensor process(
std::string_view path,
const ImageProcessOptions& options,
StreamOrDevice where = {}
) const
Preprocess one image from a file path → [H, W, C] Float32. path is read during the call, not retained. where overrides the bound placement ({} = bound).
Declared in ClikaRT/processor/processor.h, line 187
process(Span< uint8_t>, ImageProcessOptions, StreamOrDevice)
Tensor process(
ClikaRT::Span<const std::uint8_t> bytes,
const ImageProcessOptions& options,
StreamOrDevice where = {}
) const
Preprocess one image from a file path → [H, W, C] Float32. path is read during the call, not retained. where overrides the bound placement ({} = bound).
Declared in ClikaRT/processor/processor.h, line 190
process(Tensor, ImageProcessOptions, StreamOrDevice)
Tensor process(
const Tensor& image,
const ImageProcessOptions& options,
StreamOrDevice where = {}
) const
Preprocess one image from a file path → [H, W, C] Float32. path is read during the call, not retained. where overrides the bound placement ({} = bound).
Declared in ClikaRT/processor/processor.h, line 193
process_batch(Span< Span< uint8_t>>, ImageProcessOptions, StreamOrDevice)
Tensor process_batch(
ClikaRT::Span<const ClikaRT::Span<const std::uint8_t>> images,
const ImageProcessOptions& options,
StreamOrDevice where = {}
) const
Preprocess a batch of encoded images → [N, H, W, C] Float32 (all images must preprocess to the same [H, W, C]; fix the output size in the config).
Declared in ClikaRT/processor/processor.h, line 197