martinzink commented on code in PR #2258: URL: https://github.com/apache/nifi-minifi-cpp/pull/2258#discussion_r4104016503
########## minifi_rust/extensions/minifi_tensor/src/low_level_processors/image_to_tensor/image_to_tensor_def.rs: ########## @@ -0,0 +1,206 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use super::{ColorFormat, ImageToTensor, ResizeFilter, ResizeMode, TensorShapeFormat}; +use crate::utils::per_channel_f32::PerChannelF32; +use minifi_native::{ + OutputAttribute, ProcessorDefinition, ProcessorInputRequirement, Property, PropertyDefinition, + Relationship, property_definitions, +}; + +pub(crate) const TARGET_WIDTH: Property<u32> = Property::new( + "Target width", + "Width in pixels the decoded image is resized to before normalisation and \ + inference.", +); + +pub(crate) const TARGET_HEIGHT: Property<u32> = Property::new( + "Target height", + "Height in pixels the decoded image is resized to before normalisation and \ + inference.", +); + +pub(crate) const RESIZE_FILTER: Property<ResizeFilter> = Property::new( + "Resize filter", + "Interpolation filter applied when resizing the decoded image. Nearest is fastest \ + but blocky; Bilinear is a good default; Bicubic and Lanczos3 are higher-quality \ + but slower.", +) +.with_default(ResizeFilter::Bilinear.into_str()); + +pub(crate) const RESIZE_MODE: Property<ResizeMode> = Property::new( + "Resize mode", + "How the source image is fitted into the target dimensions. 'Stretch' scales each \ + axis independently, distorting aspect ratio. 'Letterbox' preserves aspect ratio \ + and pads the remaining border with 'Letterbox pad value' (applied in normalised \ + output space).", +) +.with_default(ResizeMode::Stretch.into_str()); + +pub(crate) const LETTERBOX_PAD_VALUE: Property<f32> = Property::new( + "Letterbox pad value", + "Value written for padding pixels when 'Resize mode' is 'Letterbox'. This is a \ + normalised value (post mean/std), so 0.0 corresponds to a neutral input for most \ + networks. Ignored when 'Resize mode' is 'Stretch'.", +) +.with_default("0.0"); + +pub(crate) const COLOR_FORMAT: Property<ColorFormat> = Property::new( + "Color format", + "Colour space of the tensor fed to the model. RGB and BGR produce three-channel \ + tensors (channel order determined by the format); Grayscale produces a \ Review Comment: [#[strum(serialize = "Grayscale")]](https://github.com/apache/nifi-minifi-cpp/pull/2258/commits/d4266defd022b6ba3e2b477a9b8b964971918e17) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
