开始使用 Lookout for Vision - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

开始使用 Lookout for Vision

以下代码示例演示了如何开始使用 Lookout for Vision。

Python
SDK适用于 Python (Boto3)
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

""" This example shows how to list your Amazon Lookout for Vision projects. If you haven't previously created a project in the current AWS Region, the response is an empty list, however it confirms that you can call the Lookout for Vision API. """ from botocore.exceptions import ClientError import boto3 class Hello: """Hello class for Amazon Lookout for Vision""" @staticmethod def list_projects(lookoutvision_client): """ Lists information about the projects that are in your AWS account and in the current AWS Region. : param lookoutvision_client: A Boto3 Lookout for Vision client. """ try: response = lookoutvision_client.list_projects() for project in response["Projects"]: print("Project: " + project["ProjectName"]) print("ARN: " + project["ProjectArn"]) print() print("Done!") except ClientError as err: print(f"Couldn't list projects. \n{err}") raise def main(): session = boto3.Session(profile_name="lookoutvision-access") lookoutvision_client = session.client("lookoutvision") Hello.list_projects(lookoutvision_client) if __name__ == "__main__": main()
  • 有关API详细信息,请参阅ListProjects中的 AWS SDKPython (Boto3) API 参考。