Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeepLearning_ImageClassification_TensorFlow sample in 0.11 #325

Closed
bandozia opened this issue Mar 21, 2019 · 2 comments
Closed

DeepLearning_ImageClassification_TensorFlow sample in 0.11 #325

bandozia opened this issue Mar 21, 2019 · 2 comments

Comments

@bandozia
Copy link

I'm struggling to adapt this example to version 0.11
In TFModelScorer.LoadModel,
MLContext.Transforms.Resize and ImagePixelExtractorTransformer are not available, so I tried to do it this way:

Change

 var pipeline = mlContext.Transforms.LoadImages(imageFolder: imagesFolder, columns: (outputColumnName: ImageReal, inputColumnName: nameof(ImageNetData.ImagePath)))
                            .Append(mlContext.Transforms.Resize(outputColumnName: ImageReal, imageWidth: ImageNetSettings.imageWidth, imageHeight: ImageNetSettings.imageHeight, inputColumnName: ImageReal))
                            .Append(mlContext.Transforms.ExtractPixels(columns: new[] { new ImagePixelExtractorTransformer.ColumnInfo(name: InceptionSettings.inputTensorName, inputColumnName: ImageReal, interleave: ImageNetSettings.channelsLast, offset: ImageNetSettings.mean) }))
                            .Append(mlContext.Transforms.ScoreTensorFlowModel(modelLocation:modelLocation, outputColumnNames:new[] { InceptionSettings.outputTensorName }, inputColumnNames: new[] { InceptionSettings.inputTensorName } ));

to

var pipeline = mlContext.Transforms.LoadImages(imageFolder: imagesFolder, (outputColumnName: ImageReal, inputColumnName: nameof(ImageNetData.ImagePath)))
                .Append(mlContext.Transforms.ResizeImages(outputColumnName: ImageReal, imageWidth: ImageNetSettings.imageWidth, imageHeight: ImageNetSettings.imageHeight, inputColumnName: ImageReal))
                .Append(mlContext.Transforms.ExtractPixels(columns: new[] { new ImagePixelExtractingEstimator.ColumnOptions(name: InceptionSettings.inputTensorName, inputColumnName: ImageReal, interleave: ImageNetSettings.channelsLast, offset: ImageNetSettings.mean) }))
                .Append(mlContext.Transforms.ScoreTensorFlowModel(modelLocation: modelLocation, outputColumnNames: new[] { InceptionSettings.outputTensorName }, inputColumnNames: new[] { InceptionSettings.inputTensorName }));

but this results in an error, It seems like I'm missing a dimension

input must be 4-dimensional[224,224,3]
[[{{node conv2d0_pre_relu/conv}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_input_0_0, conv2d0_w)]]

Since the tensorflow model is the same as it works in v0.10, I must be doing something wrong.
Does anyone know the proper way to adapt this example?

@CESARDELATORRE
Copy link
Contributor

CESARDELATORRE commented Mar 21, 2019

@bandozia - TensorFlow support in 0.11 is broken. Right now you can:

  • Use 0.10
  • Wait for 0.12 to be released at NuGet in a few days
  • Use 0.12 daily-drops-preview available at MyGet

See issue which is already closed since it's been fixed for 0.12:
dotnet/machinelearning#2778

Hope it helps!

@prathyusha12345
Copy link
Contributor

TenosrFlow samples are working with ML.Net 10.0-preview. we migrated the samples. Please try to follow the code in those samples. For example: https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started/DeepLearning_ImageClassification_TensorFlow.

Closing this issue. thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants