static ndarray <float> PrepareImage(byte[,,] image) { int height = image.GetLength(0); int width = image.GetLength(1); int channels = image.GetLength(2); var normalized = ImageTools.NormalizeChannelValue(image.ToNumPyArray()); var flattened = normalized.reshape(new[] { height *width, channels }).astype(np.float32_fn); return((ndarray <float>)flattened); }
static Tensor ClampToValidChannelValueRange(Tensor input) => tf.clip_by_value(input, clip_value_min: ImageTools.NormalizeChannelValue(-0.01f), clip_value_max: ImageTools.NormalizeChannelValue(255.01f));