Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan CreateDataset
dengan AWS SDK
Contoh kode berikut menunjukkan cara menggunakanCreateDataset
.
Untuk informasi selengkapnya, lihat Membuat kumpulan data Anda.
- Python
-
- SDKuntuk Python (Boto3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. class Datasets: @staticmethod def create_dataset(lookoutvision_client, project_name, manifest_file, dataset_type): """ Creates a new Lookout for Vision dataset :param lookoutvision_client: A Lookout for Vision Boto3 client. :param project_name: The name of the project in which you want to create a dataset. :param bucket: The bucket that contains the manifest file. :param manifest_file: The path and name of the manifest file. :param dataset_type: The type of the dataset (train or test). """ try: bucket, key = manifest_file.replace("s3://", "").split("/", 1) logger.info("Creating %s dataset type...", dataset_type) dataset = { "GroundTruthManifest": {"S3Object": {"Bucket": bucket, "Key": key}} } response = lookoutvision_client.create_dataset( ProjectName=project_name, DatasetType=dataset_type, DatasetSource=dataset, ) logger.info("Dataset Status: %s", response["DatasetMetadata"]["Status"]) logger.info( "Dataset Status Message: %s", response["DatasetMetadata"]["StatusMessage"], ) logger.info("Dataset Type: %s", response["DatasetMetadata"]["DatasetType"]) # Wait until either created or failed. finished = False status = "" dataset_description = {} while finished is False: dataset_description = lookoutvision_client.describe_dataset( ProjectName=project_name, DatasetType=dataset_type ) status = dataset_description["DatasetDescription"]["Status"] if status == "CREATE_IN_PROGRESS": logger.info("Dataset creation in progress...") time.sleep(2) elif status == "CREATE_COMPLETE": logger.info("Dataset created.") finished = True else: logger.info( "Dataset creation failed: %s", dataset_description["DatasetDescription"]["StatusMessage"], ) finished = True if status != "CREATE_COMPLETE": message = dataset_description["DatasetDescription"]["StatusMessage"] logger.exception("Couldn't create dataset: %s", message) raise Exception(f"Couldn't create dataset: {message}") except ClientError: logger.exception("Service error: Couldn't create dataset.") raise
-
Untuk API detailnya, lihat CreateDataset AWSSDKReferensi Python (Boto3). API
-
Tindakan
CreateModel