Home

Bases: BaseModel

A dataset class representing a dataset in the Tenyks platform

Attributes:

NameTypeDescription
client Client The client to interact with the Tenyks API.
workspace_name strName of the workspace the dataset belongs to.
key strKey of the dataset.
name strName of the dataset.
owner strOwner of the dataset.
owner_email EmailStr Owner email of the dataset.
created_at datetime Creation timestamp of the dataset.
images_location Optional [ Union [ AWSLocation , AzureLocation , GCSLocation ]]Directory location of the images of the dataset.
metadata_location Optional [ Union [ AWSLocation , AzureLocation , GCSLocation ]]Directory location of the metadata of the dataset.
categories List [ Category ]Categories/classes of the dataset.
models List Names of the models of the dataset.
status strStatus of the dataset.
n_images intNumber of images in the dataset.
iou_threshold floatIOU threshold set for the dataset.

add_image

add_image ( image_path , annotations = None , tags = None , verbose = False )

Add an image to the dataset along with its annotations and tags.

Parameters:

NameTypeDescriptionDefault
image_pathstrThe path of the image to add.required
annotationsOptional [ List [ Annotation ]]The annotations to add to the image. Defaults to None.None
tagsOptional [ List [ Tag ]]The tags to add to the image. Defaults to None.None
verboseOptional [bool]If True, provides progress updates. Defaults to False.False

count_images

count_images ( filter = None , model_key = None )

Return image count that match the filter criteria.

Parameters:

NameTypeDescriptionDefault
filterOptional [str]Filter conditions for counting. Defaults to None.None
model_keyOptional [str]Model key to filter images. Defaults to None.None

Returns:

NameTypeDescription
intintNumber of images that match the filter criteria.

create_model

create_model ( name , confidence_threshold = None ,iou_threshold = None )

Create a new model for the dataset.

Parameters:

NameTypeDescriptionDefault
namestrThe name of the new model.required
confidence_thresholdOptional [float]The confidence threshold for the model. Defaults to None.None
iou_thresholdOptional [float]The IOU threshold for the model. Defaults to None.None

Returns:

NameTypeDescription
ModelModel The newly created model.

delete_model

delete_model ( key )

Delete a model from the dataset.

Parameters:

NameTypeDescriptionDefault
keystrThe key of the model to delete.required

finetune_search_model

finetune_search_model ( search_query , ground_truth_search_results)

Placeholder method for finetuning search

Parameters:

NameTypeDescriptionDefault
search_querystrsearch query on which to finetune modelrequired
ground_truth_search_resultsList [ Image ]ground truth images that should be retrievedrequired

get_category_by_id

get_category_by_id ( category_id )

Retrieve a category by its ID.

Parameters:

NameTypeDescriptionDefault
category_idintThe ID of the category to retrieve.required

Returns:

NameTypeDescription
CategoryCategory The category corresponding to the given ID.

get_category_by_name

get_category_by_name ( category_name )

Retrieve a category by its name.

Parameters:

NameTypeDescriptionDefault
category_namestrThe name of the category to retrieve.required

Returns:

NameTypeDescription
CategoryCategory The category corresponding to the given name.

get_image_by_key

get_image_by_key ( image_key )

Retrieve an image by its key.

Parameters:

NameTypeDescriptionDefault
image_keystrThe key of the image to retrieve.required

Returns:

NameTypeDescription
ImageImage The image corresponding to the given key.

get_model

get_model ( key )

Retrieve a model by its key.

Parameters:

NameTypeDescriptionDefault
keystrThe key of the model to retrieve.required

Returns:

NameTypeDescription
ModelModel The model corresponding to the given key.

get_model_names

get_model_names ()

Retrieve the names of the models associated with the dataset.

Returns:

TypeDescription
List [str]List[str]: A list of model display names.

get_models

get_models ()

Retrieve the models associated with the dataset.

Returns:

TypeDescription
List [ Model ]List[Model]: A list of models associated with the dataset.

get_tag_by_key

get_tag_by_key ( tag_key )

Retrieve a tag by its key.

Parameters:

NameTypeDescriptionDefault
tag_keystrThe key of the tag to retrieve.required

Returns:

NameTypeDescription
TagTag The tag corresponding to the given key.

get_tag_by_name

get_tag_by_name ( tag_name )

Retrieve a tag by its display name.

Parameters:

NameTypeDescriptionDefault
tag_namestrThe name of the tag to retrieve.required

Returns:

NameTypeDescription
TagTag The tag corresponding to the given display name.

get_tags

get_tags ()

Retrieve the tags associated with the dataset.

Returns:

TypeDescription
List [ Tag ]List[Tag]: A list of tags created for the dataset.

head

head ( n = 5 )

Retrieve the first few images from the dataset.

Parameters:

NameTypeDescriptionDefault
nintThe number of images to retrieve. Defaults to 5.5

Returns:

TypeDescription
List [ Image ]List[Image]: A list of the first n images in the dataset.

images_generator

images_generator (filter = None, sort_by = None, model_key= None, page_size = 250)

Generator to retrieve images from the dataset in a paginated manner.

Parameters:

NameTypeDescriptionDefault
filterOptional [str]Filter conditions for the search. Defaults to None.None
sort_byOptional [str]Sort criteria for the search. Defaults to None.None
model_keyOptional [str]Model key to filter images. Defaults to None.None
page_sizeOptional [int]Number of images per page. Defaults to 250.250

Yields:

NameTypeDescription
GeneratorGenerator A generator yielding images.

ingest

ingest ( import_operation = None , verbose = True )

Trigger the ingestion process for the dataset.

Parameters:

NameTypeDescriptionDefault
import_operationOptional [str]The import operation type. Defaults to None.None
verboseOptional [bool]If True, provides progress updates. Defaults to True.True

save_image_metadata

save_image_metadata ( metadata_key , metadata_values )

Add or update custom metadata for images in a dataset.

Parameters:

NameTypeDescriptionDefault
metadata_keystrThe key representing the type of metadata to be saved. Must contain only alphanumeric characters (no spaces, underscores, or special characters), e.g. brightness.required
metadata_valuesDict [str, Union [int, float]]A dictionary where the keys are image identifiers and the values are the metadata values to be saved (either integer or float).required

Example:

metadata_values = { "image1": 0.75, "image2": 0.85, "image3": 0.65, # More  
image metadata... } dataset.save_image_metadata( metadata_key="brightness",  
metadata_values=metadata_values )

Note: The metadata values are sent to the server in batches of 500 to avoid overwhelming the API. Each batch is processed sequentially, and the method logs the progress of each batch. After all batches are processed, the dataset's metadata key is updated accordingly.

search_images

search_images (n_images = 250, filter = None, sort_by =None,model_key = None)

Perform image search in the dataset based on filters.

Parameters:

NameTypeDescriptionDefault
n_imagesOptional [int]The number of images to retrieve. Defaults to 250.250
filterOptional [str]Filter conditions for the search. Defaults to None.None
sort_byOptional [str]Sort criteria for the search. Defaults to None.None
model_keyOptional [str]Model key to filter images. Defaults to None.None

Returns:

TypeDescription
List [ Image ]List[Image]: A list of images that match the search criteria.

search_video

search_video(n_videos = 50 , filter = None , sort_by =None , model_key = None)

Perform video search in the dataset based on filters.

Parameters:

NameTypeDescriptionDefault
n_videosOptional [str]Number of video clips to return. Defaults to 50.50
filterOptional [str]Filter conditions for the search. Defaults to None.None
sort_byOptional [str]Sort criteria for the search. Defaults to None.None
model_keyOptional [str]Model key to filter videos. Defaults to None.None

Returns:

TypeDescription
List [ VideoClip ]List[VideoClip]: A list of video clips that match the search criteria.

update_image

update_image( image_key , annotations , tags = None , verbose= False )

Update an existing image's annotations and tags.

Parameters:

NameTypeDescriptionDefault
image_keystrThe key of the image to update.required
annotationsList [ Annotation ]The new annotations for the image.required
tagsOptional [ List [ Tag ]]The new tags for the image. Defaults to None.None
verboseOptional [bool]If True, provides progress updates. Defaults to False.False

upload_annotations

upload_annotations( coco_path_or_dict , verbose = True )

Upload annotations to the dataset.

Parameters:

NameTypeDescriptionDefault
coco_path_or_dictUnion [str, dict]The file path or dictionary of COCO annotations to upload.required
verboseOptional [bool]If True, provides progress updates. Defaults to True.True

upload_annotations_from_cloud

upload_annotations_from_cloud ( coco_file_location )

Upload annotations to the dataset from a cloud location.

Parameters:

NameTypeDescriptionDefault
coco_file_locationUnion [ AWSLocation , AzureLocation , GCSLocation ]The cloud location of the COCO annotations to upload.required

upload_custom_embeddings

upload_custom_embeddings(embedding_name,embedding_location,embedding_type='images',verbose= True)

Upload custom embeddings to the dataset for use in Embedding viewer.

Parameters:

NameTypeDescriptionDefault
embedding_namestrThe display name of the embeddings.required
embedding_locationdictThe location of the embeddings in cloud storage.required
embedding_typestrThe type of embeddings. At present only 'images' is supported. 'annotations'/'predictions' coming soon!'images'
verboseOptional [bool]If True, provides progress updates. Defaults to True.True

upload_custom_embeddings_from_local

upload_custom_embeddings_from_local ( embedding_name ,embedding_path , embedding_type = 'images' , verbose = True )

Upload custom embeddings from a local file to the dataset.

Parameters:

NameTypeDescriptionDefault
embedding_namestrThe display name of the embeddings.required
embedding_pathstrThe path to the custom embeddings JSON.required
embedding_typestrThe type of embeddings. At present only 'images' is supported. 'annotations'/'predictions' coming soon!'images'
verboseOptional [bool]If True, provides progress updates. Defaults to True.True

upload_images

upload_images ( image_directory_or_paths , verbose = True )

Upload images to the dataset.

Parameters:

NameTypeDescriptionDefault
image_directory_or_pathsUnion [str, Path , List [str]]The directory or paths of the images to upload.required
verboseOptional [bool]If True, provides progress updates. Defaults to True.True

upload_videos_from_cloud_and_ingest

upload_videos_from_cloud_and_ingest ( video_folder_location ,sample_rate_per_second , frames_to_subsample , prompts = [ 'objects' ], threshold = 0.005 )

Create a new dataset in the current workspace.

Parameters:

NameTypeDescriptionDefault
video_folder_locationUnion [ AWSLocation , GCSLocation , AzureLocation ]The location of the folder of videos where the images uploaded to the dataset come fromrequired

video_clip_generator

video_clip_generator(filter = None, sort_by = None, model_key = None, page_size = 50)

Generator to retrieve video clips from the dataset in a paginated manner.

Parameters:

NameTypeDescriptionDefault
filterOptional [str]Filter conditions for the search. Defaults to None.None
sort_byOptional [str]Sort criteria for the search. Defaults to None.None
model_keyOptional [str]Model key to filter videos. Defaults to None.None
page_sizeOptional [int]Number of images per page. Defaults to 50.50

Yields:

NameTypeDescription
GeneratorGenerator A generator yielding images.