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