如何使用非公开图像在 AMAZON Mechanical Turk 上创建 HIT?
How to use images that are not publicly available for creating HITs on AMZ mechanical Turk?
我正在将图像分类任务外包给亚马逊的 Mechanical Turk。因此,csv 文件用于存储工作人员用于分类的图像的 url。根据文档中的示例,这些 url 指向的图像需要公开供工作人员访问。
但是,我的数据很敏感,不允许公开托管。我有机会在访问受限的图像上使用 MTurk 吗?
我建议将图像托管在私有 S3 存储桶中,并生成 预签名 URLs,有效期为 expiration
秒。通过这样做,您将允许 MTurk 上的工作人员看到 HIT 图像(通过 预签名 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
我正在将图像分类任务外包给亚马逊的 Mechanical Turk。因此,csv 文件用于存储工作人员用于分类的图像的 url。根据文档中的示例,这些 url 指向的图像需要公开供工作人员访问。
但是,我的数据很敏感,不允许公开托管。我有机会在访问受限的图像上使用 MTurk 吗?
我建议将图像托管在私有 S3 存储桶中,并生成 预签名 URLs,有效期为 expiration
秒。通过这样做,您将允许 MTurk 上的工作人员看到 HIT 图像(通过 预签名 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