-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Changed Image classification API to accept Image as VBuffer<byte> #4242
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -3,10 +3,13 @@ | |||
// See the LICENSE file in the project root for more information. | |||
|
|||
using System; | |||
using System.Collections.Concurrent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
@@ -112,6 +135,10 @@ private ImageLoadingTransformer(IHost host, ModelLoadContext ctx) | |||
// int: id of image folder | |||
|
|||
ImageFolder = ctx.LoadStringOrNull(); | |||
if (ctx.Header.ModelVerWritten >= 0x00010003) // do a version check | |||
UseImageType = ctx.Reader.ReadBoolean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two don't need to be defined in advance.
@@ -125,6 +131,9 @@ public static void Example() | |||
IEnumerable<ImageData> testImages = LoadImagesFromDirectory( | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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