python - 使用 microsoft api 构建应用程序
问题描述
我学习机器学习。我正在使用 azure-cognitiveservices-vision-face 构建一个应用程序,但我遇到了如下图所示的问题(APIErrorException: (404) Resource not found)。我该如何解决?谢谢和抱歉,因为我的英语很差。在此处输入图像描述
APIErrorException Traceback (most recent call last)
<ipython-input-38-889e8e1c61a7> in <module>()
1 single_face_image_url = 'https://www.biography.com/.image/t_share/MTQ1MzAyNzYzOTgxNTE0NTEz/john-f-kennedy---mini-biography.jpg'
2 single_image_name = os.path.basename(single_face_image_url)
----> 3 detected_faces = face_client.face.detect_with_url(url=single_face_image_url)
4 if not detected_faces:
5 raise Exception('No face detected from image {}'.format(single_image_name))
/usr/local/lib/python3.6/dist-packages/azure/cognitiveservices/vision/face/operations/_face_operations.py in detect_with_url(self, url, return_face_id, return_face_landmarks, return_face_attributes, recognition_model, return_recognition_model, detection_model, custom_headers, raw, **operation_config)
547
548 if response.status_code not in [200]:
--> 549 raise models.APIErrorException(self._deserialize, response)
550
551 deserialized = None
APIErrorException: (404) Resource not found
解决方案
看起来您错过了尾随斜杠和端点末尾,如下所示;
EndPoint:https://westus.api.cognitive.microsoft.com/face/v1.0;
尝试将其更改为:
Modified : EndPoint:https://westus.api.cognitive.microsoft.com/face/v1.0/;
附加参考;
https://docs.microsoft.com/en-us/azure/cognitive-services/face/quickstarts/python-sdk https://github.com/Microsoft/Cognitive-Face-iOS/issues/37
希望能帮助到你。
推荐阅读
- flutter - 初始化时只能访问静态成员
- c# - 无法使用 DocuSign 管理 API [docusignapi] 更新用户个人资料
- php - 在 Laravel 6+ 中的 insert() 函数之后检索批量插入的 id
- sql - Hive SQL:如何将单个字段拆分为具有定义长度的多个列?
- c# - 如何找到仅在滚动后可见的元素?
- javascript - 使用 Stomp Client 订阅主题,但我没有收到任何通知 无法使用 React Native 并使用 Angular
- java - 创建目录时解压缩文件返回 FileNotFoundException
- windows - Pygame 破解了 Windows
- android - 如何正确初始化改造实例
- node.js - 在 Axios 调用中使用 Joi 进行验证没有给出正确的响应