ClikaRT::processor::ImageProcessorConfig
class
Header: ClikaRT/processor/config.h
Settable configuration for an ImageProcessor (convert-rgb → resize → center-crop → rescale → normalize → pad). Default-constructed to the documented HuggingFace defaults (resize + rescale by 1/255 + normalize on; crop + pad off); tune with the fluent setters, or round-trip a preprocessor_config.json through from_json / to_json. Move-only.
Static member functions
from_json()
static ImageProcessorConfig from_json(std::string_view text)
Parse a config from preprocessor_config.json text (flat, or nesting an "image_processor" block). Malformed text raises ClikaRT::Error.
The accepted schema is ClikaRT's own canonical config: the HuggingFace preprocessing keys plus the ClikaRT extension keys (target_dtype, resize_before_cast). Two semantics to be aware of when feeding it a HuggingFace-authored file:
- A missing key takes ClikaRT's documented default (this class's default-constructed state), NOT the per-processor-class default the HuggingFace
image_processor_typewould imply. Fields a HuggingFace class hardcodes rather than serializes must be set explicitly. - A key outside the accepted schema is ignored for the parse but logged as a warning naming it, so a mis-spelled or unsupported key is a visible diagnostic, never a silently different pipeline.
- A
size/crop_size/pad_sizevalue is one of: a bare integer (forsize, the shortest edge, aspect preserved, the CLIP-style"size": 224; forcrop_size/pad_size, a square), a[height, width]list (an exact target),{height, width},{shortest_edge},{shortest_edge, longest_edge}, or{max_height, max_width}. Any other value form (a one-element list, a string, an object with another key set) is refused with an error naming the supported forms, never read as "no size".
Declared in ClikaRT/processor/config.h, line 80
Member functions
ImageProcessorConfig()
ImageProcessorConfig()
A default configuration, usable with no config file.
Declared in ClikaRT/processor/config.h, line 50
ImageProcessorConfig(ImageProcessorConfig)
ImageProcessorConfig(ImageProcessorConfig&&) noexcept
move-construct (the source becomes an empty shell)
Declared in ClikaRT/processor/config.h, line 51
operator=(ImageProcessorConfig)
ImageProcessorConfig& operator=(ImageProcessorConfig&&) noexcept
move-assign (the source becomes an empty shell)
Declared in ClikaRT/processor/config.h, line 52
ImageProcessorConfig(ImageProcessorConfig)
ImageProcessorConfig(const ImageProcessorConfig&)
copy-construct: a DEEP copy (independent settings)
Declared in ClikaRT/processor/config.h, line 53
operator=(ImageProcessorConfig)
ImageProcessorConfig& operator=(const ImageProcessorConfig&)
copy-assign: a deep copy
Declared in ClikaRT/processor/config.h, line 54
~ImageProcessorConfig()
~ImageProcessorConfig()
destructor
Declared in ClikaRT/processor/config.h, line 55
to_json()
std::string to_json(int indent = 2) const
Serialize to preprocessor_config.json text (indent < 0 = compact), ClikaRT's canonical form, with every field (defaults included) materialized. Every field round-trips through from_json. Infallible.
Declared in ClikaRT/processor/config.h, line 86
resize_shortest_edge(int64_t)
ImageProcessorConfig& resize_shortest_edge(std::int64_t edge)
Resize the shortest edge to edge, preserving aspect (turns resize on): the {shortest_edge} size form; a bare integer size in a config file means the same. The other edge is truncated, never rounded, so a 480×640 image at 224 becomes 224×298.
Declared in ClikaRT/processor/config.h, line 94
resize_shortest_edge(int64_t, int64_t)
ImageProcessorConfig& resize_shortest_edge(std::int64_t edge, std::int64_t longest_cap)
Resize the shortest edge to edge and cap the longest at longest_cap (the DETR-style aspect-preserving fit, the {shortest_edge, longest_edge} size form; turns resize on). When the cap binds, the shortest edge is re-derived from it: a 1080×1920 image at 800/1333 becomes 750×1333.
Declared in ClikaRT/processor/config.h, line 99
resize_to()
ImageProcessorConfig& resize_to(std::int64_t height, std::int64_t width)
Resize to an exact height×width (turns resize on): the {height, width} / [height, width] size forms.
Declared in ClikaRT/processor/config.h, line 102
resize_within()
ImageProcessorConfig& resize_within(std::int64_t max_height, std::int64_t max_width)
Fit inside max_height×max_width preserving aspect, the {max_height, max_width} size form (turns resize on). Scales up as well as down: the more constrained side lands exactly on its bound, the other is truncated; a 300×400 image within 100×60 becomes 45×60.
Declared in ClikaRT/processor/config.h, line 107
set_do_resize()
ImageProcessorConfig& set_do_resize(bool on)
resize step on/off (the resize_* setters turn it on)
Declared in ClikaRT/processor/config.h, line 108
resample(ImageResample)
ImageProcessorConfig& resample(ImageResample mode)
The resize resampling filter (PIL vocabulary). Default bicubic.
Declared in ClikaRT/processor/config.h, line 110
resample(ImageResample, bool)
ImageProcessorConfig& resample(ImageResample mode, bool antialias)
Filter + antialias in one call (the resize quality pair): mode picks the filter, antialias the smoothing.
Declared in ClikaRT/processor/config.h, line 113
set_antialias()
ImageProcessorConfig& set_antialias(bool on)
Antialiased resize on/off. Default ON, the PIL behavior every HuggingFace image processor exhibits; turn off only to trade fidelity for speed on large downscales.
Declared in ClikaRT/processor/config.h, line 117
center_crop_to()
ImageProcessorConfig& center_crop_to(std::int64_t height, std::int64_t width)
Center-crop to height×width (turns crop on).
Declared in ClikaRT/processor/config.h, line 119
set_do_center_crop()
ImageProcessorConfig& set_do_center_crop(bool on)
center-crop step on/off (center_crop_to turns it on)
Declared in ClikaRT/processor/config.h, line 120
pad_to()
ImageProcessorConfig& pad_to(std::int64_t height, std::int64_t width)
Pad (detection-style) bottom/right with zeros to height×width (turns pad on).
Declared in ClikaRT/processor/config.h, line 123
set_do_pad()
ImageProcessorConfig& set_do_pad(bool on)
pad step on/off (pad_to turns it on)
Declared in ClikaRT/processor/config.h, line 124
rescale_by()
ImageProcessorConfig& rescale_by(double factor)
Scale pixel values by factor (e.g. 1/255). Turns rescale on.
Declared in ClikaRT/processor/config.h, line 126
set_do_rescale()
ImageProcessorConfig& set_do_rescale(bool on)
rescale step on/off (rescale_by turns it on)
Declared in ClikaRT/processor/config.h, line 127
normalize()
ImageProcessorConfig& normalize(ClikaRT::Span<const float> mean, ClikaRT::Span<const float> std)
Per-channel normalization (subtract mean, divide by std). mean/std are length 1 or 3; turns normalize on. The spans are read during the call.
Declared in ClikaRT/processor/config.h, line 130
set_do_normalize()
ImageProcessorConfig& set_do_normalize(bool on)
normalize step on/off (normalize turns it on)
Declared in ClikaRT/processor/config.h, line 131
set_do_convert_rgb()
ImageProcessorConfig& set_do_convert_rgb(bool on)
force 1/4-channel input to RGB before the pipeline (default on)
Declared in ClikaRT/processor/config.h, line 132
set_target_dtype()
ImageProcessorConfig& set_target_dtype(DataType dtype)
The dtype the pipeline produces (and works in for rescale/normalize). The loaded image is cast to it exactly once, or not at all when it already matches. Default Float32.
Declared in ClikaRT/processor/config.h, line 136
set_resize_before_cast()
ImageProcessorConfig& set_resize_before_cast(bool on)
Resize/crop in the LOADED dtype and cast to target_dtype afterward, the HuggingFace/PIL order (default true). Set false to cast to target_dtype FIRST and resize in that dtype: the portable path for a device whose resize kernel does not cover the loaded integer dtype.
Declared in ClikaRT/processor/config.h, line 141
do_resize()
bool do_resize() const
whether the resize step runs (default on)
Declared in ClikaRT/processor/config.h, line 144
resample()
ImageResample resample() const
The resampling filter. A config whose PIL code has no filter here (e.g. LANCZOS) reads back Bicubic, the filter the pipeline actually runs.
Declared in ClikaRT/processor/config.h, line 147
antialias()
bool antialias() const
whether resize antialiases (default on)
Declared in ClikaRT/processor/config.h, line 148
do_center_crop()
bool do_center_crop() const
whether center-crop runs (default off)
Declared in ClikaRT/processor/config.h, line 149
do_rescale()
bool do_rescale() const
whether rescale runs (default on)
Declared in ClikaRT/processor/config.h, line 150
rescale_factor()
double rescale_factor() const
the rescale multiplier (default 1/255)
Declared in ClikaRT/processor/config.h, line 151
do_normalize()
bool do_normalize() const
whether normalize runs (default on)
Declared in ClikaRT/processor/config.h, line 152
do_convert_rgb()
bool do_convert_rgb() const
whether RGB conversion runs (default on)
Declared in ClikaRT/processor/config.h, line 153
do_pad()
bool do_pad() const
whether detection-pad runs (default off)
Declared in ClikaRT/processor/config.h, line 154
target_dtype()
DataType target_dtype() const
the pipeline output/work dtype (default Float32)
Declared in ClikaRT/processor/config.h, line 155
resize_before_cast()
bool resize_before_cast() const
whether geometry runs before the dtype cast (default true)
Declared in ClikaRT/processor/config.h, line 156