发布于 2019-07-12 04:12:47
这些图像可以通过培训API中的QueryPredictions
API获得。
其余的文档是这里。
Python文档是这里。
下面是您的代码的样子:
from azure.cognitiveservices.vision.customvision.training import CustomVisionTrainingClient
from azure.cognitiveservices.vision.customvision.training.models import PredictionQueryToken
# Set your region
endpoint = 'https://<your region>.api.cognitive.microsoft.com'
# Set your Training API key
training_key = '<your training key>'
# Set your Project ID
project_id = '<your project id>'
# Query the stored prediction images
trainer = CustomVisionTrainingClient(training_key, endpoint=endpoint)
token = PredictionQueryToken()
response = trainer.query_predictions(project_id, token)
# Get the image URLs, for example
urls = [result.original_image_uri for result in response.results]
发布于 2019-07-05 08:37:09
在您的描述中,API引用的链接似乎不正确。有几个版本的Azure Microsoft自定义视觉API如下图所示,您可以参考https://<your region, such as southcentralus>.dev.cognitive.microsoft.com/docs/services/?page=2
来查看它们,用于获取培训图像的API属于培训阶段。
因此,如果您想获得培训图像的urls,首先您需要了解您现在使用的自定义视觉培训的哪个版本。如我所知,您可以在Azure门户上的订阅的Overview
& Quick start
选项卡上看到版本信息。例如,我的自定义愿景是1.0
,如下图所示。
图1. Overview
选项卡
图2. Quick start
选项卡,并单击API reference
查看与该版本相关的文档。
因此,我可以看到有三个API满足了您的需求,如下图所示。
下面是通过GetAllTaggedImages
(v1.0)列出所有标记图像的示例代码。
import requests
projectId = "<your project id from project settings of Cognitive portal>"
endpoint = f"https://southcentralus.api.cognitive.microsoft.com/customvision/v1.0/Training/projects/{projectId}/images/tagged/all"
print(endpoint)
headers = {
'Training-key': '<key from keys tab of Azure portal or project settings of Cognitive portal>',
}
resp = requests.get(endpoint, headers=headers)
print(resp.text)
import json
images = json.loads(resp.text)
image_urls = (image['ImageUri'] for image in images)
for image_url in image_urls:
print(image_url)
希望能帮上忙。
https://stackoverflow.com/questions/56869528
复制相似问题