ML.NET管道

问题描述

我正在使用ML.NET 1.5.2版进行图像分类,并使用KERAS生成卷积神经网络(CNN)来预测28x28彩色BGR像素图像。问题是ML.NET引擎在管道级别修改映像。图像修改的过程在问题https://github.com/dotnet/machinelearning/issues/2022部分有很好的描述(在ML.NET和Keras / TensorFlow#2022下,卷积网络给出了不同的结果)。从那时起,ML.NET经历了多次更新,当前版本已更改“ ResizeImages”和“ ExtractPixels”。我正在使用以下管道并更改了属性

在ExtractPixels上:

-interleavePixelColors: true
-orderOfExtraction: ImagePixelExtractingEstimator.ColorsOrder.ABGR

在ResizeImages:

resizing: ImageResizingEstimator.ResizingKind.Fill
cropAnchor: ImageResizingEstimator.Anchor.Center

只有使用这些设置,我才能获得与KERAS(python)中接近的值。

我通过错误和管道属性的试验得出了正确的结果。我的问题是,有人在管道中被操纵后是否知道观察图像(jpg或bmp文件)的方法。欢迎所有意见。

我的代码

var pipeline = mlContext.Transforms.LoadImages(
                                        outputColumnName: "conv2d_4_input",imageFolder: "",inputColumnName: nameof(ImageNetData.ImagePath))
                    .Append(mlContext.Transforms.ResizeImages(
                                        outputColumnName: "conv2d_4_input",imageWidth: ImageNetSettings.imageWidth,imageHeight: ImageNetSettings.imageHeight,inputColumnName: "conv2d_4_input",resizing: ImageResizingEstimator.ResizingKind.Fill,cropAnchor: ImageResizingEstimator.Anchor.Center))
                    .Append(mlContext.Transforms.ExtractPixels(
                                        outputColumnName: "conv2d_4_input",inputColumnName:null,colorsToExtract: ImagePixelExtractingEstimator.ColorBits.Rgb,orderOfExtraction: ImagePixelExtractingEstimator.ColorsOrder.ABGR,interleavePixelColors: true,offsetimage: 0,scaleImage: 1,outputAsFloatArray: true))
                    .Append(mlContext.Transforms.ApplyOnnxModel(
                                        modelFile: modelLocation,outputColumnNames: new[] { ModelSettings.ModelOutput },inputColumnNames: new[] { ModelSettings.ModelInput }));

更新:看来

DataDebuggerPreview ls = pipeline.Preview(data); 

为您提供ColumnView和RowView属性here from docs)。从那里可以建立图像。如果有人曾经尝试过此操作,我想知道,并且会感谢您是否提供了代码段。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)