-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Can't make image classification prediction on MacOS using a Tensorflow model #6233
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
Comments
Are you using M1 macbook? |
No, I'm using a 2019 Intel Macbook Pro |
Can you provide a minimal reproduction example, and also the following information
|
This issue has been marked |
Sorry for the late response but it has been some busy days. The model is trained on a MacBook using tensorflow-metal version 0.5.0 |
@michaelgsharp can you help take a look |
Sorry for my delay. @vadd98 what version of the tensorflow redist did you use from nuget? and what version did you use with your python code? |
This issue has been marked |
I'm using the SciSharp.TensorFlow.Redist Nuget package version 2.3.1. |
Could you try retraining your model with tensorflow-macos version 2.3.1? Let us know what happens. It's possible there is an incompatibility between 2.9.2 and 2.3.1 on mac that doesn't exist on windows. |
This issue has been marked |
It seems there is no 2.3.1 version of tensorflow-macos, the minimum version is 2.5.0. So I tried updating redist to the latest version (2.7.0) but the error still remains. I'll try to retrain the model using tensorflow-macos and redist both on 2.7.0 version and will let you know as soon as I have any update |
I just tried using tensorflow-macos and redist both on 2.7.0 version for training (via Python) and predicting but I still get the error |
Managed to run training and predictions (using the sample code at least) on Mac M1 using tensorflow-macos 2.9.2 and SciSharp.TensorFlow.Redist 2.7.0. |
I just tried to add the Microsoft.ML.TensorFlow.Redist package version 0.14.0 but I still get the error. |
Sorry for the delay. I got a hold of an intel mac machine and successfully managed to reproduce this bug as you outlined. I'm not exactly sure what is causing it, but I'm on a MacBook Air 2018, Intel chip, MacOS 12.4 for the reference of others in this thread. |
@tarekgh was planning some refactoring work for this code already, so we will take a look at this bug again once that goes through. |
I just tried to run the same code in a net 6 focal docker container and I'm getting the same error |
I am working on changing the Image handling in general and should fix this problem #6363. Will let you know when I have it merged. Thanks for your patience. |
The PR #6363 should be addressed this issue. Please try it and let's know if you see any issue. Please note, we have introduced a class called |
Thanks! |
You can get the newly built package from the internal feed. But you need to wait till the new package gets built, signed, and published. Currently we are experiencing some issues in the building, this should be fixed soon. The way to reference the internal feed is as follows. When we have a new build, I'll send you the package version that you can use. Add a nuget.config file to your project, in the same folder as your .csproj or .sln file <?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="MachineLearning" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/MachineLearning/nuget/v3/index.json" />
</packageSources>
</configuration> |
The package version you can use which has the changes is |
I'm using the new package and it is indeed working on Mac and on Ubuntu Focal Docker containers. Thanks! |
System Information (please complete the following information):
Describe the bug
It seems impossible to make prediction based on images using a Tensorflow model on Mac.
I'm always getting this error:
Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array. at Microsoft.ML.Transforms.Image.ImagePixelExtractingTransformer.Mapper.<>c__DisplayClass5_0
1.b__1(VBuffer1& dst) at Microsoft.ML.Transforms.TensorFlowTransformer.TensorValueGetterVec
1.GetTensor()at Microsoft.ML.Transforms.TensorFlowTransformer.Mapper.UpdateCacheIfNeeded(Int64 position, ITensorValueGetter[] srcTensorGetters, String[] activeOutputColNames, OutputCache outputCache)
at Microsoft.ML.Transforms.TensorFlowTransformer.Mapper.<>c__DisplayClass11_0
1.<MakeGetter>b__4(VBuffer
1& dst)at Microsoft.ML.Data.TypedCursorable
1.TypedRowBase.<>c__DisplayClass8_0
1.b__0(TRow row)at Microsoft.ML.Data.TypedCursorable
1.TypedRowBase.FillValues(TRow row) at Microsoft.ML.Data.TypedCursorable
1.RowImplementation.FillValues(TRow row)at Microsoft.ML.PredictionEngineBase
2.FillValues(TDst prediction) at Microsoft.ML.PredictionEngine
2.Predict(TSrc example, TDst& prediction)at Microsoft.ML.PredictionEngineBase
2.Predict(TSrc example)
The exact same code with same model and same images to predict works flawlessly on Windows 10.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Make predictions without exceptions.
Screenshots, Code, Sample Projects
If applicable, add screenshots, code snippets, or sample projects to help explain your problem.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: