-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add a DNN Image Featurizer Transform Estimator #1447
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
56 commits
Select commit
Hold shift + click to select a range
bc71575
Skeleton for implementing with a new tranformer
vaeksare 32dc90c
Approach using a chain of transformers
vaeksare 38fecff
Reworked to use estimator chain
vaeksare 5e1faa5
Add basic testing
vaeksare 3c3aa2a
Reworked to use extension methods
vaeksare 66b621e
Create more extensive tests
vaeksare 87a5d51
Remove changes to onnx transform tests
vaeksare 5bec174
Rework to use CDN approach
vaeksare 8876f02
Add static extensions
vaeksare 2630f7b
Added test for static pipeline
vaeksare 4a38bf9
Updated to use correct CDN location
vaeksare 75b1b0d
Added some minor comments
vaeksare 271ae03
Use extension methods and set up the model download/nuget placement
vaeksare 2e5ef2d
Change the proj to try to fix download
vaeksare 85ca884
Fix the download in csproj
vaeksare b76deda
Models successfully download into correct folder
vaeksare 259ac05
Include the onnx models in the nuget package
vaeksare d093d4b
Fix tests and add documentation
vaeksare 30b9488
Fixed building breaking due to merge
vaeksare a3792d9
Update the estimator name to match new name
vaeksare 9338464
Change model download location and update the corresponding doc
vaeksare 1e7c7ae
Actually fixed the download location
vaeksare ec352d4
Address PR comments and add experimental test (not enabled yet)
vaeksare ee24322
Changed documentation style to use xml
vaeksare 6c97453
Add test that checks output results
vaeksare 24caec9
Address more comments
vaeksare 3975134
Change param name to be more accurate
vaeksare bf25371
Added refs to documentation
vaeksare c72bcfe
Add one more ref
vaeksare 2bb2163
Added all 4 different models
vaeksare 4cdd1eb
Address comments
vaeksare af7a844
Address more comments
vaeksare 0e2d617
More comment fixes
vaeksare e9e60b0
Address some of the comments
vaeksare 326d8bf
Replace TLC links
vaeksare 579ad6b
Rework download location
vaeksare 368cd64
Change model download to new redist proj
vaeksare 1d106bd
Add the models to content folder
vaeksare 1bebc64
Address some comments
vaeksare 22e385b
Merge remote-tracking branch 'upstream/master' into dnn-image-feat
vaeksare 8f9e808
Revert "Merge remote-tracking branch 'upstream/master' into dnn-image…
vaeksare a1e571d
Merge remote-tracking branch 'upstream/master' into dnn-image-feat
vaeksare 55b5b0f
updated libmf ref
vaeksare 7405fce
Updated to fix issues related to OnnxTransform changes
vaeksare ce93709
Merge remote-tracking branch 'upstream/master' into dnn-image-feat
vaeksare 02e8ebc
Update to new namespace
vaeksare c519a19
Address more comments
vaeksare a687ccb
Reorganize model downloading
vaeksare 52a3e6a
Fix test downloading
vaeksare 9f566a2
Removed model duplication in NuGets
vaeksare d33eb06
Updated targets location
vaeksare 3e4db44
Fixed issues with target content inclusion
vaeksare 5fbd41d
Change targets file to be consistent
vaeksare bdc9f60
Fix bug due to targets
vaeksare 8effaf9
Simplify model copy in tests
vaeksare b27ebe2
Address minor comment
vaeksare 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.SamplesUtils", | |
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.Recommender", "src\Microsoft.ML.Recommender\Microsoft.ML.Recommender.csproj", "{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.DnnImageFeaturizer.ResNet18", "src\Microsoft.ML.DnnImageFeaturizer.ResNet18\Microsoft.ML.DnnImageFeaturizer.ResNet18.csproj", "{9222FC9D-599A-49A5-B685-08CC9A5C81D7}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.DnnImageFeaturizer.AlexNet", "src\Microsoft.ML.DnnImageFeaturizer.AlexNet\Microsoft.ML.DnnImageFeaturizer.AlexNet.csproj", "{6C29AA9B-054B-4762-BEA5-D305B932AA80}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.DnnImageFeaturizer.ResNet50", "src\Microsoft.ML.DnnImageFeaturizer.ResNet50\Microsoft.ML.DnnImageFeaturizer.ResNet50.csproj", "{4805129D-78C8-46D4-9519-0AD9B0574D6D}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.DnnImageFeaturizer.ResNet101", "src\Microsoft.ML.DnnImageFeaturizer.ResNet101\Microsoft.ML.DnnImageFeaturizer.ResNet101.csproj", "{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
|
@@ -501,6 +509,38 @@ Global | |
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU | ||
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU | ||
{9222FC9D-599A-49A5-B685-08CC9A5C81D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9222FC9D-599A-49A5-B685-08CC9A5C81D7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9222FC9D-599A-49A5-B685-08CC9A5C81D7}.Debug-Intrinsics|Any CPU.ActiveCfg = Debug-Intrinsics|Any CPU | ||
{9222FC9D-599A-49A5-B685-08CC9A5C81D7}.Debug-Intrinsics|Any CPU.Build.0 = Debug-Intrinsics|Any CPU | ||
{9222FC9D-599A-49A5-B685-08CC9A5C81D7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9222FC9D-599A-49A5-B685-08CC9A5C81D7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{9222FC9D-599A-49A5-B685-08CC9A5C81D7}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU | ||
{9222FC9D-599A-49A5-B685-08CC9A5C81D7}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU | ||
{6C29AA9B-054B-4762-BEA5-D305B932AA80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6C29AA9B-054B-4762-BEA5-D305B932AA80}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6C29AA9B-054B-4762-BEA5-D305B932AA80}.Debug-Intrinsics|Any CPU.ActiveCfg = Debug-Intrinsics|Any CPU | ||
{6C29AA9B-054B-4762-BEA5-D305B932AA80}.Debug-Intrinsics|Any CPU.Build.0 = Debug-Intrinsics|Any CPU | ||
{6C29AA9B-054B-4762-BEA5-D305B932AA80}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6C29AA9B-054B-4762-BEA5-D305B932AA80}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{6C29AA9B-054B-4762-BEA5-D305B932AA80}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU | ||
{6C29AA9B-054B-4762-BEA5-D305B932AA80}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU | ||
{4805129D-78C8-46D4-9519-0AD9B0574D6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4805129D-78C8-46D4-9519-0AD9B0574D6D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4805129D-78C8-46D4-9519-0AD9B0574D6D}.Debug-Intrinsics|Any CPU.ActiveCfg = Debug-Intrinsics|Any CPU | ||
{4805129D-78C8-46D4-9519-0AD9B0574D6D}.Debug-Intrinsics|Any CPU.Build.0 = Debug-Intrinsics|Any CPU | ||
{4805129D-78C8-46D4-9519-0AD9B0574D6D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4805129D-78C8-46D4-9519-0AD9B0574D6D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4805129D-78C8-46D4-9519-0AD9B0574D6D}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU | ||
{4805129D-78C8-46D4-9519-0AD9B0574D6D}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU | ||
{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71}.Debug-Intrinsics|Any CPU.ActiveCfg = Debug-Intrinsics|Any CPU | ||
{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71}.Debug-Intrinsics|Any CPU.Build.0 = Debug-Intrinsics|Any CPU | ||
{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU | ||
{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
|
@@ -556,6 +596,10 @@ Global | |
{ECB71297-9DF1-48CE-B93A-CD969221F9B6} = {DA452A53-2E94-4433-B08C-041EDEC729E6} | ||
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. Not aligned? #Resolved |
||
{11A5210E-2EA7-42F1-80DB-827762E9C781} = {09EADF06-BE25-4228-AB53-95AE3E15B530} | ||
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3} = {09EADF06-BE25-4228-AB53-95AE3E15B530} | ||
{9222FC9D-599A-49A5-B685-08CC9A5C81D7} = {09EADF06-BE25-4228-AB53-95AE3E15B530} | ||
{6C29AA9B-054B-4762-BEA5-D305B932AA80} = {09EADF06-BE25-4228-AB53-95AE3E15B530} | ||
{4805129D-78C8-46D4-9519-0AD9B0574D6D} = {09EADF06-BE25-4228-AB53-95AE3E15B530} | ||
{DB7CEB5E-8BE6-48A7-87BE-B91D9AE96F71} = {09EADF06-BE25-4228-AB53-95AE3E15B530} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {41165AF1-35BB-4832-A189-73060F82B01D} | ||
|
19 changes: 19 additions & 0 deletions
19
...Microsoft.ML.DnnImageFeaturizer.AlexNet/Microsoft.ML.DnnImageFeaturizer.AlexNet.nupkgproj
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,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageDescription>ML.NET component for pretrained AlexNet image featurization</PackageDescription> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.ML.OnnxTransform\Microsoft.ML.OnnxTransform.nupkgproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="$(ObjDir)\DnnImageModels\AlexNetOnnx\AlexNet.onnx" Pack="true" PackagePath="tools\DnnImageModels\AlexNetOnnx" /> | ||
<Content Include="$(ObjDir)\DnnImageModels\AlexNetPrepOnnx\AlexNetPreprocess.onnx" Pack="true" PackagePath="tools\DnnImageModels\AlexNetPrepOnnx" /> | ||
<Content Include="..\common\DnnImageFeaturizer.props" Pack="true" PackagePath="build\netstandard2.0\$(MSBuildProjectName).props" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
|
5 changes: 5 additions & 0 deletions
5
...t.ML.DnnImageFeaturizer.AlexNet/Microsoft.ML.DnnImageFeaturizer.AlexNet.symbols.nupkgproj
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,5 @@ | ||
<Project DefaultTargets="Pack"> | ||
|
||
<Import Project="Microsoft.ML.DnnImageFeaturizer.AlexNet.nupkgproj" /> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
...osoft.ML.DnnImageFeaturizer.ResNet101/Microsoft.ML.DnnImageFeaturizer.ResNet101.nupkgproj
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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageDescription>ML.NET component for pretrained ResNet101 image featurization</PackageDescription> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.ML.OnnxTransform\Microsoft.ML.OnnxTransform.nupkgproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="$(ObjDir)\DnnImageModels\ResNet101Onnx\ResNet101.onnx" Pack="true" PackagePath="tools\DnnImageModels\ResNet101Onnx" /> | ||
<Content Include="$(ObjDir)\DnnImageModels\ResNetPrepOnnx\ResNetPreprocess.onnx" Pack="true" PackagePath="tools\DnnImageModels\ResNetPrepOnnx" /> | ||
<Content Include="..\common\DnnImageFeaturizer.props" Pack="true" PackagePath="build\netstandard2.0\$(MSBuildProjectName).props" /> | ||
</ItemGroup> | ||
|
||
</Project> |
5 changes: 5 additions & 0 deletions
5
....DnnImageFeaturizer.ResNet101/Microsoft.ML.DnnImageFeaturizer.ResNet101.symbols.nupkgproj
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,5 @@ | ||
<Project DefaultTargets="Pack"> | ||
|
||
<Import Project="Microsoft.ML.DnnImageFeaturizer.ResNet101.nupkgproj" /> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
...crosoft.ML.DnnImageFeaturizer.ResNet18/Microsoft.ML.DnnImageFeaturizer.ResNet18.nupkgproj
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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageDescription>ML.NET component for pretrained ResNet18 image featurization</PackageDescription> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.ML.OnnxTransform\Microsoft.ML.OnnxTransform.nupkgproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="$(ObjDir)\DnnImageModels\ResNet18Onnx\ResNet18.onnx" Pack="true" PackagePath="tools\DnnImageModels\ResNet18Onnx" /> | ||
<Content Include="$(ObjDir)\DnnImageModels\ResNetPrepOnnx\ResNetPreprocess.onnx" Pack="true" PackagePath="tools\DnnImageModels\ResNetPrepOnnx" /> | ||
<Content Include="..\common\DnnImageFeaturizer.props" Pack="true" PackagePath="build\netstandard2.0\$(MSBuildProjectName).props" /> | ||
</ItemGroup> | ||
|
||
</Project> |
5 changes: 5 additions & 0 deletions
5
...ML.DnnImageFeaturizer.ResNet18/Microsoft.ML.DnnImageFeaturizer.ResNet18.symbols.nupkgproj
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,5 @@ | ||
<Project DefaultTargets="Pack"> | ||
|
||
<Import Project="Microsoft.ML.DnnImageFeaturizer.ResNet18.nupkgproj" /> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
...crosoft.ML.DnnImageFeaturizer.ResNet50/Microsoft.ML.DnnImageFeaturizer.ResNet50.nupkgproj
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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageDescription>ML.NET component for pretrained ResNet50 image featurization</PackageDescription> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.ML.OnnxTransform\Microsoft.ML.OnnxTransform.nupkgproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="$(ObjDir)\DnnImageModels\ResNet50Onnx\ResNet50.onnx" Pack="true" PackagePath="tools\DnnImageModels\ResNet50Onnx" /> | ||
<Content Include="$(ObjDir)\DnnImageModels\ResNetPrepOnnx\ResNetPreprocess.onnx" Pack="true" PackagePath="tools\DnnImageModels\ResNetPrepOnnx" /> | ||
<Content Include="..\common\DnnImageFeaturizer.props" Pack="true" PackagePath="build\netstandard2.0\$(MSBuildProjectName).props" /> | ||
</ItemGroup> | ||
|
||
</Project> |
5 changes: 5 additions & 0 deletions
5
...ML.DnnImageFeaturizer.ResNet50/Microsoft.ML.DnnImageFeaturizer.ResNet50.symbols.nupkgproj
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,5 @@ | ||
<Project DefaultTargets="Pack"> | ||
|
||
<Import Project="Microsoft.ML.DnnImageFeaturizer.ResNet50.nupkgproj" /> | ||
|
||
</Project> |
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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Content Include="$(MSBuildThisFileDirectory)..\..\tools\DnnImageModels\**\*.*"> | ||
<Link>DnnImageModels\%(RecursiveDir)%(Filename)%(Extension)</Link> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
</Project> |
54 changes: 54 additions & 0 deletions
54
src/Microsoft.ML.DnnImageFeaturizer.AlexNet/AlexNetExtension.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,54 @@ | ||
// 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 Microsoft.ML.Runtime; | ||
using Microsoft.ML.Runtime.Data; | ||
using System.IO; | ||
using System.Reflection; | ||
|
||
namespace Microsoft.ML.Transforms | ||
{ | ||
/// <summary> | ||
/// This is an extension method to be used with the <see cref="DnnImageFeaturizerEstimator"/> in order to use a pretrained AlexNet model. | ||
/// The NuGet containing this extension is also guaranteed to include the binary model file. | ||
/// </summary> | ||
public static class AlexNetExtension | ||
{ | ||
/// <summary> | ||
/// Returns an estimator chain with the two corresponding models (a preprocessing one and a main one) required for the AlexNet pipeline. | ||
/// Also includes the renaming ColumnsCopyingTransforms required to be able to use arbitrary input and output column names. | ||
/// This assumes both of the models are in the same location as the file containing this method, which they will be if used through the NuGet. | ||
/// This should be the default way to use AlexNet if importing the model from a NuGet. | ||
/// </summary> | ||
public static EstimatorChain<ColumnsCopyingTransformer> AlexNet(this DnnImageModelSelector dnnModelContext, IHostEnvironment env, string inputColumn, string outputColumn) | ||
{ | ||
return AlexNet(dnnModelContext, env, inputColumn, outputColumn, Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DnnImageModels")); | ||
} | ||
|
||
/// <summary> | ||
/// This allows a custom model location to be specified. This is useful is a custom model is specified, | ||
/// or if the model is desired to be placed or shipped separately in a different folder from the main application. Note that because Onnx models | ||
/// must be in a directory all by themsleves for the OnnxTransform to work, this method appends a AlexNetOnnx/AlexNetPrepOnnx subdirectory | ||
/// to the passed in directory to prevent having to make that directory manually each time. | ||
/// </summary> | ||
public static EstimatorChain<ColumnsCopyingTransformer> AlexNet(this DnnImageModelSelector dnnModelContext, IHostEnvironment env, string inputColumn, string outputColumn, string modelDir) | ||
{ | ||
var modelChain = new EstimatorChain<ColumnsCopyingTransformer>(); | ||
|
||
var inputRename = new ColumnsCopyingEstimator(env, new[] { (inputColumn, "OriginalInput") }); | ||
var midRename = new ColumnsCopyingEstimator(env, new[] { ("PreprocessedInput", "Input140") }); | ||
var endRename = new ColumnsCopyingEstimator(env, new[] { ("Dropout234_Output_0", outputColumn) }); | ||
|
||
// There are two estimators created below. The first one is for image preprocessing and the second one is the actual DNN model. | ||
var prepEstimator = new OnnxScoringEstimator(env, Path.Combine(modelDir, "AlexNetPrepOnnx", "AlexNetPreprocess.onnx"), new[] { "OriginalInput" }, new[] { "PreprocessedInput" }); | ||
var mainEstimator = new OnnxScoringEstimator(env, Path.Combine(modelDir, "AlexNetOnnx", "AlexNet.onnx"), new[] { "Input140" }, new[] { "Dropout234_Output_0" }); | ||
modelChain = modelChain.Append(inputRename); | ||
var modelChain2 = modelChain.Append(prepEstimator); | ||
modelChain = modelChain2.Append(midRename); | ||
modelChain2 = modelChain.Append(mainEstimator); | ||
modelChain = modelChain2.Append(endRename); | ||
return modelChain; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Microsoft.ML.DnnImageFeaturizer.AlexNet/Microsoft.ML.DnnImageFeaturizer.AlexNet.csproj
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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<IncludeInPackage>Microsoft.ML.DnnImageFeaturizer.AlexNet</IncludeInPackage> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.ML.OnnxTransform\Microsoft.ML.OnnxTransform.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
12 changes: 12 additions & 0 deletions
12
...icrosoft.ML.DnnImageFeaturizer.ResNet101/Microsoft.ML.DnnImageFeaturizer.ResNet101.csproj
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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<IncludeInPackage>Microsoft.ML.DnnImageFeaturizer.ResNet101</IncludeInPackage> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.ML.OnnxTransform\Microsoft.ML.OnnxTransform.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
54 changes: 54 additions & 0 deletions
54
src/Microsoft.ML.DnnImageFeaturizer.ResNet101/ResNet101Extension.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,54 @@ | ||
// 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 Microsoft.ML.Runtime; | ||
using Microsoft.ML.Runtime.Data; | ||
using System.IO; | ||
using System.Reflection; | ||
|
||
namespace Microsoft.ML.Transforms | ||
{ | ||
/// <summary> | ||
/// This is an extension method to be used with the <see cref="DnnImageFeaturizerEstimator"/> in order to use a pretrained ResNet101 model. | ||
/// The NuGet containing this extension is also guaranteed to include the binary model file. | ||
/// </summary> | ||
public static class ResNet101Extension | ||
{ | ||
/// <summary> | ||
/// Returns an estimator chain with the two corresponding models (a preprocessing one and a main one) required for the ResNet pipeline. | ||
/// Also includes the renaming ColumnsCopyingTransforms required to be able to use arbitrary input and output column names. | ||
/// This assumes both of the models are in the same location as the file containing this method, which they will be if used through the NuGet. | ||
/// This should be the default way to use ResNet101 if importing the model from a NuGet. | ||
/// </summary> | ||
public static EstimatorChain<ColumnsCopyingTransformer> ResNet101(this DnnImageModelSelector dnnModelContext, IHostEnvironment env, string inputColumn, string outputColumn) | ||
{ | ||
return ResNet101(dnnModelContext, env, inputColumn, outputColumn, Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DnnImageModels")); | ||
} | ||
|
||
/// <summary> | ||
/// This allows a custom model location to be specified. This is useful is a custom model is specified, | ||
/// or if the model is desired to be placed or shipped separately in a different folder from the main application. Note that because Onnx models | ||
/// must be in a directory all by themsleves for the OnnxTransform to work, this method appends a ResNet101Onnx/ResNetPrepOnnx subdirectory | ||
/// to the passed in directory to prevent having to make that directory manually each time. | ||
/// </summary> | ||
public static EstimatorChain<ColumnsCopyingTransformer> ResNet101(this DnnImageModelSelector dnnModelContext, IHostEnvironment env, string inputColumn, string outputColumn, string modelDir) | ||
{ | ||
var modelChain = new EstimatorChain<ColumnsCopyingTransformer>(); | ||
|
||
var inputRename = new ColumnsCopyingEstimator(env, new[] { (inputColumn, "OriginalInput") }); | ||
var midRename = new ColumnsCopyingEstimator(env, new[] { ("PreprocessedInput", "Input1600") }); | ||
var endRename = new ColumnsCopyingEstimator(env, new[] { ("Pooling2286_Output_0", outputColumn) }); | ||
|
||
// There are two estimators created below. The first one is for image preprocessing and the second one is the actual DNN model. | ||
var prepEstimator = new OnnxScoringEstimator(env, Path.Combine(modelDir, "ResNetPrepOnnx", "ResNetPreprocess.onnx"), new[] { "OriginalInput" }, new[] { "PreprocessedInput" }); | ||
var mainEstimator = new OnnxScoringEstimator(env, Path.Combine(modelDir, "ResNet101Onnx", "ResNet101.onnx"), new[] { "Input1600" }, new[] { "Pooling2286_Output_0" }); | ||
modelChain = modelChain.Append(inputRename); | ||
var modelChain2 = modelChain.Append(prepEstimator); | ||
modelChain = modelChain2.Append(midRename); | ||
modelChain2 = modelChain.Append(mainEstimator); | ||
modelChain = modelChain2.Append(endRename); | ||
return modelChain; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Microsoft.ML.DnnImageFeaturizer.ResNet18/Microsoft.ML.DnnImageFeaturizer.ResNet18.csproj
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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<IncludeInPackage>Microsoft.ML.DnnImageFeaturizer.ResNet18</IncludeInPackage> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Microsoft.ML.OnnxTransform\Microsoft.ML.OnnxTransform.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.
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.
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.
Not aligned? #Resolved