/vision/v1.0/analyze 的 Microsoft 认知服务内部服务器错误
Microsoft Cognitive Service Internal Server Error for /vision/v1.0/analyze
我做了一个小程序来测试微软认知服务,但它总是return
{
"code":"InternalServerError",
"requestId":"6d6dd4ec-9840-4db3-9849-a6497094fa4c",
"message":"Internal server error."
}
我使用的代码是:
#!/usr/bin/env python
import httplib, urllib, base64
headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '53403359628e420ab85a516a79ba1bd0',
}
params = urllib.urlencode({
# Request parameters
'visualFeatures': 'Categories,Tags,Adult,Description,Faces',
'details': '{string}',
})
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("POST", "/vision/v1.0/analyze?%s" % params,
'{"url":"http://static5.netshoes.net/Produtos/bola-umbro-neo-liga-futsal/28/D21-0232-028/D21-0232-028_zoom1.jpg?resize=54g:*"}', headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
是我做错了什么还是普遍的服务器问题?
问题出在 params 变量中。在定义要提取的视觉特征时,您可以指定图像的特定细节,如 documentation 中所述。 details 字段(如果使用)必须使用可用的有效 string 选项之一进行初始化(目前仅支持 "Celebrities" 选项,这将识别图像中的名人)。在这种情况下,您使用 literally 文档中注明的占位符 ('{string'}) 初始化了 details 字段。这导致系统出现内部错误。
要纠正这个问题,您应该尝试:
params = urllib.urlencode({
# Request parameters
'visualFeatures': 'Categories,Tags,Adult,Description,Faces',
'details': 'Celebrities',
})
(PS:已将此行为报告给 Microsoft 认知服务。)
我做了一个小程序来测试微软认知服务,但它总是return
{
"code":"InternalServerError",
"requestId":"6d6dd4ec-9840-4db3-9849-a6497094fa4c",
"message":"Internal server error."
}
我使用的代码是:
#!/usr/bin/env python
import httplib, urllib, base64
headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '53403359628e420ab85a516a79ba1bd0',
}
params = urllib.urlencode({
# Request parameters
'visualFeatures': 'Categories,Tags,Adult,Description,Faces',
'details': '{string}',
})
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("POST", "/vision/v1.0/analyze?%s" % params,
'{"url":"http://static5.netshoes.net/Produtos/bola-umbro-neo-liga-futsal/28/D21-0232-028/D21-0232-028_zoom1.jpg?resize=54g:*"}', headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
是我做错了什么还是普遍的服务器问题?
问题出在 params 变量中。在定义要提取的视觉特征时,您可以指定图像的特定细节,如 documentation 中所述。 details 字段(如果使用)必须使用可用的有效 string 选项之一进行初始化(目前仅支持 "Celebrities" 选项,这将识别图像中的名人)。在这种情况下,您使用 literally 文档中注明的占位符 ('{string'}) 初始化了 details 字段。这导致系统出现内部错误。
要纠正这个问题,您应该尝试:
params = urllib.urlencode({
# Request parameters
'visualFeatures': 'Categories,Tags,Adult,Description,Faces',
'details': 'Celebrities',
})
(PS:已将此行为报告给 Microsoft 认知服务。)