我们在python3中的googlecolab上使用azurefaceapi。 它可以很好地用于url(web上的图像),但是我们不能让它在Colab中作为文件下载的本地文件上工作。 例如,我们无法读取本地Colab文件中的文件,例如以下路径: ImagePath='/content/Slide331.PNG'
response = requests.post(face_api_url, params=params, headers=headers, json={"url": image_url})
如何更改json={“url”:image\u url} 到本地路径,例如ImagePath='/content/Slide331.PNG'??????你知道吗
我们试着去看蔚蓝请求.post文件和参数,但它没有提供任何具体信息。你知道吗
我们相信这些也需要改变:
faces = response.json()
image_file = BytesIO(requests.get(image_url).content)
这是ouf完整代码,上面是其中的元素:
''Python
def annotate_image(image_url):
response = requests.post(face_api_url, params=params, headers=headers, json={"url": image_url})
faces = response.json()
image_file = BytesIO(requests.get(image_url).content)
image = Image.open(image_file)
plt.figure(figsize=(8,8))
ax = plt.imshow(image, alpha=0.6)
for face in faces:
[HERE IS THE CODE TO PLOT FACES ON THE PICTURES WHICH WORKS WELL]
''
我们尝试将URL更改为本地路径,但没有成功: {'错误':{'代码':'无效URL','消息':'无效图像URL.}}
目前没有回答
相关问题 更多 >
编程相关推荐