swift - Watson VisualRecognition 无法对图像进行分类,给出错误 400(使用 swift)
问题描述
我正在学习使用 Watson 的 VisualRecognition 服务。应用程序将图像发送到 Watson,然后从 Watson 接收分类结果。它以前工作正常。但是它今天突然停止工作。
let apiKey = "my api key"
let version = "2019-01-01"
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage{
SVProgressHUD.show()
self.cameraButton.isEnabled = false
self.folderButton.isEnabled = false
self.ShareButton.isHidden = true
foodNameIndicatorText.isHidden = true
foodDescriptionButtonA.isHidden = true
foodDescriptionButtonB.isHidden = true
foodDescriptionButtonC.isHidden = true
//clear the results array everytime users pick an new image
self.classificationResults = []
self.foodItemResults = []
imageView.image = image
//dismiss the imgPickerController after presented
imgPickerController.dismiss(animated: true, completion: nil)
let visualRecognition = VisualRecognition(version: version, apiKey: apiKey)
visualRecognition.classify(image: image, threshold: 0.0, owners: ["default"], classifierIDs: ["food"], acceptLanguage: "en") { response, error in
if let error = error {
print("============================here is error =========================================")
print(error)
print("============================end of error =========================================")
}
guard let classifiedImages = response?.result else {
print("Failed to classify the image")
return
}
print(classifiedImages) ......
错误:
http(statusCode: Optional(400), message: nil, metadata: nil)
============================错误结束=================== ================
我尝试创建一个新的 visualRecognition 实例,并根据 Watson 的 IOS 文档使用它的分类方法。我使用的图像参数来自 imagePickerController,我允许用户从库中选择图像。但是,我在响应处理程序中收到错误,并且代码无法对我的图像进行分类。究竟发生了什么?
解决方案
如果您使用的是 Lite(免费)计划并且它突然停止工作,我的第一个猜测是您每月使用了 1000 个免费事件,这些事件用于训练和/或分类。否则,您可能应该使用您的帐户实例的详细信息打开 IBM Cloud 客户支持票证。
推荐阅读
- sql - 两个查询独立工作但不能合并它们
- c# - C#有存储多个对象并且仍然易于访问的好方法吗
- google-apps-script - Google Apps 脚本 Drive.file.insert 问题
- google-sheets - 倒数计时器从谷歌表中的开始和截止时间值的差异
- java - 如何在 Eclipse 上打印 Java 表情符号
- firebase - Firebase 函数日志记录不适用于不可调用函数
- c# - 动态 ImageButton ImageClickEventHandler 未触发
- java - 如何在 Java 中使用 Regex 提取 SQL FROM 子句中的表名?
- c - C中的函数泛化
- reactjs - React Hooks - 动态添加或删除输入字段时输入失去焦点