Beispiel #1
0
# set up connection
vc = vis.Connection('../../config.yaml')

# GLOBALS
ANN_TYPE_ID = 4  # Use the dedicated test type
API_KEY_ID = 2  # Change this to your own key
ANN_INST_ID = 1135  # Change this to your own annotation instance

# To find your API keys, the following will return a list:
resp = vc.call('api_keys')
# then pick the 'id' of the API key you want to use

## create a new hit type
# set up the qualification requirements
qual_reqs = vis.yaml_field([
    vis.qual_field("00000000000000000071", "US", "eql"),  # US workers only
    vis.qual_field("000000000000000000L0", "95", "gte")
])  # >95% appr. rate
# create the hit type on the Visipedia server, but don't register it yet
resp = vc.call('hit_types',
               'create',
               params={
                   'identifier': 'Example Presence/Absence HIT',
                   'title': 'Example Test HIT',
                   'description': 'Test HIT to see if API works.',
                   'keywords': 'images,labeling,test,example',
                   'reward': 1,
                   'assignment_duration': 500,
                   'auto_approval_delay': 2592000,
                   'annotation_type_id': ANN_TYPE_ID,
                   'api_key_id': API_KEY_ID,
                   'sandbox': 1,
Beispiel #2
0
# set up connection
vc = vis.Connection('../../config.yaml')

# GLOBALS
ANN_TYPE_ID = 4 # Use the dedicated test type
API_KEY_ID = 2 # Change this to your own key
ANN_INST_ID = 1135 # Change this to your own annotation instance

# To find your API keys, the following will return a list:
resp = vc.call('api_keys')
# then pick the 'id' of the API key you want to use

## create a new hit type
# set up the qualification requirements
qual_reqs = vis.yaml_field(
    [vis.qual_field("00000000000000000071", "US", "eql"),  # US workers only
     vis.qual_field("000000000000000000L0", "95", "gte")]) # >95% appr. rate
# create the hit type on the Visipedia server, but don't register it yet
resp = vc.call('hit_types', 'create', 
                params={'identifier' : 'Example Presence/Absence HIT',
                        'title' : 'Example Test HIT',
                        'description' : 'Test HIT to see if API works.',
                        'keywords' : 'images,labeling,test,example',
                        'reward' : 1,
                        'assignment_duration' : 500,
                        'auto_approval_delay' : 2592000,
                        'annotation_type_id' : ANN_TYPE_ID,
                        'api_key_id' : API_KEY_ID,
                        'sandbox' : 1,
                        'qualification_requirement' : qual_reqs,
                        'register' : 0})
## create a new annotation type version
# use a dedicated annotation type for testing the other functionality
ID = 4  # don't remove this annotation_type -- it is used for testing...
resp = vc.call(
    "annotation_type_versions",
    "create",
    params={"annotation_type_id": ID},
    files=[("code", vis.folder_field("presence_absence"))],
)
annotation_type_version_id = resp.content["id"]

## create an instance for the annotation type
# format the parameters for the instance
# NOTE: you must format them EXACTLY like you want them to appear in the
#       javascript code!
prm = vis.yaml_field(
    {
        "object_name": "'Foo Bird'",
        "wikipedia_url": "'http://en.wikipedia.org/wiki/Foo'",
        "example_ids": "[1001, 1002, 1003]",
    }
)
# create the instance
resp = vc.call(
    "annotation_instances",
    "create",
    params={"annotation_type_version_id": annotation_type_version_id, "name": "Foo Bird Example", "parameters": prm},
)
annotation_instance_id = resp.content["id"]
Beispiel #4
0
resp = vc.call('annotation_types', 'destroy', id=annotation_type_id)

## create a new annotation type version
# use a dedicated annotation type for testing the other functionality
ID = 4  # don't remove this annotation_type -- it is used for testing...
resp = vc.call('annotation_type_versions',
               'create',
               params={
                   'annotation_type_id': ID,
               },
               files=[('code', vis.folder_field('presence_absence'))])
annotation_type_version_id = resp.content['id']

## create an instance for the annotation type
# format the parameters for the instance
# NOTE: you must format them EXACTLY like you want them to appear in the
#       javascript code!
prm = vis.yaml_field({
    "object_name": "'Foo Bird'",
    "wikipedia_url": "'http://en.wikipedia.org/wiki/Foo'",
    "example_ids": '[1001, 1002, 1003]'
})
# create the instance
resp = vc.call('annotation_instances',
               'create',
               params={
                   'annotation_type_version_id': annotation_type_version_id,
                   'name': 'Foo Bird Example',
                   'parameters': prm
               })
annotation_instance_id = resp.content['id']