Skip to content

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

Merged
merged 14 commits into from
Oct 3, 2019

Conversation

harshithapv
Copy link
Contributor

@harshithapv harshithapv commented Sep 23, 2019

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

@dnfclas
Copy link

dnfclas commented Sep 23, 2019

CLA assistant check
All CLA requirements met.

@codemzs
Copy link
Member

codemzs commented Sep 29, 2019

Please revert this file, i.e git checkout upstream master filepath


Refers to: docs/samples/Microsoft.ML.Samples/Program.cs:32 in ae2ac0d. [](commit_id = ae2ac0d, deletion_comment = False)

@codemzs
Copy link
Member

codemzs commented Oct 3, 2019

            verWeCanReadBack: 0x00010002,

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)

Copy link
Member

@codemzs codemzs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -3,10 +3,13 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Concurrent;

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();

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,

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;

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);
Copy link
Contributor

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.

harshithapv added a commit to harshithapv/machinelearning that referenced this pull request Oct 15, 2019
…Added functionality to use resnet_v2_50 model. Added learning rate scheduling for CIFAR-10 dataset.
@ghost ghost locked as resolved and limited conversation to collaborators Mar 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Image Classification DNN Transfer Learning] - Support training and scoring with in-memory images
6 participants