我正在学习使用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,允许用户从库中选择图像。但是,我在响应处理程序中收到错误,并且代码无法对图像进行分类。实际发生了什么?
答案 0 :(得分:1)
如果您使用的是Lite(免费)计划,并且突然停止工作,我的第一个猜测是您已经使用了每月用于培训和/或分类的1000个免费事件。否则,您可能应该打开一个IBM Cloud客户支持凭单,其中包含您的帐户实例的详细信息。
答案 1 :(得分:0)
Watson Visual Recognition的当前界面版本为2018-03-19
,但是您的代码中包含2019-01-01
。