从 Boto API 获取 Mechanical Turk 任务输入数据(例如示例图像 url)

Get Mechanical Turk task input data (e.g. example image url) from Boto API

当通过 boto API 从 Mechanical Turk 分配中检索结果时,如何查看在创建新批次之前提供的 CSV 中的输入数据?

我能够找到它的唯一方法(除了从原始 CSV 文件中)是从 MTurk 网络仪表板中可用的批处理结果 CSV。

get_assignment() nor get_hit() 似乎都不包含此数据。

我能够通过 API 访问此信息,尽管有些间接。

我应该注意,我正在处理边界框任务,其中所需的输入是每个问题的图像 URL。

调用 get_hit() 时,响应中包含一个 Question 字段,其中包含向工作人员显示的问题的 XML 布局。一些输入数据,包括我正在寻找的图像 URL,可以通过解析此 XML 数据获得。

我使用 BeautifulSoup 来解析 XML:

# Get the assignment
assignment = client.get_assignment(AssignmentId=assignment_id)
# Load the XML for the question, aka task
question_soup = BeautifulSoup(assignment['HIT']['Question'], 'lxml')
task_input = question_soup.find('crowd-bounding-box')
# Extract the image src
image_url = task_input['src']