SDK

The SDK class contains some core functionalities of Remo. It mainly acts as a wrapper around our API endpoints.

Use the SDK class to:

  • create a dataset and annotation set

  • list and retrieve datasets

  • export annotations without a need to intialize a dataset

Most of the functions documented below can be called from Python by doing

import remo

remo.function_name()

class remo.sdk.SDK

Creates sdk object, and checks connection to server

documentation
class remo.sdk.SDK(server: str, email: str, password: str, viewer: str = 'browser')
  • Parameters

    • server – server host name, e.g. http://localhost:8123/

    • email – user credentials

    • password – user credentials

    • viewer – allows to choose between browser, electron and jupyter viewer. To be able change viewer, you can use set_viewer() function. See example.

Example:

import remo

remo.set_viewer('browser')

add_annotations_to_image

Adds annotation to a given image

documentation
add_annotations_to_image(annotation_set_id: int, image_id: int, annotations: List[remo.domain.annotation.Annotation])
  • Parameters

    • annotation_set_id – annotation set id

    • image_id – image id

    • annotations – Annotation object


add_data_to_dataset

Adds images and/or annotations to an existing dataset. Use local files to link (rather than copy) images. Use paths_to_upload if you want to copy image files or archive files. Use urls to download from the web images, annotations or archives. Adding images: support for jpg,``jpeg``, png, tif Adding annotations: to add annotations, you need to specify the annotation task and make sure the specific file format is one of those supported. See documentation here: https://remo.ai/docs/annotation-formats/ Adding archive files: support for zip, tar, gzip

documentation
add_data_to_dataset(dataset_id: int, local_files: List[str] = None, paths_to_upload: List[str] = None, urls: List[str] = None, annotation_task: str = None, folder_id: int = None, annotation_set_id: int = None, class_encoding=None, wait_for_complete=True)
  • Parameters

    • dataset_id – id of the dataset to add data to

    • local_files – list of files or directories containing annotations and image files Remo will create smaller copies of your images for quick previews but it will point at the original files to show original resolutions images. Folders will be recursively scanned for image files.

    • paths_to_upload – list of files or directories containing images, annotations and archives. These files will be copied inside .remo folder. Folders will be recursively scanned for image files. Unpacked archive will be scanned for images, annotations and nested archives.

    • urls – list of urls pointing to downloadable target, which can be image, annotation file or archive.

    • annotation_task – annotation tasks tell remo how to parse annotations. See also: remo.task.

    • folder_id – specifies target virtual folder in the remo dataset. If None, it adds to the root level.

    • annotation_set_id – specifies target annotation set in the dataset. If None: if no annotation set exists, one will be automatically created. If exactly one annotation set already exists, it will add annotations to that annotation set, provided the task matches.

    • class_encoding – specifies how to convert labels in annotation files to readable labels. If None, Remo will try to interpret the encoding automatically - which for standard words, means they will be read as they are. See also: remo.class_encodings.

    • wait_for_complete – blocks function until upload data completes

  • Returns

    Dictionary with results for linking files, upload files and upload urls:

    {
        'files_link_result': ...,
        'files_upload_result': ...,
        'urls_upload_result': ...
    }
    

create_annotation_set

Creates a new annotation set within the given dataset

documentation
create_annotation_set(annotation_task: str, dataset_id: int, name: str, classes: List[str] = [])
  • Parameters

    • annotation_task – specified task for the annotation set. See also: remo.task

    • dataset_id – dataset id

    • name – name of the annotation set

    • classes – list of classes. Default is no classes

  • Returns

    remo.AnnotationSet


create_dataset

Creates a new dataset in Remo and optionally populate it with images and annotations. To add annotations, you need to specify an annotation task.

documentation
create_dataset(name: str, local_files: List[str] = None, paths_to_upload: List[str] = None, urls: List[str] = None, annotation_task: str = None, class_encoding=None, wait_for_complete=True)
  • Parameters

    • name – name of the dataset.

    • local_files – list of files or directories. These files will be linked. Folders will be recursively scanned for image files: jpg, png, tif.

    • paths_to_upload – list of files or directories. These files will be copied. Supported files: images, annotations and archives.

      • image files: jpg, png, tif.

      • annotation files: json, xml, csv.

      • archive files: zip, tar, gzip.

      Unpacked archive will be scanned for images, annotations and nested archives.

    • urls – list of urls pointing to downloadable target, which can be image, annotation file or archive.

    • annotation_task – specifies annotation task. See also: remo.task.

    • class_encoding – specifies how to convert class labels in annotation files to classes. See also: remo.class_encodings.

    • wait_for_complete – blocks function until upload data completes

  • Returns

    remo.Dataset


delete_dataset

Deletes dataset

documentation
delete_dataset(dataset_id: int)
  • Parameters

    dataset_id – dataset id


export_annotations

Exports annotations in given format

documentation
export_annotations(annotation_set_id: int, annotation_format: str = 'json', export_coordinates: str = 'pixel', full_path: bool = True, export_tags: bool = True)
  • Parameters

    • annotation_set_id – annotation set id

    • annotation_format – can be one of [‘json’, ‘coco’, ‘csv’], default=’json’

    • full_path – uses full image path (e.g. local path), it can be one of [True, False], default=True

    • export_coordinates – converts output values to percentage or pixels, can be one of [‘pixel’, ‘percent’], default=’pixel’

    • export_tags – exports the tags to a CSV file, it can be one of [True, False], default=True

  • Returns

    annotation file content


export_annotations_to_file

Exports annotations in given format

documentation
export_annotations_to_file(output_file: str, annotation_set_id: int, annotation_format: str = 'json', export_coordinates: str = 'pixel', full_path: bool = True, export_tags: bool = True)
  • Parameters

    • output_file – output file to save

    • annotation_set_id – annotation set id

    • annotation_format – can be one of [‘json’, ‘coco’, ‘csv’], default=’json’

    • full_path – uses full image path (e.g. local path), it can be one of [True, False], default=True

    • export_coordinates – converts output values to percentage or pixels, can be one of [‘pixel’, ‘percent’], default=’pixel’

    • export_tags – exports the tags to a CSV file, it can be one of [True, False], default=True


generate_annotations_from_folders

Creates a CSV annotation file for image classification tasks, where images are stored in folders with names matching the labels of the images. The CSV file is saved in the same input directory where images are stored. Example of data structure for a dog / cat dataset:

  • cats_and_dogs
    * dog
    
            * img1.jpg
    
            * img2.jpg
    
            * 
    
    * cat
    
            * img199.jpg
    
            * img200.jpg
    
            * 
    

Example::

# Download and unzip this sample dataset: s-3.s3-eu-west-1.amazonaws.com/cats_and_dogs.zip
data_path = “cats_and_dogs”
remo.generate_annotations_from_folders(path_to_data_folder=data_path)
documentation
generate_annotations_from_folders(path_to_data_folder: str)
  • Parameters

    path_to_data_folder – path to the source folder where data is stored

  • Returns

    string, path to the generated CSV annotation file

  • Return type

    csv_annotation_path


get_annotation_info

Returns current annotations for the image

documentation
get_annotation_info(dataset_id: int, annotation_set_id: int, image_id: int)
  • Parameters

    • dataset_id – dataset id

    • annotation_set_id – annotation set id

    • image_id – image id

  • Returns

    annotations info - list of annotation objects or classes


get_annotation_set

Retrieves annotation set

documentation
get_annotation_set(annotation_set_id: int)
  • Parameters

    annotation_set_id – annotation set id

  • Returns

    remo.AnnotationSet


get_dataset

Retrieves a dataset with given dataset id.

documentation
get_dataset(dataset_id: int)
  • Parameters

    dataset_id – dataset id

  • Returns

    remo.Dataset


get_image

Retrieves image by a given image id

documentation
get_image(image_id: int)
  • Parameters

    image_id – image id

  • Returns

    remo.Image


get_image_content

Get image file content by url

documentation
get_image_content(url: str)
  • Parameters

    url – image url

  • Returns

    image binary data


list_annotation_set_classes

List classes within the annotation set

documentation
list_annotation_set_classes(annotation_set_id: int)
  • Parameters

    annotation_set_id – annotation set id

  • Returns

    list of classes


list_annotation_sets

Returns a list of AnnotationSet containing all the AnnotationSets of a given dataset

documentation
list_annotation_sets(dataset_id: int)
  • Parameters

    dataset_id – dataset id

  • Returns

    List[remo.AnnotationSet]


list_annotations

Returns all annotations for a given annotation set

documentation
list_annotations(dataset_id: int, annotation_set_id: int)
  • Parameters

    • dataset_id – dataset id

    • annotation_set_id – annotation set id

  • Returns

    List[remo.Annotation]


list_dataset_images

Returns a list of images within a dataset with given dataset_id

documentation
list_dataset_images(dataset_id: int, limit: int = None, offset: int = None)
  • Parameters

    • dataset_id – dataset id

    • limit – limits result images

    • offset – specifies offset

  • Returns

    List[remo.Image]


list_datasets

Lists the available datasets

documentation
list_datasets()
  • Returns

    List[remo.Dataset]


list_image_annotations

Returns annotations for a given image

documentation
list_image_annotations(dataset_id: int, annotation_set_id: int, image_id: int)
  • Parameters

    • dataset_id – dataset id

    • annotation_set_id – annotation set id

    • image_id – image id

  • Returns

    List[remo.Annotation]


open_ui

Opens the main page of Remo

documentation
open_ui()

search_images

Search images by class and annotation task

documentation
search_images(classes=None, task: str = None, dataset_id: int = None, limit: int = None)
  • Parameters

    • classes – string or list of strings - search for images which match all given classes

    • task – name of the annotation task to filter dataset

    • dataset_id – narrows search result to given dataset

    • limit – limits number of search results

  • Returns

    image_id, dataset_id, name, annotations


set_viewer

Allows to choose one of available viewers

documentation
set_viewer(viewer: str)
  • Parameters

    viewer – choose between ‘browser’, ‘electron’ and ‘jupyter’ viewer


view_annotate_image

Opens browser on the annotation tool for giving image

documentation
view_annotate_image(annotation_set_id: int, image_id: int)
  • Parameters

    • annotation_set_id – annotation set id

    • image_id – image id


view_annotation_stats

Opens browser in annotation set insights page

documentation
view_annotation_stats(annotation_set_id: int)
  • Parameters

    annotation_set_id – annotation set id


view_annotation_tool

Opens browser in annotation view for the given annotation set

documentation
view_annotation_tool(id: int)
  • Parameters

    id – annotation set id


view_dataset

Opens browser for the given dataset

documentation
view_dataset(id: int)
  • Parameters

    id – dataset id


view_image

Opens browser on the image view for given image

documentation
view_image(image_id: int, dataset_id: int)
  • Parameters

    • image_id – image id

    • dataset_id – dataset id


Opens browser in search page

documentation
view_search()