Skip to content

LabelApi

All URIs are relative to https://app.coactive.ai

Method HTTP request Description
get_concept_labels GET /api/v0/concepts/{concept_id}/labels Get labels for the concept
get_label_candidates_for_concept GET /api/v0/concepts/{concept_id}/candidates Get candidates to label for the concept
update_concept_labels PATCH /api/v0/concepts/{concept_id}/labels Update labels of a concept
upload_concept_labels_from_csv POST /api/v0/concepts/{concept_id}/labels/csv Add labels to a concept from a CSV file

get_concept_labels

PagedConceptLabelsResponse get_concept_labels(concept_id)

Get labels for the concept

Example

  • Bearer Authentication (HTTPBearer):
import time
import coactive
from coactive.apis import LabelApi
from coactive.model.paged_concept_labels_response import PagedConceptLabelsResponse
from coactive.model.http_validation_error import HTTPValidationError
from coactive.model.error_response import ErrorResponse
from coactive.model.label_enum import LabelEnum

# Defining the host is optional and defaults to https://app.coactive.ai.

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Example with auth is provided below, use the example that
# satisfies your auth use case.


# Configure Bearer authorization: HTTPBearer


# See configuration.py for a list of all supported configuration parameters.

from YOUR_ENV import CLIENT_ID, CLIENT_SECRET


configuration = coactive.Configuration(
    host = "https://app.coactive.ai",
    access_token = f"{CLIENT_ID}:{CLIENT_SECRET}",
)

# Enter a context with an instance of the API client
with coactive.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = LabelApi(api_client)
    concept_id = "428e52cd-7ceb-490c-ae3f-0848c82d8c97"
    offset = 0 # (optional) if omitted the server will use the default value of 0
    limit = 100 # (optional) if omitted the server will use the default value of 100
    labels_to_include = [
        LabelEnum("["1"]"),
    ] # (optional)

    # example passing only required values which don't have defaults set
    try:
        # Get labels for the concept
        api_response = api_instance.get_concept_labels(concept_id)
        print(api_response)
    except coactive.ApiException as e:
        print("Exception when calling LabelApi->get_concept_labels: %s\n" % e)

    # example passing only required values which don't have defaults set
    # and optional values
    try:
        # Get labels for the concept
        api_response = api_instance.get_concept_labels(concept_id, offset=offset, limit=limit, labels_to_include=labels_to_include)
        print(api_response)
    except coactive.ApiException as e:
        print("Exception when calling LabelApi->get_concept_labels: %s\n" % e)

Parameters

Name Type Description Notes
concept_id str The unique identifier for the concept
offset int, none_type Starting index to return [optional] if omitted the server will use the default value of 0
limit int, none_type Max number of items to return [optional] if omitted the server will use the default value of 100
labels_to_include [LabelEnum], none_type List of labels types to include, leave blank to return all [optional]

Return type

PagedConceptLabelsResponse

Authorization

HTTPBearer

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Paginated labels for the concept -
403 Authentication error -
401 Unauthorized -
404 Concept not found -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to home]

get_label_candidates_for_concept

CandidatesToLabelResponse get_label_candidates_for_concept(concept_id)

Get candidates to label to help refine the concept

Example

  • Bearer Authentication (HTTPBearer):
import time
import coactive
from coactive.apis import LabelApi
from coactive.model.http_validation_error import HTTPValidationError
from coactive.model.error_response import ErrorResponse
from coactive.model.candidates_to_label_response import CandidatesToLabelResponse

# Defining the host is optional and defaults to https://app.coactive.ai.

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Example with auth is provided below, use the example that
# satisfies your auth use case.


# Configure Bearer authorization: HTTPBearer


# See configuration.py for a list of all supported configuration parameters.

from YOUR_ENV import CLIENT_ID, CLIENT_SECRET


configuration = coactive.Configuration(
    host = "https://app.coactive.ai",
    access_token = f"{CLIENT_ID}:{CLIENT_SECRET}",
)

# Enter a context with an instance of the API client
with coactive.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = LabelApi(api_client)
    concept_id = "428e52cd-7ceb-490c-ae3f-0848c82d8c97"

    # example passing only required values which don't have defaults set
    try:
        # Get candidates to label for the concept
        api_response = api_instance.get_label_candidates_for_concept(concept_id)
        print(api_response)
    except coactive.ApiException as e:
        print("Exception when calling LabelApi->get_label_candidates_for_concept: %s\n" % e)

Parameters

Name Type Description Notes
concept_id str The concept id to get candidates to label

Return type

CandidatesToLabelResponse

Authorization

HTTPBearer

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Candidates to label to help refine the concept -
403 Authentication error -
401 Unauthorized -
404 Concept not found -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to home]

update_concept_labels

bool, date, datetime, dict, float, int, list, str, none_type update_concept_labels(concept_id, update_concept_labels_request)

Update labels of a concept

Example

  • Bearer Authentication (HTTPBearer):
import time
import coactive
from coactive.apis import LabelApi
from coactive.model.update_concept_labels_request import UpdateConceptLabelsRequest
from coactive.model.http_validation_error import HTTPValidationError
from coactive.model.error_response import ErrorResponse

# Defining the host is optional and defaults to https://app.coactive.ai.

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Example with auth is provided below, use the example that
# satisfies your auth use case.


# Configure Bearer authorization: HTTPBearer


# See configuration.py for a list of all supported configuration parameters.

from YOUR_ENV import CLIENT_ID, CLIENT_SECRET


configuration = coactive.Configuration(
    host = "https://app.coactive.ai",
    access_token = f"{CLIENT_ID}:{CLIENT_SECRET}",
)

# Enter a context with an instance of the API client
with coactive.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = LabelApi(api_client)
    concept_id = "428e52cd-7ceb-490c-ae3f-0848c82d8c97"
    update_concept_labels_request = UpdateConceptLabelsRequest(
        labels=[
            ConceptLabelRequest(
                coactive_image_id="a6894d72-612d-4c20-b4d0-8f3f21c2bb10",
                image_path="s3://your-s3-bucket/path/to/image.jpg",
                label=LabelEnum("1"),
            ),
        ],
    )

    # example passing only required values which don't have defaults set
    try:
        # Update labels of a concept
        api_response = api_instance.update_concept_labels(concept_id, update_concept_labels_request)
        print(api_response)
    except coactive.ApiException as e:
        print("Exception when calling LabelApi->update_concept_labels: %s\n" % e)

Parameters

Name Type Description Notes
concept_id str The concept id of the labels to modify
update_concept_labels_request UpdateConceptLabelsRequest

Return type

bool, date, datetime, dict, float, int, list, str, none_type

Authorization

HTTPBearer

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 The success of the update labels patch -
403 Authentication error -
401 Unauthorized -
404 Concept version not found -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to home]

upload_concept_labels_from_csv

bool, date, datetime, dict, float, int, list, str, none_type upload_concept_labels_from_csv(concept_id, file)

Add labels to a concept from a CSV file

Example

  • Bearer Authentication (HTTPBearer):
import time
import coactive
from coactive.apis import LabelApi
from coactive.model.http_validation_error import HTTPValidationError
from coactive.model.error_response import ErrorResponse

# Defining the host is optional and defaults to https://app.coactive.ai.

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Example with auth is provided below, use the example that
# satisfies your auth use case.


# Configure Bearer authorization: HTTPBearer


# See configuration.py for a list of all supported configuration parameters.

from YOUR_ENV import CLIENT_ID, CLIENT_SECRET


configuration = coactive.Configuration(
    host = "https://app.coactive.ai",
    access_token = f"{CLIENT_ID}:{CLIENT_SECRET}",
)

# Enter a context with an instance of the API client
with coactive.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = LabelApi(api_client)
    concept_id = "428e52cd-7ceb-490c-ae3f-0848c82d8c97"
    file = open('/path/to/file', 'rb')

    # example passing only required values which don't have defaults set
    try:
        # Add labels to a concept from a CSV file
        api_response = api_instance.upload_concept_labels_from_csv(concept_id, file)
        print(api_response)
    except coactive.ApiException as e:
        print("Exception when calling LabelApi->upload_concept_labels_from_csv: %s\n" % e)

Parameters

Name Type Description Notes
concept_id str The concept to add labels
file file_type A CSV file with columns: 'path', 'coactive_image_id', 'image_path', 'video_path', or 'coactive_video_id' to identify the assets to label, and a 'label' column with values '0' or '1' to indicate whether the associated asset is a negative or positive example of the concept, respectively. If videos identified by 'video_path' or 'coactive_video_id' are present in the CSV, a column 'frame_timestamp_ms' must also be present to determine the timestamp of the relevant frame from the beginning of the video in milliseconds.

Return type

bool, date, datetime, dict, float, int, list, str, none_type

Authorization

HTTPBearer

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 The concept was successfully updated -
403 Authentication error -
401 Unauthorized -
404 Concept not found -
400 The file must be a CSV -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to home]