Skip to main content

No project description provided

Project description


title: Python SDK Tutorial for WowDAO short: Python SDK Tutorial type: guide order: 675 meta_title: WowDAO Python SDK Tutorial meta_description: Tutorial documentation for the WowDAO Python SDK that covers how and why to use the SDK to easily include data labeling project creation and annotated task parsing in your data pipeline python scripts for data science and machine learning projects.

You can use the WowDAO Python SDK to make annotating data a more integrated part of your data science and machine learning pipelines. This software development kit (SDK) lets you call the WowDAO API directly from scripts using predefined classes and methods.

With the WowDAO Python SDK, you can perform the following tasks in a Python script:

See the full SDK reference documentation for all available modules, or review the available API endpoints for any tasks that the SDK does not cover.

Start using the WowDAO Python SDK

  1. Install the SDK: pip install wow-ai-sdk
  2. In your Python script, do the following:
    1. Import the SDK.
    2. Define your API key and WowDAO URL (API key is available at Account page).
    3. Connect to the API.
# Define the URL where WowDAO is accessible and the API key for your user account
WOWAI_URL = 'http://localhost:8080'
API_KEY = 'd6f8a2622d39e9d89ff0dfef1a80ad877f4ee9e3'

# Import the SDK and the client module
from wow_ai_sdk import Client

# Connect to the WowDAO API and check the connection
ls = Client(url=WOWAI_URL, api_key=API_KEY)
ls.check_connection()

Create a project with the WowDAO Python SDK

Create a project in WowDAO using the SDK. Specify the project title and the labeling configuration. Choose your labeling configuration based on the type of labeling that you wish to perform. See the available templates for WowDAO projects, or set a blank configuration with <View></View>.

For example, create an audio transcription project in your Python code:

project = ls.start_project(
    title='Object Detection with Bounding Boxes Project',
    label_config='''
    <View>\n  <Image name=\"image\" value=\"$image\"/>\n  <RectangleLabels name=\"label\" toName=\"image\">\n    <Label value=\"Airplane\" background=\"green\"/>\n    <Label value=\"Car\" background=\"blue\"/>\n  </RectangleLabels>\n</View>\n
    '''
)

For more about what you can do with the project module of the SDK, see the project module SDK reference.

Import tasks with the WowDAO Python SDK

You can import tasks from your script using the WowDAO Python SDK.

For a specific project, you can import tasks in WowDAO JSON format or connect to cloud storage providers and import image, audio, or video files directly.

project.import_tasks(
    [
        {'image': 'https://i.imgur.com/HaR6pIZ.jpeg'},
        {'image': 'https://i.imgur.com/WbISHgK.jpeg'}
    ]
)

You can also import predictions:

Add predictions to existing tasks with the WowDAO Python SDK

You can add predictions to existing tasks in WowDAO in your Python script.

For an existing simple image classification project, you can do the following to add predictions of "Dog" for image tasks that you retrieve:

task_ids = project.get_tasks_ids()
project.create_prediction(task_ids[0], result='Dog', score=0.9)

For complex cases, such as object detection with bounding boxes, you can specify structured results:

project.create_prediction(task_ids[1], result={"x": 10, "y": 20, "width": 30, "height": 40, "label": ["Dog"]}, score=0.9)

For another example, see the Jupyter notebook example of importing pre-annotated data.

Import pre-annotated tasks into WowDAO

You can also import predictions together with tasks as pre-annotated tasks. The SDK offers several ways that you can import pre-annotations into WowDAO.

One way is to import tasks in a simple JSON format, where one key in the JSON identifies the data object being labeled, and the other is the key containing the prediction.

In this example, import predictions for an image classification task:

project.import_tasks(
    [{'image': f'https://i.imgur.com/WbISHgK.jpeg', 'label': 'Car'},
    {'image': f'https://i.imgur.com/HaR6pIZ.jpeg', 'label': 'Car'}],
    preannotated_from_fields=['label']
)

The image is specified in the image key using a public URL, and the prediction is referenced in an arbitrary pet key, which is then specified in the preannotated_from_fields() method.

For more examples, see the Jupyter notebook example of importing pre-annotated data.

Prepare and manage data with filters

You can also use the SDK to control how tasks appear in the data manager to annotators or reviewers. You can create custom filters and ordering for the tasks based on parameters that you specify with the SDK. This lets you have more granular control over which tasks in your dataset get labeled or reviewed, and in which order.

Prepare unlabeled data with filters

For example, you can create a filter to prepare tasks to be annotated. For example, if you want annotators to focus on tasks in the first 1000 tasks in a dataset that contain the word "possum" in the field "text" in the task data, do the following:

from wow_ai_sdk.data_manager import Filters, Column, Type, Operator

Filters.create(Filters.AND, [
    Filters.item(
        Column.id,
        Operator.GREATER_OR_EQUAL,
        Type.Number,
        Filters.value(1)
    ),
        Filters.item(
        Column.id,
        Operator.LESS_OR_EQUAL,
        Type.Number,
        Filters.value(1000)
    ),
    Filters.item(
        Column.data(text),
        Operator.CONTAINS,
        Type.String,
        Filters.value("possum")
    )
])

Manage annotations with filters

For example, to create a filter that displays only tasks with an ID greater than 42 or that were annotated between November 1, 2021, and now, do the following:

from wow_ai_sdk.data_manager import Filters, Column, Type, Operator

Filters.create(Filters.OR, [
    Filters.item(
        Column.id,
        Operator.GREATER,
        Type.Number,
        Filters.value(42)
    ),
    Filters.item(
        Column.completed_at,
        Operator.IN,
        Type.Datetime,
        Filters.value(
            datetime(2021, 11, 1),
            datetime.now()
        )
    )
])

You can use this example filter to prepare completed tasks for review in WowDAO.ai

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wow_ai_sdk-0.2.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wow_ai_sdk-0.2.0-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file wow_ai_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: wow_ai_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for wow_ai_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 37996aa01640666b9f52de4c4c0004317a985f76db28d18de8b6c5656b682bcd
MD5 f6647566a39f8bde8ced8077a9516788
BLAKE2b-256 2d643bbbe67e46035f6ab015be56f369bf839eefba75be1dcee9342b684e380f

See more details on using hashes here.

File details

Details for the file wow_ai_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: wow_ai_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for wow_ai_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a02251b676707d62e1a2860f23e9aac405382be5f52de8baf49ead1f3c569738
MD5 459a80d09688dbb66a2b8f74ad662f5b
BLAKE2b-256 44ecf0a769962078b27b99080364420d7844a4c35be1c5f6c237cb86f010e40d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page