diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/.gitignore b/samples/modelbuilder/ImageClassification_Azure_LandUse/.gitignore new file mode 100644 index 000000000..ca9e32aea --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/.gitignore @@ -0,0 +1,361 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*[.json, .xml, .info] + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Models +# **/*.onnx +# **/MLModel.zip \ No newline at end of file diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUse.sln b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUse.sln new file mode 100644 index 000000000..0214207ed --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUse.sln @@ -0,0 +1,121 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LandUseAPI", "LandUseAPI\LandUseAPI.csproj", "{072A985C-AFA3-4749-9ADC-44B8B8A86C43}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LandUseML.Model", "LandUseML.Model\LandUseML.Model.csproj", "{DB539ACB-65AC-4729-BF36-1FE1B100DC8D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LandUseML.ConsoleApp", "LandUseML.ConsoleApp\LandUseML.ConsoleApp.csproj", "{C977DB56-3880-4245-AA0A-0B06DE3F8F73}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LandUseUWP", "LandUseUWP\LandUseUWP.csproj", "{6743E603-A633-4A01-90B1-62667F58B0E3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|ARM.ActiveCfg = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|ARM.Build.0 = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|ARM64.Build.0 = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|x64.ActiveCfg = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|x64.Build.0 = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|x86.ActiveCfg = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Debug|x86.Build.0 = Debug|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|Any CPU.Build.0 = Release|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|ARM.ActiveCfg = Release|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|ARM.Build.0 = Release|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|ARM64.ActiveCfg = Release|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|ARM64.Build.0 = Release|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|x64.ActiveCfg = Release|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|x64.Build.0 = Release|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|x86.ActiveCfg = Release|Any CPU + {072A985C-AFA3-4749-9ADC-44B8B8A86C43}.Release|x86.Build.0 = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|ARM.ActiveCfg = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|ARM.Build.0 = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|ARM64.Build.0 = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|x64.ActiveCfg = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|x64.Build.0 = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|x86.ActiveCfg = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Debug|x86.Build.0 = Debug|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|Any CPU.Build.0 = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|ARM.ActiveCfg = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|ARM.Build.0 = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|ARM64.ActiveCfg = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|ARM64.Build.0 = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|x64.ActiveCfg = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|x64.Build.0 = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|x86.ActiveCfg = Release|Any CPU + {DB539ACB-65AC-4729-BF36-1FE1B100DC8D}.Release|x86.Build.0 = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|ARM.ActiveCfg = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|ARM.Build.0 = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|ARM64.Build.0 = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|x64.ActiveCfg = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|x64.Build.0 = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|x86.ActiveCfg = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Debug|x86.Build.0 = Debug|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|Any CPU.Build.0 = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|ARM.ActiveCfg = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|ARM.Build.0 = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|ARM64.ActiveCfg = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|ARM64.Build.0 = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|x64.ActiveCfg = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|x64.Build.0 = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|x86.ActiveCfg = Release|Any CPU + {C977DB56-3880-4245-AA0A-0B06DE3F8F73}.Release|x86.Build.0 = Release|Any CPU + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|Any CPU.ActiveCfg = Debug|x86 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|ARM.ActiveCfg = Debug|ARM + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|ARM.Build.0 = Debug|ARM + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|ARM.Deploy.0 = Debug|ARM + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|ARM64.Build.0 = Debug|ARM64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|x64.ActiveCfg = Debug|x64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|x64.Build.0 = Debug|x64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|x64.Deploy.0 = Debug|x64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|x86.ActiveCfg = Debug|x86 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|x86.Build.0 = Debug|x86 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Debug|x86.Deploy.0 = Debug|x86 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|Any CPU.ActiveCfg = Release|x86 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|ARM.ActiveCfg = Release|ARM + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|ARM.Build.0 = Release|ARM + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|ARM.Deploy.0 = Release|ARM + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|ARM64.ActiveCfg = Release|ARM64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|ARM64.Build.0 = Release|ARM64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|ARM64.Deploy.0 = Release|ARM64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|x64.ActiveCfg = Release|x64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|x64.Build.0 = Release|x64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|x64.Deploy.0 = Release|x64 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|x86.ActiveCfg = Release|x86 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|x86.Build.0 = Release|x86 + {6743E603-A633-4A01-90B1-62667F58B0E3}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8EF0791A-27EB-4F37-BFA6-4D4A7730FFB3} + EndGlobalSection +EndGlobal diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Controllers/ClassificationController.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Controllers/ClassificationController.cs new file mode 100644 index 000000000..ce0197ca3 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Controllers/ClassificationController.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using System.IO; +using System.Drawing; +using Microsoft.ML; +using LandUseML.Model; +using System.Reflection; + +namespace LandUseAPI.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ClassificationController : ControllerBase + { + private readonly PredictionEngine _predictionEngine; + private readonly object _predictionEngineLock = new object(); + + public ClassificationController(PredictionEngine predictionEngine) + { + _predictionEngine = predictionEngine; + } + + [HttpPost] + public async Task ClassifyImage([FromBody] Dictionary input) + { + string prediction; + string imagePath = Path.Join(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "inputimage.jpeg"); + + // Get raw image bytes + var imageBytes = Convert.FromBase64String(input["data"]); + + using (var ms = new MemoryStream(imageBytes)) + { + // Save the image to a file + using (var img = await Task.Run(() => Image.FromStream(ms))) + await Task.Run(() => img.Save(imagePath)); + } + + lock (_predictionEngineLock) + { + // Use Prediction to classify image + ModelOutput output = _predictionEngine.Predict(new ModelInput { ImageSource = imagePath }); + prediction = output.Prediction; + } + + return prediction; + } + } +} \ No newline at end of file diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Controllers/WeatherForecastController.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Controllers/WeatherForecastController.cs new file mode 100644 index 000000000..9cd3db934 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Controllers/WeatherForecastController.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace LandUseAPI.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet] + public IEnumerable Get() + { + var rng = new Random(); + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = rng.Next(-20, 55), + Summary = Summaries[rng.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/LandUseAPI.csproj b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/LandUseAPI.csproj new file mode 100644 index 000000000..8a9357107 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/LandUseAPI.csproj @@ -0,0 +1,17 @@ + + + + netcoreapp3.1 + + + + + + + + + + + + + diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Program.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Program.cs new file mode 100644 index 000000000..9e92e4e50 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace LandUseAPI +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Startup.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Startup.cs new file mode 100644 index 000000000..0ed39709f --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/Startup.cs @@ -0,0 +1,70 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using System.IO; +using Microsoft.ML; +using LandUseML.Model; +using System.Reflection; + +namespace LandUseAPI +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddSingleton>(sp => + { + // Initialize MLContext + MLContext ctx = new MLContext(); + + // Register NormalizeMapping + ctx.ComponentCatalog.RegisterAssembly(typeof(NormalizeMapping).Assembly); + + // Register LabelMapping + ctx.ComponentCatalog.RegisterAssembly(typeof(LabelMapping).Assembly); + + // Define model path + var modelPath = Path.Join(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "MLModel.zip"); + + //Load model + ITransformer mlModel = ctx.Model.Load(modelPath, out var modelInputSchema); + + // Create prediction engine + var predEngine = ctx.Model.CreatePredictionEngine(mlModel); + + return predEngine; + }); + services.AddControllers(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/WeatherForecast.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/WeatherForecast.cs new file mode 100644 index 000000000..74ba244c3 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/WeatherForecast.cs @@ -0,0 +1,15 @@ +using System; + +namespace LandUseAPI +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string Summary { get; set; } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/appsettings.Development.json b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/appsettings.Development.json new file mode 100644 index 000000000..8983e0fc1 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/appsettings.json b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/appsettings.json new file mode 100644 index 000000000..d9d9a9bff --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseAPI/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/LandUseML.ConsoleApp.csproj b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/LandUseML.ConsoleApp.csproj new file mode 100644 index 000000000..33dac535c --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/LandUseML.ConsoleApp.csproj @@ -0,0 +1,20 @@ + + + + Exe + netcoreapp2.1 + + + + + + + + + + + + PreserveNewest + + + diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/ModelBuilder.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/ModelBuilder.cs new file mode 100644 index 000000000..13c0e1f69 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/ModelBuilder.cs @@ -0,0 +1,73 @@ +// This file was auto-generated by ML.NET Model Builder. +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.ML; +using Microsoft.ML.Data; +using LandUseML.Model; +namespace LandUseML.ConsoleApp +{ + public static class ModelBuilder + { + private static string MLNET_MODEL = @"MLModel.zip"; + private static string ONNX_MODEL = @"bestModel.onnx"; + + // Create MLContext to be shared across the model creation workflow objects + // Set a random seed for repeatable/deterministic results across multiple trainings. + private static MLContext mlContext = new MLContext(seed: 1); + + // Training in Azure produces an ONNX model; this method demonstrates creating an ML.NET model (MLModel.zip) from the ONNX model (bestModel.onnx), which you can then use with the ConsumeModel() method to make predictions + public static void CreateMLNetModelFromOnnx() + { + // Load data + IDataView inputDataView = mlContext.Data.LoadFromEnumerable(new ModelInput[] { }); + + // Create an ML.NET pipeline to score using the ONNX model + // Notice that this pipeline is not trainable because it only contains transformers + IEstimator pipeline = BuildPipeline(mlContext); + + // Create ML.NET model from pipeline + ITransformer mlModel = pipeline.Fit(inputDataView); + + // Save model + SaveModel(mlContext, mlModel, MLNET_MODEL, inputDataView.Schema); + } + + public static IEstimator BuildPipeline(MLContext mlContext) + { + // Data process configuration with pipeline data transformations to: + // 1. Score using provided onnx model + // 2. Map scores to labels to make model output easier to understand and use + var pipeline = mlContext.Transforms.LoadImages("ImageSource_featurized", null, "ImageSource") + .Append(mlContext.Transforms.ResizeImages("ImageSource_featurized", 224, 224, "ImageSource_featurized")) + .Append(mlContext.Transforms.ExtractPixels("ImageSource_featurized", "ImageSource_featurized")) + .Append(mlContext.Transforms.CustomMapping( + (input, output) => NormalizeMapping.Mapping(input, output), + contractName: nameof(NormalizeMapping))) + .Append(mlContext.Transforms.ApplyOnnxModel(modelFile: ONNX_MODEL)) + .Append(mlContext.Transforms.CustomMapping( + (input, output) => LabelMapping.Mapping(input, output), + contractName: nameof(LabelMapping))); + return pipeline; + } + + private static void SaveModel(MLContext mlContext, ITransformer mlModel, string modelRelativePath, DataViewSchema modelInputSchema) + { + // Save/persist the trained model to a .ZIP file + Console.WriteLine($"=============== Saving the model ==============="); + mlContext.Model.Save(mlModel, modelInputSchema, GetAbsolutePath(modelRelativePath)); + Console.WriteLine("The model is saved to {0}", GetAbsolutePath(modelRelativePath)); + } + + public static string GetAbsolutePath(string relativePath) + { + FileInfo _dataRoot = new FileInfo(typeof(Program).Assembly.Location); + string assemblyFolderPath = _dataRoot.Directory.FullName; + + string fullPath = Path.Combine(assemblyFolderPath, relativePath); + + return fullPath; + } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/Program.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/Program.cs new file mode 100644 index 000000000..14986f1e9 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/Program.cs @@ -0,0 +1,45 @@ +// This file was auto-generated by ML.NET Model Builder. + +using System; +using System.IO; +using System.Linq; +using Microsoft.ML; +using LandUseML.Model; +using System.Reflection; + +namespace LandUseML.ConsoleApp +{ + class Program + { + //Image to use for predictions + private const string DATA_FILEPATH = @"inputimage.jpeg"; + + static void Main(string[] args) + { + // Create single instance of sample data for model input + ModelInput sampleData = CreateSingleDataSample(DATA_FILEPATH); + + // Make a single prediction on the sample data and print results + var predictionResult = ConsumeModel.Predict(sampleData); + + Console.WriteLine("Using model to make single prediction -- Comparing actual Label with predicted Label from sample data...\n\n"); + Console.WriteLine($"ImageSource: {sampleData.ImageSource}"); + Console.WriteLine($"\n\nActual Label: {sampleData.Label} \nPredicted Label value {predictionResult.Prediction} \nPredicted Label scores: [{String.Join(",", predictionResult.Score)}]\n\n"); + Console.WriteLine("=============== End of process, hit any key to finish ==============="); + Console.ReadKey(); + } + + // Change this code to create your own sample data + #region CreateSingleDataSample + // Method to load single row of dataset to try a single prediction + private static ModelInput CreateSingleDataSample(string dataFilePath) + { + // Use first line of dataset as model input + // You can replace this with new test data (hardcoded or from end-user application) + ModelInput sampleForPrediction = new ModelInput { ImageSource = dataFilePath }; + + return sampleForPrediction; + } + #endregion + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/inputimage.jpeg b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/inputimage.jpeg new file mode 100644 index 000000000..465bdbd0e Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.ConsoleApp/inputimage.jpeg differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/ConsumeModel.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/ConsumeModel.cs new file mode 100644 index 000000000..eb2fb4fd9 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/ConsumeModel.cs @@ -0,0 +1,39 @@ +// This file was auto-generated by ML.NET Model Builder. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.ML; +using LandUseML.Model; +using System.IO; +using System.Reflection; + +namespace LandUseML.Model +{ + public class ConsumeModel + { + // For more info on consuming ML.NET models, visit https://aka.ms/model-builder-consume + // Method for consuming model in your app + public static ModelOutput Predict(ModelInput input) + { + // Create new MLContext + MLContext mlContext = new MLContext(); + + // Register NormalizeMapping + mlContext.ComponentCatalog.RegisterAssembly(typeof(NormalizeMapping).Assembly); + + // Register LabelMapping + mlContext.ComponentCatalog.RegisterAssembly(typeof(LabelMapping).Assembly); + + // Load model & create prediction engine + string modelPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),"MLModel.zip"); + ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema); + var predEngine = mlContext.Model.CreatePredictionEngine(mlModel); + + // Use model to make prediction on input data + ModelOutput result = predEngine.Predict(input); + return result; + } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/LabelMapping.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/LabelMapping.cs new file mode 100644 index 000000000..dd54a7dc2 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/LabelMapping.cs @@ -0,0 +1,48 @@ +// This file was auto-generated by ML.NET Model Builder. +using Microsoft.ML.Data; +using Microsoft.ML.Transforms; +using System; +using System.Linq; + +namespace LandUseML.Model +{ + [CustomMappingFactoryAttribute(nameof(LabelMapping))] + public class LabelMapping : CustomMappingFactory + { + public static string[] Label { get; set; } = new string[] { "AnnualCrop", "Forest", "HerbaceousVegetation", "Highway", "Industrial", "Pasture", "PermanentCrop", "Residential", "River", "SeaLake", }; + // This is the custom mapping. We now separate it into a method, so that we can use it both in training and in loading. + public static void Mapping(LabelMappingInput input, LabelMappingOutput output) + { + var values = input.output1.GetValues().ToArray(); + var maxVal = values.Max(); + var exp = values.Select(v => Math.Exp(v - maxVal)); + var sumExp = exp.Sum(); + + exp.Select(v => (float)(v / sumExp)).ToArray(); + output.score = exp.Select(v => (float)(v / sumExp)).ToArray(); + + var maxValue = output.score.Max(); + var maxValueIndex = Array.IndexOf(output.score, maxValue); + output.label = Label[maxValueIndex]; + } + // This factory method will be called when loading the model to get the mapping operation. + public override Action GetMapping() + { + return Mapping; + } + } + public class LabelMappingInput + { + [ColumnName("output1")] + public VBuffer output1; + } + public class LabelMappingOutput + { + + [ColumnName("PredictedLabel")] + public string label { get; set; } + + [ColumnName("Score")] + public float[] score { get; set; } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/LandUseML.Model.csproj b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/LandUseML.Model.csproj new file mode 100644 index 000000000..1eabb104a --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/LandUseML.Model.csproj @@ -0,0 +1,21 @@ + + + + netstandard2.0 + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/MLModel.zip b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/MLModel.zip new file mode 100644 index 000000000..05b7785f4 Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/MLModel.zip differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/ModelInput.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/ModelInput.cs new file mode 100644 index 000000000..6c7aa26dd --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/ModelInput.cs @@ -0,0 +1,18 @@ +// This file was auto-generated by ML.NET Model Builder. + +using Microsoft.ML.Data; + +namespace LandUseML.Model +{ + public class ModelInput + { + [ColumnName("Label"), LoadColumn(0)] + public string Label { get; set; } + + + [ColumnName("ImageSource"), LoadColumn(1)] + public string ImageSource { get; set; } + + + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/ModelOutput.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/ModelOutput.cs new file mode 100644 index 000000000..5361d793f --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/ModelOutput.cs @@ -0,0 +1,16 @@ +// This file was auto-generated by ML.NET Model Builder. + +using System; +using Microsoft.ML.Data; + +namespace LandUseML.Model +{ + public class ModelOutput + { + // ColumnName attribute is used to change the column name from + // its default value, which is the name of the field. + [ColumnName("PredictedLabel")] + public String Prediction { get; set; } + public float[] Score { get; set; } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/NormalizeMapping.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/NormalizeMapping.cs new file mode 100644 index 000000000..c5881b121 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/NormalizeMapping.cs @@ -0,0 +1,50 @@ +// This file was auto-generated by ML.NET Model Builder. + +using Microsoft.ML.Data; +using Microsoft.ML.Transforms; +using System; +using System.Linq; + +namespace LandUseML.Model +{ + [CustomMappingFactoryAttribute(nameof(NormalizeMapping))] + public class NormalizeMapping : CustomMappingFactory + { + // This is the custom mapping. We now separate it into a method, so that we can use it both in training and in loading. + public static void Mapping(NormalizeInput input, NormalizeOutput output) + { + var values = input.Reshape.GetValues().ToArray(); + + var image_mean = new float[] { 0.485f, 0.456f, 0.406f }; + var image_std = new float[] { 0.229f, 0.224f, 0.225f }; + + for (int x = 0; x < values.Count(); x++) + { + var y = x % 3; + // Normalize by 255 first + values[x] /= 255; + values[x] = (values[x] - image_mean[y]) / image_std[y]; + }; + + output.Reshape = new VBuffer(values.Count(), values); + } + // This factory method will be called when loading the model to get the mapping operation. + public override Action GetMapping() + { + return Mapping; + } + } + public class NormalizeInput + { + [ColumnName("ImageSource_featurized")] + [VectorType(3, 224, 224)] + public VBuffer Reshape; + } + public class NormalizeOutput + { + [ColumnName("input1")] + [VectorType(3 * 224 * 224)] + public VBuffer Reshape; + } +} + diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/bestModel.onnx b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/bestModel.onnx new file mode 100644 index 000000000..dac0b2dff Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/bestModel.onnx differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/bestModelMap.json b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/bestModelMap.json new file mode 100644 index 000000000..28bc2387c --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseML.Model/bestModelMap.json @@ -0,0 +1 @@ +["AnnualCrop", "Forest", "HerbaceousVegetation", "Highway", "Industrial", "Pasture", "PermanentCrop", "Residential", "River", "SeaLake"] \ No newline at end of file diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/App.xaml b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/App.xaml new file mode 100644 index 000000000..bece52ff4 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/App.xaml @@ -0,0 +1,7 @@ + + + diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/App.xaml.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/App.xaml.cs new file mode 100644 index 000000000..cec73f1ff --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/App.xaml.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +namespace LandUseUWP +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + sealed partial class App : Application + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + this.Suspending += OnSuspending; + } + + /// + /// Invoked when the application is launched normally by the end user. Other entry points + /// will be used such as when the application is launched to open a specific file. + /// + /// Details about the launch request and process. + protected override void OnLaunched(LaunchActivatedEventArgs e) + { + Frame rootFrame = Window.Current.Content as Frame; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + rootFrame.NavigationFailed += OnNavigationFailed; + + if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) + { + //TODO: Load state from previously suspended application + } + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + if (e.PrelaunchActivated == false) + { + if (rootFrame.Content == null) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame.Navigate(typeof(MainPage), e.Arguments); + } + // Ensure the current window is active + Window.Current.Activate(); + } + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new Exception("Failed to load Page " + e.SourcePageType.FullName); + } + + /// + /// Invoked when application execution is being suspended. Application state is saved + /// without knowing whether the application will be terminated or resumed with the contents + /// of memory still intact. + /// + /// The source of the suspend request. + /// Details about the suspend request. + private void OnSuspending(object sender, SuspendingEventArgs e) + { + var deferral = e.SuspendingOperation.GetDeferral(); + //TODO: Save application state and stop any background activity + deferral.Complete(); + } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/LockScreenLogo.scale-200.png b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 000000000..735f57adb Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/LockScreenLogo.scale-200.png differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/SplashScreen.scale-200.png b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/SplashScreen.scale-200.png new file mode 100644 index 000000000..023e7f1fe Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/SplashScreen.scale-200.png differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Square150x150Logo.scale-200.png b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 000000000..af49fec1a Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Square150x150Logo.scale-200.png differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Square44x44Logo.scale-200.png b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 000000000..ce342a2ec Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Square44x44Logo.scale-200.png differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 000000000..f6c02ce97 Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/StoreLogo.png b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/StoreLogo.png new file mode 100644 index 000000000..7385b56c0 Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/StoreLogo.png differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Wide310x150Logo.scale-200.png b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 000000000..288995b39 Binary files /dev/null and b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Assets/Wide310x150Logo.scale-200.png differ diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Coordinates.cs b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Coordinates.cs new file mode 100644 index 000000000..cc06f1260 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/Coordinates.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Text.Json.Serialization; + +namespace LandUseUWP +{ + class Coordinates + { + [JsonPropertyName("lat")] + public string Latitude { get; set; } + + [JsonPropertyName("lon")] + public string Longitude { get; set; } + } +} diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/LandUseUWP.csproj b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/LandUseUWP.csproj new file mode 100644 index 000000000..f02eb3741 --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/LandUseUWP.csproj @@ -0,0 +1,172 @@ + + + + + Debug + x86 + {6743E603-A633-4A01-90B1-62667F58B0E3} + AppContainerExe + Properties + LandUseUWP + LandUseUWP + en-US + UAP + 10.0.18362.0 + 10.0.17763.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + true + false + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + true + true + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + true + true + + + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM64 + false + prompt + true + true + + + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM64 + false + prompt + true + true + + + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + true + true + + + PackageReference + + + + App.xaml + + + + MainPage.xaml + + + + + + Designer + + + + + + + + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + 6.2.9 + + + 4.7.1 + + + + 14.0 + + + + \ No newline at end of file diff --git a/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/MainPage.xaml b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/MainPage.xaml new file mode 100644 index 000000000..75306221b --- /dev/null +++ b/samples/modelbuilder/ImageClassification_Azure_LandUse/LandUseUWP/MainPage.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + +