Skip to content

coactive

Coactive api allows you to interact will all aspects of the coactive platform and functionality.

  • Package version: 0.1.24

Requirements.

Python >=3.6

Installation & Usage

pip install

pip install coactive

Then import the package:

import coactive

Setuptools

Install via Setuptools.

python setup.py install --user
(or sudo python setup.py install to install the package for all users)

Then import the package:

import coactive

Getting Started

Please follow the installation procedure and then run the following:

import time
import coactive
from coactive.apis import ClassificationApi
from coactive.models import (
    ClassificationRequest,
    ClassificationResponse,
    CustomClassificationResponse,
    ErrorResponse,
    HTTPValidationError,
    TextDetectionRequest,
    TextDetectionResponse,
    VisualSafetyClassificationRequest,
    VisualSafetyClassificationResponse,
)
# 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 = ClassificationApi(api_client)
    classification_request = ClassificationRequest(
        embedding_id="b78a6e5f-5434-46c4-9e4f-ded092147584",
        concept_id="428e52cd-7ceb-490c-ae3f-0848c82d8c97",
        embedding_vectors=[
            ClassificationEmbeddingVectorRequest(
                embedding_vector=[0.15,1.32,0.19],
                external_id="some-id",
            ),
        ],
        paths=["s3://your-s3-bucket/path/to/image.jpg","https://example.com/path/to/image.jpg"],
    ) 
    threshold = 0.5  # (optional) (default to 0.5)

    try:
        # Classify assets by embedding id
        api_response = api_instance.classify_assets(classification_request, threshold=threshold)
        print(api_response)
    except coactive.ApiException as e:
        print("Exception when calling ClassificationApi->classify_assets: %s\n" % e)

Documentation for API Endpoints

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

Class Method HTTP request Description
ClassificationApi classify_assets POST /api/v0/classify/assets Classify assets by embedding id
ClassificationApi classify_assets_custom_model POST /api/v0/classify/assets/custom/{model_name} Classify list of assets by embedding id and a custom model
ClassificationApi classify_assets_file POST /api/v0/classify/assets/file Classify assets by embedding id
ClassificationApi classify_assets_for_visual_safety POST /api/v0/classify/assets/visual-safety Classify a list of assets for visual safety
ClassificationApi classify_assets_for_visual_safety_file POST /api/v0/classify/assets/visual-safety/file Classify a list of assets for visual safety
ClassificationApi detect_text POST /api/v0/classify/assets/text-detect Detect if there is text in a list of assets.
ClassificationApi detect_text_file POST /api/v0/classify/assets/text-detect/file Detect if there is text in a list of assets.
ConceptApi create_concept POST /api/v0/concepts Create a new concept
ConceptApi delete_concept DELETE /api/v0/concepts/{concept_id} Delete concept by id
ConceptApi get_concept GET /api/v0/concepts/{concept_id} Get concept by id
ConceptApi get_concepts GET /api/v0/concepts Get paginated concepts
ConceptApi get_concepts_by_embedding GET /api/v0/embeddings/{embedding_id}/concepts Get concepts by embedding id
ConceptApi update_concept_by_id PATCH /api/v0/concepts/{concept_id} Update concept by id
ConceptApi validate_concept_name POST /api/v0/concepts/validate-name Validate concept name
CredentialsApi add_aws_credentials POST /api/v0/credentials/aws Add AWS credentials that can be used to fetch data from a cloud provider
CredentialsApi add_gcp_credentials POST /api/v0/credentials/gcp Add GCP credentials that can be used to fetch data from a cloud provider
CredentialsApi test_configuration POST /api/v0/credentials/credentials/test Test the role associated with the credentials is configured to access a data path
DatasetApi add_assets_to_dataset POST /api/v0/datasets/{dataset_id}/assets Add assets to an existing dataset
DatasetApi create_dataset POST /api/v0/datasets Create a new dataset
DatasetApi delete_dataset DELETE /api/v0/datasets/{dataset_id} Delete dataset by id
DatasetApi get_available_encoders GET /api/v0/encoders Get all available encoders
DatasetApi get_dataset GET /api/v0/datasets/{dataset_id} Get dataset by id
DatasetApi get_dataset_images GET /api/v0/datasets/{dataset_id}/images Get images by dataset id
DatasetApi get_dataset_videos GET /api/v0/datasets/{dataset_id}/videos Get videos by dataset id
DatasetApi get_datasets GET /api/v0/datasets Get all datasets paginated
DatasetApi update_dataset PATCH /api/v0/datasets/{dataset_id} Update dataset by id
DatasetApi update_metadata_for_assets POST /api/v0/datasets/{dataset_id}/assets_metadata Update asset metadata in an existing dataset
EmbeddingApi get_embedding_by_id GET /api/v0/embeddings/{embedding_id} Get embedding by id
EmbeddingApi get_embeddings_by_dataset_id GET /api/v0/datasets/{dataset_id}/embeddings Get embeddings by dataset id
EmbeddingApi get_encoder_for_embedding GET /api/v0/embeddings/{embedding_id}/encoder Get encoder for embedding
EmbeddingApi update_embedding_by_id PATCH /api/v0/embeddings/{embedding_id} Update embedding by id
ImageApi get_metadata_for_image GET /api/v0/images/{coactive_image_id}/metadata Get metadata for image
ImageApi get_metadata_for_images GET /api/v0/images/metadata Get metadata for images
ImageApi get_statuses_for_images GET /api/v0/datasets/{dataset_id}/images/statuses Get statuses for images
LabelApi get_concept_labels GET /api/v0/concepts/{concept_id}/labels Get labels for the concept
LabelApi get_label_candidates_for_concept GET /api/v0/concepts/{concept_id}/candidates Get candidates to label for the concept
LabelApi update_concept_labels PATCH /api/v0/concepts/{concept_id}/labels Update labels of a concept
LabelApi upload_concept_labels_from_csv POST /api/v0/concepts/{concept_id}/labels/csv Add labels to a concept from a CSV file
QueryApi delete_query_by_id DELETE /api/v0/queries/{query_id} Delete query by id
QueryApi execute_query POST /api/v0/queries Create and enqueue a SQL query
QueryApi get_queries GET /api/v0/queries Get paginated list of queries
QueryApi get_query_by_id GET /api/v0/queries/{query_id} Get query by id, including results
QueryApi get_query_results_csv GET /api/v0/queries/{query_id}/csv Get query results in CSV format
QueryApi get_query_results_csv_download_url GET /api/v0/queries/{query_id}/csv/url Get a url to download query results in CSV format
QueryApi stop_query_execution POST /api/v0/queries/{query_id}/stop Stop query execution
SimilaritySearchApi get_similar_images POST /api/v0/similarity-search/embeddings/{embedding_id}/search Get similar images
SimilaritySearchApi get_similar_images_grouped POST /api/v0/similarity-search/embeddings/{embedding_id}/grouped-search Get similar images grouped by the group by key
SimilaritySearchApi get_similar_images_grouped_semantic POST /api/v0/similarity-search/embeddings/{embedding_id}/grouped-search/semantic Get similar images grouped by the group by key and semantic notion of metadata
SimilaritySearchApi search_images_by_text_grouped GET /api/v0/similarity-search/similarity-search/embeddings/{embedding_id}/grouped-search/text Get similar images grouped by the group by key and semantic notion of the text query

Documentation For Models

Documentation For Authorization

HTTPBearer

  • Type: Bearer authentication

Author