gpt4 book ai didi

azure - Microsoft Azure Custom Vision Python SDK - 使用计算机中的图像文件进行预测

转载 作者:行者123 更新时间:2023-12-02 23:06:45 27 4
gpt4 key购买 nike

https://learn.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/python-tutorial

我按照上述教程使用 Azure 自定义视觉 Python SDK。我不想使用互联网上的图像进行预测(如教程中所示),而是想使用计算机中的图像文件。我怎样才能做到这一点?谢谢!

最佳答案

Github 项目中有一个为您提到的教程托管的示例:

它用于对象检测,但分类的调用相同,区别在于结果的内容(这里有 bounding_box 项,因为对象检测是预测图像中的区域):

def predict_project(prediction_key, project, iteration):
predictor = CustomVisionPredictionClient(prediction_key, endpoint=ENDPOINT)

# Open the sample image and get back the prediction results.
with open(os.path.join(IMAGES_FOLDER, "Test", "test_od_image.jpg"), mode="rb") as test_data:
results = predictor.predict_image(project.id, test_data, iteration.id)

# Display the results.
for prediction in results.predictions:
print ("\t" + prediction.tag_name + ": {0:.2f}%".format(prediction.probability * 100), prediction.bounding_box.left, prediction.bounding_box.top, prediction.bounding_box.width, prediction.bounding_box.height)

在此处查看来源:https://github.com/Azure-Samples/cognitive-services-python-sdk-samples/blob/master/samples/vision/custom_vision_object_detection_sample.py#L122

关于azure - Microsoft Azure Custom Vision Python SDK - 使用计算机中的图像文件进行预测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54839576/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com