コード例 #1
0
def launch_verify_question_answer(data,
                                  reward=1.00,
                                  tasks_per_hit=50,
                                  sandbox=False):
    """Launches HITs to ask workers to verify bounding boxes.

    Args:
        data: List containing image urls, questions and answers, for the task.
        reward: A postive valued dollar amount per task.
        tasks_per_hit: Number of images per hit.
        sandbox: Whether to interact on sandbox or production.

    Returns:
        A list of hit ids that have been launched.
    """
    et = EasyTurk(sandbox=sandbox)
    template = 'verify_question_answer.html'
    hit_ids = []
    i = 0
    while i < len(data):
        hit = et.launch_hit(
            template,
            data[i:i + tasks_per_hit],
            reward=reward,
            title='Verify the answer to a question about an picture',
            description=
            ('Verify whether an answer to a question about a picture is correct.'
             ),
            keywords='image, text, picture, answer, question, relationship')
        hit_id = hit['HIT']['HITId']
        hit_ids.append(hit_id)
        i += tasks_per_hit
    return hit_ids
コード例 #2
0
def launch_verify_bbox(data, reward=1.00, tasks_per_hit=30, sandbox=False):
    """Launches HITs to ask workers to verify bounding boxes.

    Args:
        data: List containing image urls, objects, for the task.
        reward: A postive valued dollar amount per task.
        tasks_per_hit: Number of images per hit.
        sandbox: Whether to interact on sandbox or production.

    Returns:
        A list of hit ids that have been launched.
    """
    et = EasyTurk(sandbox=sandbox)
    template = 'verify_bbox.html'
    hit_ids = []
    i = 0
    while i < len(data):
        hit = et.launch_hit(
            template,
            data[i:i + tasks_per_hit],
            reward=reward,
            title='Verify objects in pictures',
            description=(
                'Verify whether objects are correctly identified in pictures.'
            ),
            keywords='image, text, picture, object, bounding box')
        hit_id = hit['HIT']['HITId']
        hit_ids.append(hit_id)
        i += tasks_per_hit
    return hit_ids
コード例 #3
0
def launch_guesswhich(num_hits, reward=1.00, tasks_per_hit=10, sandbox=False):
    """Launches HITs to ask workers to caption images.

    Args:
        data: List containing image urls for the task.
        reward: A postive valued dollar amount per task.
        tasks_per_hit: Number of images per hit.
        sandbox: Whether to interact on sandbox or production.

    Returns:
        A list of hit ids that have been launched.
    """
    et = EasyTurk(sandbox=sandbox)
    template = 'guesswhich/index_et.html'
    hit_ids = []
    all_task_data = configure_guesswhich_tasks(num_hits,
                                               tasks_per_hit,
                                               debug=False)
    i = 0
    while i < len(all_task_data):
        hit = et.launch_hit_unicode(
            #template, all_task_data[i:i+tasks_per_hit], reward=reward,
            template,
            all_task_data[i:i + tasks_per_hit][0],
            reward=reward,
            title='Guess Which game with chatbot',
            description=
            ('Play interactive \'Guess Which\' image guessing game with a chatbot.'
             ),
            keywords='image, questions, chatbot, guessing',
            frame_height=0)
        hit_id = hit['HIT']['HITId']
        hit_ids.append(hit_id)
        i += tasks_per_hit
    return hit_ids
コード例 #4
0
def launch_caption(data, reward=1.00, tasks_per_hit=10, sandbox=False):
    """Launches HITs to ask workers to caption images.

    Args:
        data: List containing image urls for the task.
        reward: A postive valued dollar amount per task.
        tasks_per_hit: Number of images per hit.
        sandbox: Whether to interact on sandbox or production.

    Returns:
        A list of hit ids that have been launched.
    """
    et = EasyTurk(sandbox=sandbox)
    template = 'write_caption.html'
    hit_ids = []
    i = 0
    while i < len(data):
        hit = et.launch_hit(
            template,
            data[i:i + tasks_per_hit],
            reward=reward,
            title='Caption some pictures',
            description=('Write captions about the contents of images.'),
            keywords='image, caption, text')
        hit_id = hit['HIT']['HITId']
        hit_ids.append(hit_id)
        i += tasks_per_hit
    return hit_ids
コード例 #5
0
ファイル: interface.py プロジェクト: kayburns/easyturk
def launch_minecraft(data, reward=0.00, tasks_per_hit=10, sandbox=True):
    """Launches HITs to ask workers to caption images.

    Args:
        data: List containing image urls for the task.
        reward: A postive valued dollar amount per task.
        tasks_per_hit: Number of images per hit.
        sandbox: Whether to interact on sandbox or production.

    Returns:
        A list of hit ids that have been launched.
    """
    et = EasyTurk(sandbox=sandbox)
    template = 'minecraft.html'
    hit_ids = []
    i = 0
    while i < len(data):
        hit = et.launch_hit(
            template, data[i:i+tasks_per_hit], reward=reward,
            title='Build houses with a dialogue agent in Minecraft.',
            description=('Must have Minecraft 1.12 already installed! We ' \
                'can\'t reimburse cost of Minecraft, so please accept only ' \
                'if you have already purchased it for yourself in the past.'),
            keywords='bots, dialogue, minecraft, games')
        hit_id = hit['HIT']['HITId']
        hit_ids.append(hit_id)
        i += tasks_per_hit
    return hit_ids
コード例 #6
0
ファイル: clean.py プロジェクト: ANarcomey/easyturk
def main(args):
    use_sandbox = False if args.prod else True
    et = EasyTurk(sandbox=use_sandbox)
    online_hits = et.list_hits()

    for i, hit in enumerate(online_hits):
        #print("HIT {} of {} has title {}".format(i, len(online_hits), hit['Title']))
        if hit['Title'] == args.target_title:
            print("HIT {} should be deleted. Title={}, Description={}".format(
                hit['HITId'], hit['Title'], hit['Description']))
            if args.delete_without_ask:
                print("Deleting HIT {}".format(hit['HITId']))
                et.delete_hit(hit['HITId'])
コード例 #7
0
def main(args):
    use_sandbox = False if args.prod else True
    et = EasyTurk(sandbox=use_sandbox)
    hits_filename = args.json_path

    if os.path.exists(hits_filename):

        current_hits = json.load(open(hits_filename, 'r'))
        remaining_hits = []
        for hit in current_hits:
            success = et.delete_hit(hit)
            if not success: remaining_hits.append(hit)
        json.dump(remaining_hits, open(hits_filename, 'w'))
        print("Remaining hits on {}: \n{}".format(hits_filename,
                                                  remaining_hits))
    else:
        print("No hits to delete from {}".format(hits_filename))
コード例 #8
0
ファイル: interface.py プロジェクト: hyzcn/easyturk
def fetch_completed_hits(hit_ids, approve=True):
    """Grabs the results for the hit ids.

    Args:
        hit_ids: A list of hit ids to fetch.
        approve: Whether to approve the hits that have been submitted.

    Returns:
        A dictionary from hit_id to the result, if that hit_id has
        been submitted.
    """
    et = EasyTurk()
    output = {}
    for hit_id in hit_ids:
        results = et.get_results(hit_id, reject_on_fail=False)
        if len(results) > 0:
            output[hit_id] = results
            if approve:
                for assignment in results:
                    assignment_id = assignment['assignment_id']
                    et.approve_assignment(assignment_id)
    return output
コード例 #9
0
ファイル: review.py プロジェクト: ANarcomey/easyturk
def main(args):
	use_sandbox = False if args.prod else True
	et = EasyTurk(sandbox=use_sandbox)

	hits_filename = args.json_path
	if os.path.exists(hits_filename):
	    current_hits = json.load(open(hits_filename,'r'))
	    print("Loaded results for {} hits from {}.".format(len(current_hits), hits_filename))

	    progress = et.show_hit_progress(current_hits)
	    print("Retrieved progress for {} hits.".format(len(progress)))
	
	    results = interface.fetch_completed_hits(current_hits, approve=False, sandbox=use_sandbox)
	    print("Loaded results for {} hits from {}. Retrived {} results.".format(len(current_hits), hits_filename, len(results)))
	    if args.breakpoint:
	    	pdb.set_trace()
	    else:
	    	print("Results:\n{}".format(results))
	    	print("Progress:\n{}".format(progress))


	else:
	    print("No hits to review from {}".format(hits_filename))  
コード例 #10
0
ファイル: evaluate.py プロジェクト: vaibhavad/easyturk
def interface():
    """Endpoint that rejects and approves work.
    """
    et = EasyTurk(sandbox=False)
    if request.method != 'POST':
        return 'Fail'
    assignment_ids = json.loads(request.form['assignment_ids'])
    approve = json.loads(request.form['approve'])
    for assignment_id in assignment_ids:
        if approve:
            et.approve_assignment(assignment_id)
        else:
            et.reject_assignment(assignment_id)
    eresults_file = request.form['eresults_file']
    results = json.load(open(eresults_file))
    for hit in results['hits']:
        if hit['assignment_id'] in assignment_ids:
            hit['approve'] = approve
    json.dump(results, open(eresults_file, 'w'))
    return 'Succcess'
コード例 #11
0
ファイル: render.py プロジェクト: ANarcomey/easyturk
#from django.core.urlresolvers import reverse

from interface import configure_guesswhich_tasks
from interface import visualize_guesswhich_task

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--template', required=True)
    parser.add_argument('--output', required=True)

    #parser.add_argument('--specify_config', action='store_true')
    parser.add_argument('--HIT-config-json', type=str)
    args = parser.parse_args()

    # Compile the template.
    et = EasyTurk()
    env = et.get_jinja_env()
    template = env.get_template(args.template)

    #env2 = Environment(extensions=[FragmentCacheExtension])
    #env2.fragment_cache = SimpleCache()
    '''
    from django.templatetags.static import static
    from django.urls import reverse

    from jinja2 import Environment


    def environment(**options):
        env = Environment(**options)
        env.globals.update({