Changed Image classification API to accept Image as VBuffer<byte>#4242
Changed Image classification API to accept Image as VBuffer<byte>#4242codemzs merged 14 commits intodotnet:masterfrom
Conversation
...icrosoft.ML.Samples/Dynamic/ImageClassification/ResnetV2101TransferLearningTrainTestSplit.cs
Outdated
Show resolved
Hide resolved
...icrosoft.ML.Samples/Dynamic/ImageClassification/ResnetV2101TransferLearningTrainTestSplit.cs
Outdated
Show resolved
Hide resolved
...icrosoft.ML.Samples/Dynamic/ImageClassification/ResnetV2101TransferLearningTrainTestSplit.cs
Outdated
Show resolved
Hide resolved
...icrosoft.ML.Samples/Dynamic/ImageClassification/ResnetV2101TransferLearningTrainTestSplit.cs
Outdated
Show resolved
Hide resolved
...icrosoft.ML.Samples/Dynamic/ImageClassification/ResnetV2101TransferLearningTrainTestSplit.cs
Outdated
Show resolved
Hide resolved
...icrosoft.ML.Samples/Dynamic/ImageClassification/ResnetV2101TransferLearningTrainTestSplit.cs
Outdated
Show resolved
Hide resolved
...icrosoft.ML.Samples/Dynamic/ImageClassification/ResnetV2101TransferLearningTrainTestSplit.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.ML.ImageAnalytics/Microsoft.ML.ImageAnalytics.csproj
Outdated
Show resolved
Hide resolved
increment these versions since you are changing model format and then when deserializing the model check if the model was written with an older version or new version and based on that try to deserialize indicator for image type. #Resolved Refers to: src/Microsoft.ML.ImageAnalytics/ImageLoader.cs:183 in 20d6660. [](commit_id = 20d6660, deletion_comment = False) |
...icrosoft.ML.Samples/Dynamic/ImageClassification/ResnetV2101TransferLearningTrainTestSplit.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.ML.ImageAnalytics/Microsoft.ML.ImageAnalytics.csproj
Outdated
Show resolved
Hide resolved
tools-local/Microsoft.ML.StableApi/Microsoft.ML.StableApi.csproj
Outdated
Show resolved
Hide resolved
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using System.Collections.Concurrent; |
There was a problem hiding this comment.
Concurrent [](start = 25, length = 10)
This and System.Runtime.InteropServices are not used, please remove them.
Also, System.Diagnostics.Contracts should not be used, on line 328 you have Contract.Assert instead of Contracts.Assert.
|
|
||
| ImageFolder = ctx.LoadStringOrNull(); | ||
| if (ctx.Header.ModelVerWritten >= 0x00010003) // do a version check | ||
| UseImageType = ctx.Reader.ReadBoolean(); |
There was a problem hiding this comment.
ReadBoolean [](start = 42, length = 11)
Please use ReadBoolByte instead.
| verWeCanReadBack: 0x00010002, | ||
| verWrittenCur: 0x00010003, // Added support for output type as byte array | ||
| verReadableCur: 0x00010003, | ||
| verWeCanReadBack: 0x00010003, |
There was a problem hiding this comment.
0x00010003 [](start = 34, length = 10)
This should still be 0x00010002, since you are taking care of backwards compatibility in line 138.
| private static bool TryLoadDataIntoBuffer(string path, ref VBuffer<byte> imgData, byte[] readBuffer) | ||
| { | ||
| int count = -1; | ||
| int bytesread = -1; |
There was a problem hiding this comment.
These two don't need to be defined in advance.
| imagesForPredictions, false); | ||
|
|
||
| byte[] imgBytes = File.ReadAllBytes(testImages.First().ImagePath); | ||
| VBuffer<Byte> imgData = new VBuffer<byte>(imgBytes.Length, imgBytes); |
There was a problem hiding this comment.
It doesn't look like this in-memory image is being used for the Prediction when using the PredictionEngine, right?
In fact, looks like this object 'imgData' is not used later on?
We need to have and test Predictions by providing the in-memory image instead of file paths.
I cannot find such a code.
…Added functionality to use resnet_v2_50 model. Added learning rate scheduling for CIFAR-10 dataset.
Changed Image classification API to accept Image as V Buffer. Also, added a few optimizations to re-use the buffer for performance gains.
So we can do the best job, please check:
fixes #4153