-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add support for Mobilenet v2 in Image Classification transfer learning #4351
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a62e956
add Mobilenet_V2 architecture support and sample
ashbhandare 7afce9b
Separated try catch fix in different issue, added model download loca…
ashbhandare be59945
removed redundant sample, changed comment message to add MobilenetV2
ashbhandare 251312f
added test for MobileNetV2, reusing test with Theory
ashbhandare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/Microsoft.ML.TestFramework/Attributes/TensorflowTheoryAttribute.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
namespace Microsoft.ML.TestFramework.Attributes | ||
{ | ||
/// <summary> | ||
/// A theory for tests requiring TensorFlow. | ||
/// </summary> | ||
public sealed class TensorFlowTheoryAttribute : EnvironmentSpecificTheoryAttribute | ||
{ | ||
public TensorFlowTheoryAttribute() : base("TensorFlow is 64-bit only") | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override bool IsEnvironmentSupported() | ||
{ | ||
return Environment.Is64BitProcess; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1207,8 +1207,10 @@ public void TensorFlowStringTest() | |
Assert.Equal(string.Join(" ", input.B).Replace("/", " "), textOutput.BOut[0]); | ||
} | ||
|
||
[TensorFlowFact] | ||
public void TensorFlowImageClassification() | ||
[TensorFlowTheory] | ||
[InlineData(ImageClassificationEstimator.Architecture.ResnetV2101)] | ||
[InlineData(ImageClassificationEstimator.Architecture.MobilenetV2)] | ||
public void TensorFlowImageClassification(ImageClassificationEstimator.Architecture arch) | ||
{ | ||
string assetsRelativePath = @"assets"; | ||
string assetsPath = GetAbsolutePath(assetsRelativePath); | ||
|
@@ -1249,10 +1251,10 @@ public void TensorFlowImageClassification() | |
var pipeline = mlContext.Transforms.LoadImages("Image", fullImagesetFolderPath, false, "ImagePath") // false indicates we want the image as a VBuffer<byte> | ||
.Append(mlContext.Model.ImageClassification( | ||
"Image", "Label", | ||
// Just by changing/selecting InceptionV3 here instead of | ||
// Just by changing/selecting InceptionV3/MobilenetV2 here instead of | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to add a test for the new functionality? The CI isn't executing any of your new code. #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
// ResnetV2101 you can try a different architecture/pre-trained | ||
// model. | ||
arch: ImageClassificationEstimator.Architecture.ResnetV2101, | ||
arch: arch, | ||
epoch: 50, | ||
batchSize: 10, | ||
learningRate: 0.01f, | ||
|
@@ -1384,7 +1386,7 @@ public void TensorFlowImageClassificationEarlyStoppingIncreasing() | |
var pipeline = mlContext.Transforms.LoadImages("Image", fullImagesetFolderPath, false, "ImagePath") // false indicates we want the image as a VBuffer<byte> | ||
.Append(mlContext.Model.ImageClassification( | ||
"Image", "Label", | ||
// Just by changing/selecting InceptionV3 here instead of | ||
// Just by changing/selecting InceptionV3/MobilenetV2 here instead of | ||
// ResnetV2101 you can try a different architecture/pre-trained | ||
// model. | ||
arch: ImageClassificationEstimator.Architecture.ResnetV2101, | ||
|
@@ -1473,7 +1475,7 @@ public void TensorFlowImageClassificationEarlyStoppingDecreasing() | |
var pipeline = mlContext.Transforms.LoadImages("Image", fullImagesetFolderPath, false, "ImagePath") // false indicates we want the image as a VBuffer<byte> | ||
.Append(mlContext.Model.ImageClassification( | ||
"Image", "Label", | ||
// Just by changing/selecting InceptionV3 here instead of | ||
// Just by changing/selecting InceptionV3/MobilenetV2 here instead of | ||
// ResnetV2101 you can try a different architecture/pre-trained | ||
// model. | ||
arch: ImageClassificationEstimator.Architecture.ResnetV2101, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.