ios - Xamarin.iOS coreML 在后台模式下获取预测空引用错误

标签 ios xamarin xamarin.ios coreml

当 iOS 应用程序在后台模式下运行时,model.GetPrediction 方法返回 null 对象。当应用程序位于前台时,该方法返回正确的预测。还有其他人遇到过这个问题吗?

最佳答案

有几件事:

当应用后台运行时,您执行任意代码的时间非常有限。

  • 您可以检查BackgroundTimeRemaining来确定您还剩多少时间。
  • 您必须在 BeginBackgroundTask 操作中执行预测

前台应用程序(包括 Springboard)的优先级高于 GPU。

  • 前台应用 GPU 处理不会因执行基于后台任务的预测而中断。

  • 您可以通过向预测调用提供 MLPredictionOptions 来请求预测使用 CPU (UsesCpuOnly)。

Your model should be restricted to the CPU if it might run in the background or if your app has other GPU intensive tasks.

回复:https://developer.apple.com/documentation/coreml/mlpredictionoptions/2921288-usescpuonly?language=objc

关于ios - Xamarin.iOS coreML 在后台模式下获取预测空引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49015698/

相关文章:

ios - xamarin 形式 : iOS webview not showing website run using react or ant design pro

ios - 自动布局按比例缩放 View

c# - 使用 Xamarin.iOS (C#) : Which method should I use? 在 iOS 中设置后台

android - 如何在 ionic 中打开键盘时以编程方式使屏幕滚动到顶部

xcode - 无法摆脱 Xcode 中的闪屏

ios - WKWEBVIEW 仅显示网站的移动版本

ios - 加密plist文件方法

c# - Xamarin Studio(在 OSX 上)还是 Visual Studio(在 Windows 上)?

c# - 在 Xamarin Android 中存储 SQLite 数据库的路径

ios - Xamarin iOS : Can we set stoardboardid in XIB file?