【问题标题】:How to use images that are not publicly available for creating HITs on AMZ mechanical Turk?如何使用未公开的图像在 AMAZON Mechanical Turk 上创建 HIT?
【发布时间】:2021-01-04 14:13:50
【问题描述】:

我将图像分类任务外包给亚马逊的 Mechanical Turk。因此,使用 csv 文件存储工人用于分类的图像的 url。根据文档中的示例,这些 url 指向的图像需要公开供工作人员访问。

但是,我的数据是敏感数据,不允许公开托管。我是否有机会在访问受限的图像上使用 MTurk?

【问题讨论】:

    标签: image permissions mturk


    【解决方案1】:

    我建议将图像托管在私有 S3 存储桶中,并生成 presigned URLs,其有效期为 expiration 秒。通过这样做,您将允许 MTurk 上的工作人员查看 HIT 图像(通过 presigned URL),并保证在 expiration 秒后 URL 将过期,不再允许任何人访问敏感数据.

    import logging
    import boto3
    from botocore.exceptions import ClientError
    
    
    def create_presigned_url(bucket: str, key: str, expiration: int):
        """Generate a presigned URL to share an S3 object
    
        :param bucket: name of the bucket
        :param key: key of the object for which to create a presigned URL
        :param expiration: Time in seconds for the presigned URL to remain valid
        :return: Presigned URL as string. If error, returns None.
        """
    
        # Generate a presigned URL for the S3 object
        s3_client = boto3.client('s3')
        try:
            response = s3_client.generate_presigned_url(
                          'get_object',
                           Params={'Bucket': bucket, 'Key': key},
                           ExpiresIn=expiration
                       )
        except ClientError as e:
            logging.error(e)
            return None
    
        # The response contains the presigned URL
        return response
      
    

    有关如何在此处生成预签名 url 的更多信息:https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-presigned-urls.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多