我已经在 customvision.ai 上训练了模型并获得了预测键和端点。
这是我写的
import requests
import json
url="https://centralindia.api.cognitive.microsoft.com/customvision/v3.0/Prediction/xxxxxxxxxx/classify/iterations/Iteration1/url"
headers={'content-type':'application/json','Prediction-Key':'24xxxxxxxxxxxxxxxxxxxxxx'}
body={"Url": "https://i.imgur.com/cYzaOkV.jpg"}
r =requests.post(url,data=body,headers=headers)
print(r.content)
但是当我试图运行它时,我得到了这个错误:
b'{"code":"BadRequestImageUrl","message":"Invalid image url"}'
但是,我尝试使用本地图像调用我的模型,在这种情况下,它可以正常工作在这里为本地 img 编写的代码:
import requests
import json
url="https://centralindia.api.cognitive.microsoft.com/customvision/v3.0/Prediction/82xxxxxxxxxxxxxxxxxxxx/classify/iterations/Iteration1/image"
headers={'content-type':'application/octet-stream','Prediction-Key':'24xxxxxxxxxxxxxxxxxx'}
r =requests.post(url,data=open("lentigo-adults-1.jpg","rb"),headers=headers)
print(r.content)
我得到了我想要的输出:
b'{"id":"43a1d33b-0ea9-490a-9ae4-d24f8395931a","project":"82462bcc-5616-4f82-98ea-8d4fda55a9e6","iteration":"d0e48a13-e906-4af2-9f4c-15d79e3b4576","created":"2020-10-14T13:48:41.671Z","predictions":[{"probability":0.999876738,"tagId":"b5bd1d3a-dbcd-4b0d-ad0b-3f8d7b12fbea","tagName":"Lentigo"},{"probability":0.0001100349,"tagId":"c69433ef-4630-4e0f-8077-2de485483323","tagName":"Acne Cystic"},{"probability":1.29300688E-05,"tagId":"2102157b-b250-4c3d-bf2a-588cda8e93eb","tagName":"Rosacea"},{"probability":1.10303489E-07,"tagId":"ea68f8e7-b50f-4ca0-88dc-c2c8f3bb6823","tagName":"Herpes"},{"probability":9.26677259E-08,"tagId":"29c5c735-90f7-48ff-b23c-545be3325e9e","tagName":"Acne Pustular"},{"probability":7.811148E-08,"tagId":"579b080c-4ab1-405f-a8bd-5bf32efd9b70","tagName":"Melasma"},{"probability":3.90258634E-08,"tagId":"8340afdd-b758-46b4-9aee-754480437f0e","tagName":"Acne Comedo"},{"probability":1.49268364E-09,"tagId":"b89f964a-1a72-41ec-b8b7-8e0d7e9ef8ff","tagName":"Eczema"}]}'
谁能帮帮我吗??我想使用 img url 调用这个端点
感谢您给我宝贵的时间来解决我的问题。