dotnet / dotnet/machinelearning
Tensorflow prediction failure with MSTest
- Dominant language
- C#
- Stars
- 9.4k
- Forks
- 2k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 11
Description
### System information
- **OS version/distro** Windows 10:
- **.NET Version (eg., dotnet --info)** 4.8:
### Issue
- **What did you do?**
Loaded Tensorflow model then called MakePrediction.
- **What happened?**
A Tensorflow.TensorflowException was raised
- **What did you expect?**
No exception, expected functionality
### Source code
```
public float PredictOne(Bitmap image)
{
if(image == null)
{
throw new ArgumentNullException();
}
float[] floatArrayImage = BitmapToFloatArrayWithPreprocessing(image);
ImageInputData[] input = new ImageInputData[] { new ImageInputData() { serving_default_input_1 = floatArrayImage } };
var outScores = MakePrediction(input);
float result = 0;
foreach(var prediction in outScores)
{
result = prediction.StatefulPartitionedCall[0];
}
return result;
}
```
### Log
```
Test method HardhatDet.Tests.HardhatDetTest.PredictOneTestNoHardhat threw exception:
System.InvalidOperationException: Splitter/consolidator worker encountered exception while consuming source data ---> Tensorflow.TensorflowException: Op type not registered 'FusedBatchNormV3' in binary running on GITLAB-RUNNER. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.
[[{{node StatefulPartitionedCall}}]]
[[{{node StatefulPartitionedCall}}]]
Stack Trace:
at Microsoft.ML.TensorFlow.TensorFlowUtils.Runner.Run()
at Microsoft.ML.Transforms.TensorFlowTransformer.Mapper.UpdateCacheIfNeeded(Int64 position, ITensorValueGetter[] srcTensorGetters, String[] activeOutputColNames, OutputCache outputCache)
at Microsoft.ML.Transforms.TensorFlowTransformer.Mapper.<>c__DisplayClass9_0`1.b__4(VBuffer`1& dst)
at Microsoft.ML.Data.DataViewUtils.Splitter.InPipe.Impl`1.Fill()
at Microsoft.ML.Data.DataViewUtils.Splitter.<>c__DisplayClass7_1.b__2()
--- End of inner exception stack trace ---
at Microsoft.ML.Data.DataViewUtils.Splitter.Batch.SetAll(OutPipe[] pipes)
at Microsoft.ML.Data.DataViewUtils.Splitter.Cursor.MoveNextCore()
at Microsoft.ML.Data.RootCursorBase.MoveNext()
at Microsoft.ML.Data.TypedCursorable`1.RowCursorImplementation.MoveNext()
at Microsoft.ML.PipeEngine`1.d__3.MoveNext()
at HardhatDet.HardhatDetector.PredictOne(Bitmap image) in D:\Gitlabrunner\builds\gb6xNTch\0\ftf\door\HardhatDet\HardhatDetector.cs:line 55
at HardhatDet.Tests.HardhatDetTest.PredictOneTestNoHardhat() in D:\Gitlabrunner\builds\gb6xNTch\0\ftf\door\GuardTests\HardhatDetTest.cs:line 123
```
Contributor guide
Assessment
This issue has not been assessed yet.