add reference to onnx package in model project (#4844)

This commit is contained in:
Xiaoyun Zhang 2020-02-18 15:50:49 -08:00 коммит произвёл GitHub
Родитель 3dcac49094
Коммит da958e13e4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 10 добавлений и 47 удалений

Просмотреть файл

@ -93,53 +93,6 @@ namespace Microsoft.ML.CodeGenerator.CSharp
Utils.AddProjectsToSolution(modelprojectDir, modelProjectName, consoleAppProjectDir, consoleAppProjectName, solutionPath);
}
public void GenerateAzureRemoteImageOutput()
{
// Get Namespace
var namespaceValue = Utils.Normalize(_settings.OutputName);
var labelType = _columnInferenceResult.TextLoaderOptions.Columns.Where(t => t.Name == _settings.LabelName).First().DataKind;
Type labelTypeCsharp = Utils.GetCSharpType(labelType);
// Generate Model Project
var modelProjectContents = GenerateAzureAttachImageModelProjectContents(namespaceValue);
var modelProjectDir = Path.Combine(_settings.OutputBaseDir, $"{_settings.OutputName}.Model");
var modelProjectName = $"{_settings.OutputName}.Model.csproj";
// Get Normalize Mapping
var normalizeContent = new NormalizeMapping()
{
Namespace = namespaceValue,
Target = _settings.Target,
}.TransformText();
normalizeContent = Utils.FormatCode(normalizeContent);
// Write files to disk
Utils.WriteOutputToFiles(modelProjectContents.ModelInputCSFileContent, "ModelInput.cs", modelProjectDir);
Utils.WriteOutputToFiles(modelProjectContents.ModelOutputCSFileContent, "ModelOutput.cs", modelProjectDir);
Utils.WriteOutputToFiles(modelProjectContents.ConsumeModelCSFileContent, "ConsumeModel.cs", modelProjectDir);
Utils.WriteOutputToFiles(modelProjectContents.ModelProjectFileContent, modelProjectName, modelProjectDir);
Utils.WriteOutputToFiles(normalizeContent, "NormalizeMapping.cs", modelProjectDir);
// Generate ConsoleApp Project
var consoleAppProjectContents = GenerateConsoleAppProjectContents(namespaceValue, labelTypeCsharp,
false, false, false, true, false, false, true, true);
// Write files to disk.
var consoleAppProjectDir = Path.Combine(_settings.OutputBaseDir, $"{_settings.OutputName}.ConsoleApp");
var consoleAppProjectName = $"{_settings.OutputName}.ConsoleApp.csproj";
Utils.WriteOutputToFiles(consoleAppProjectContents.ConsoleAppProgramCSFileContent, "Program.cs", consoleAppProjectDir);
Utils.WriteOutputToFiles(consoleAppProjectContents.modelBuilderCSFileContent, "ModelBuilder.cs", consoleAppProjectDir);
Utils.WriteOutputToFiles(consoleAppProjectContents.ConsoleAppProjectFileContent, consoleAppProjectName, consoleAppProjectDir);
// New solution file.
Utils.CreateSolutionFile(_settings.OutputName, _settings.OutputBaseDir);
// Add projects to solution
var solutionPath = Path.Combine(_settings.OutputBaseDir, $"{_settings.OutputName}.sln");
Utils.AddProjectsToSolution(modelProjectDir, modelProjectName, consoleAppProjectDir, consoleAppProjectName, solutionPath);
}
private void SetRequiredNugetPackages(IEnumerable<PipelineNode> trainerNodes, ref bool includeLightGbmPackage,
ref bool includeMklComponentsPackage, ref bool includeFastTreePackage,
ref bool includeImageTransformerPackage, ref bool includeImageClassificationPackage, ref bool includeRecommenderPackage)

Просмотреть файл

@ -49,6 +49,11 @@ namespace Microsoft.ML.CodeGenerator.Templates.Console
this.Write(" <PackageReference Include=\"Microsoft.ML.ImageAnalytics\" Version=\"");
this.Write(this.ToStringHelper.ToStringWithCulture(StablePackageVersion));
this.Write("\" />\r\n");
}
if (IncludeOnnxModel){
this.Write(" <PackageReference Include=\"Microsoft.ML.OnnxTransformer\" Version=\"");
this.Write(this.ToStringHelper.ToStringWithCulture(StablePackageVersion));
this.Write("\" />\r\n");
}
if (IncludeImageClassificationPackage){
this.Write(" <PackageReference Include=\"Microsoft.ML.Vision\" Version=\"");

Просмотреть файл

@ -22,6 +22,9 @@
<# if (IncludeImageTransformerPackage){ #>
<PackageReference Include="Microsoft.ML.ImageAnalytics" Version="<#= StablePackageVersion #>" />
<#}#>
<# if (IncludeOnnxModel){ #>
<PackageReference Include="Microsoft.ML.OnnxTransformer" Version="<#= StablePackageVersion #>" />
<#}#>
<# if (IncludeImageClassificationPackage){ #>
<PackageReference Include="Microsoft.ML.Vision" Version="<#= StablePackageVersion #>" />
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="1.14.0" />

Просмотреть файл

@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ML" Version="StablePackageVersion" />
<PackageReference Include="Microsoft.ML.OnnxTransformer" Version="StablePackageVersion" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -6,6 +6,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.ML" Version="stableversion" />
<PackageReference Include="Microsoft.ML.ImageAnalytics" Version="stableversion" />
<PackageReference Include="Microsoft.ML.OnnxTransformer" Version="stableversion" />
</ItemGroup>
<ItemGroup>