Windows ML,系统内置的机器学习平台初探
2018-05-07 12:20
477 查看
人工智能现在很火,虽然最近风头隐隐有被区块链盖过,但仍是未来技术转型的首选方向之一。作为AI核心的机器学习,目前也进化到了可以基于平台自动训练模型的地步,例如Azure Machine Learning Service和Google AutoML Service。这使得训练模型的难度大大降低,开发人员可以分出更多精力关注在训练好的模型应用上。
在这种背景下,各个操作系统平台纷纷推出内置的机器学习框架/运行环境,iOS有CoreML,Android有TensorFlow。Windows在最近的RS4(build 1803)更新之后,也正式内置了机器学习平台- Windows ML。
using System; using System.Collections.Generic; using System.Threading.Tasks; using Windows.Media; using Windows.Storage; using Windows.AI.MachineLearning.Preview; // FNSLaMuse namespace Demo { public sealed class FNSLaMuseModelInput { public VideoFrame inputImage { get; set; } } public sealed class FNSLaMuseModelOutput { public VideoFrame outputImage { get; set; } public FNSLaMuseModelOutput() { this.outputImage = VideoFrame.CreateWithSoftwareBitmap(new Windows.Graphics.Imaging.SoftwareBitmap(Windows.Graphics.Imaging.BitmapPixelFormat.Bgra8, 720, 720)); } } public sealed class FNSLaMuseModel { private LearningModelPreview learningModel; public static async Task<FNSLaMuseModel> CreateFNSLaMuseModel(StorageFile file) { LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file); FNSLaMuseModel model = new FNSLaMuseModel(); model.learningModel = learningModel; return model; } public async Task<FNSLaMuseModelOutput> EvaluateAsync(FNSLaMuseModelInput input) { FNSLaMuseModelOutput output = new FNSLaMuseModelOutput(); LearningModelBindingPreview binding = new LearningModelBindingPreview(learningModel); binding.Bind("inputImage", input.inputImage); binding.Bind("outputImage", output.outputImage); LearningModelEvaluationResultPreview evalResult = await learningModel.EvaluateAsync(binding, string.Empty); return output; } } }View Code
目前由于SDK仍在预览中,所以Visual Studio正式版并不会自动调用mlgen工具生成定义文件,需要手动执行如下命令:
mlgen -i INPUT-FILE -l LANGUAGE -n NAMESPACE [-o OUTPUT-FILE]
INPUT-FILE
: ONNX模型文件LANGUAGE
: C++或者C#NAMESPACE
: 命名空间OUTPUT-FILE
: 输出路径,可缺省
总结
有了Windows ML后我们可以实现以前难以实现的机器学习特性,同时不用依赖外部web service,很多创新的体验可以实现,不仅仅是在PC,甚至在HoloLens上同样可以运用机器学习的能力。
最后给大家安利下我的开源项目- Awesome WindowsML ONNX Models ,这个项目除了提供我已经验证过的模型外,还提供了CoreML模型的快速转换工具。
同时我也在开发为HoloLens编写的Demo,最近将会和大家见面
相关文章推荐
- 使用自动化部署服务拓展Windows系统平台
- 基于Windows平台的开放和智能的蓝牙系统结构
- Jenkins在Windows系统dotnet平台持续集成
- 基于Windows CE .net平台的嵌入式系统的定制和裁剪
- Windows 系统编程初探 (二)俗套的 Hello World
- 初探 Windows 7 M3 Build6801 - 从当前系统升级
- 英特尔发布面向Windows机器学习平台芯片
- 机器学习的框架、平台、系统、库和工具包的列表
- 基于windows平台中的系统配置、管理与维护的某些命令
- windows平台简易直播系统搭建
- Windows平台下C++插件系统实现的几个关键技术问题及其解决思路
- Windows 2008 下系统平台定时备份解决方案[1]
- Windows平台调查网络程序的2个系统工具
- 在Windows系统下搭建ELK日志分析平台
- Gearman任务分布系统部署windows平台_使用Cygwin
- Windows 系统编程初探 (三)栈(Stack)的奥秘
- 【Xamarin 挖墙脚系列:Windows 10 一个包罗万象的系统平台】
- Windows平台下C++插件系统实现的几个关键技术问题及其解决思路
- Domino系统从UNIX平台到windows平台的迁移及备份
- Windows平台下C++插件系统实现的几个关键技术问题及其解决思路