VideoProject

class VideoProject[source]

Bases: supervisely.project.project.Project

VideoProject is a parent directory for video dataset. VideoProject object is immutable.

Parameters
directory : str

Path to video project directory.

mode : OpenMode

Determines working mode for the given project.

Usage example
import supervisely as sly
project_path = "/home/admin/work/supervisely/projects/videos_example"
project = sly.Project(project_path, sly.OpenMode.READ)

Methods

copy_data

Makes a copy of the VideoProject.

create_dataset

Creates a subdirectory with given name and all intermediate subdirectories for items and annotations in project directory, and also adds created dataset to the collection of all datasets in the project.

download

Download video project from Supervisely to the given directory.

get_classes_stats

get_item_paths

rtype

ItemPaths

get_train_val_splits_by_count

Not available for VideoProject class.

get_train_val_splits_by_dataset

Not available for VideoProject class.

get_train_val_splits_by_tag

Not available for VideoProject class.

get_url

Get URL to video datasets list in Supervisely.

read_single

Read project from given ditectory.

remove_classes

Not available for VideoProject class.

remove_classes_except

Not available for VideoProject class.

remove_items_without_both_objects_and_tags

Not available for VideoProject class.

remove_items_without_objects

Not available for VideoProject class.

remove_items_without_tags

Not available for VideoProject class.

set_key_id_map

Save given KeyIdMap object to project dir in json format.

set_meta

Saves given meta to project directory in json format.

to_detection_task

Not available for VideoProject class.

to_segmentation_task

Not available for VideoProject class.

upload

Upload video project from given directory in Supervisely.

validate

Attributes

datasets

Project datasets.

directory

Path to the project directory.

key_id_map

meta

Project meta.

name

Project name.

parent_dir

Project parent directory.

total_items

Total number of items in project.

type

Project type.

dataset_class

alias of supervisely.project.video_project.VideoDataset

copy_data(dst_directory, dst_name=None, _validate_item=True, _use_hardlink=False)[source]

Makes a copy of the VideoProject.

Parameters
dst_directory : str

Path to video project parent directory.

dst_name : str, optional

Video Project name.

_validate_item : bool, optional

Checks input files format.

_use_hardlink : bool, optional

If True creates a hardlink pointing to src named dst, otherwise don’t.

Returns

VideoProject object.

Return type

VideoProject

Usage example
import supervisely as sly
project = sly.VideoProject("/home/admin/work/supervisely/projects/videos_example", sly.OpenMode.READ)
print(project.total_items)
# Output: 6

new_project = project.copy_data("/home/admin/work/supervisely/projects/", "videos_example_copy")
print(new_project.total_items)
# Output: 6
create_dataset(ds_name, ds_path=None)

Creates a subdirectory with given name and all intermediate subdirectories for items and annotations in project directory, and also adds created dataset to the collection of all datasets in the project.

Parameters
ds_name : str

Dataset name.

Returns

Dataset object

Return type

Dataset

Usage example
import supervisely as sly
project = sly.Project("/home/admin/work/supervisely/projects/lemons_annotated", sly.OpenMode.READ)

for dataset in project.datasets:
    print(dataset.name)

# Output: ds1
#         ds2

project.create_dataset("ds3")

for dataset in project.datasets:
    print(dataset.name)

# Output: ds1
#         ds2
#         ds3
static download(api, project_id, dest_dir, dataset_ids=None, download_videos=True, save_video_info=False, log_progress=True, progress_cb=None)[source]

Download video project from Supervisely to the given directory.

Parameters
api : Api

Supervisely Api class object.

project_id : int

Project ID in Supervisely.

dest_dir : str

Directory to download video project.

dataset_ids : list [ int ], optional

Datasets IDs in Supervisely to download.

download_videos : bool, optional

Download videos from Supervisely video project in dest_dir or not.

save_video_info : bool, optional

Save video infos or not.

log_progress : bool

Log download progress or not.

progress_cb : tqdm, optional

Function for tracking download progress.

Returns

None

Return type

NoneType

Usage example

import supervisely as sly

# Local destination Project folder
save_directory = "/home/admin/work/supervisely/source/video_project"

# Obtain server address and your api_token from environment variables
# Edit those values if you run this notebook on your own PC
address = os.environ['SERVER_ADDRESS']
token = os.environ['API_TOKEN']

# Initialize API object
api = sly.Api(address, token)
project_id = 8888

# Download Video Project
sly.VideoProject.download(api, project_id, save_directory)
project_fs = sly.VideoProject(save_directory, sly.OpenMode.READ)
static get_train_val_splits_by_count(project_dir, train_count, val_count)[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

static get_train_val_splits_by_dataset(project_dir, train_datasets, val_datasets)[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

static get_train_val_splits_by_tag(project_dir, train_tag_name, val_tag_name, untagged='ignore')[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

static get_url(id)[source]

Get URL to video datasets list in Supervisely.

Parameters
id : int

VideoProject ID in Supervisely.

Returns

URL to datasets list.

Return type

str

Usage example
from supervisely import VideoProject

project_id = 10093
datasets_link = VideoProject.get_url(project_id)

print(datasets_link)
# Output: "/projects/10093/datasets"
classmethod read_single(dir)[source]

Read project from given ditectory. Generate exception error if given dir contains more than one subdirectory :param dir: str :return: VideoProject class object

static remove_classes(project_dir, classes_to_remove=None, inplace=False)[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

static remove_classes_except(project_dir, classes_to_keep=None, inplace=False)[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

static remove_items_without_both_objects_and_tags(project_dir, inplace=False)[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

static remove_items_without_objects(project_dir, inplace=False)[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

static remove_items_without_tags(project_dir, inplace=False)[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

set_key_id_map(new_map)[source]

Save given KeyIdMap object to project dir in json format. :type new_map: KeyIdMap :param new_map: KeyIdMap class object

set_meta(new_meta)

Saves given meta to project directory in json format.

Parameters
new_meta : ProjectMeta

ProjectMeta object.

Returns

None

Return type

NoneType

Usage example
import supervisely as sly
proj_lemons = sly.Project("/home/admin/work/supervisely/projects/lemons_annotated", sly.OpenMode.READ)
proj_kiwi = sly.Project("/home/admin/work/supervisely/projects/kiwi_annotated", sly.OpenMode.READ)

proj_lemons.set_meta(proj_kiwi.meta)

print(project.proj_lemons)
# Output:
# +-------+--------+----------------+--------+
# |  Name | Shape  |     Color      | Hotkey |
# +-------+--------+----------------+--------+
# |  kiwi | Bitmap |  [255, 0, 0]   |        |
# +-------+--------+----------------+--------+
static to_detection_task(src_project_dir, dst_project_dir=None, inplace=False, progress_cb=None)[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

static to_segmentation_task(src_project_dir, dst_project_dir=None, inplace=False, target_classes=None, progress_cb=None, segmentation_type='semantic')[source]

Not available for VideoProject class. :raises: NotImplementedError in all cases.

Return type

None

static upload(dir, api, workspace_id, project_name=None, log_progress=True, progress_cb=None)[source]

Upload video project from given directory in Supervisely.

Parameters
dir : str

Directory with video project.

api : Api

Api class object.

workspace_id : int

Workspace ID in Supervisely to upload video project.

project_name : str

Name of video project.

log_progress : bool

Logging progress of download video project or not.

Returns

New video project ID in Supervisely and project name

Return type

int, str

Usage example

import supervisely as sly

# Local folder with Video Project
project_directory = "/home/admin/work/supervisely/source/video_project"

# Obtain server address and your api_token from environment variables
# Edit those values if you run this notebook on your own PC
address = os.environ['SERVER_ADDRESS']
token = os.environ['API_TOKEN']

# Initialize API object
api = sly.Api(address, token)

# Upload Video Project
project_id, project_name = sly.VideoProject.upload(
    project_directory,
    api,
    workspace_id=45,
    project_name="My Video Project"
)
property datasets

Project datasets.

Returns

Datasets

Return type

DatasetDict

Usage example
import supervisely as sly
project = sly.Project("/home/admin/work/supervisely/projects/lemons_annotated", sly.OpenMode.READ)
for dataset in project.datasets:
    print(dataset.name)
    # Output: ds1
    #         ds2
property directory

Path to the project directory.

Returns

Path to the project directory

Return type

str

Usage example
import supervisely as sly
project = sly.Project("/home/admin/work/supervisely/projects/lemons_annotated", sly.OpenMode.READ)
print(project.directory)
# Output: '/home/admin/work/supervisely/projects/lemons_annotated'
property meta

Project meta.

Returns

ProjectMeta object

Return type

ProjectMeta

Usage example
import supervisely as sly
project = sly.Project("/home/admin/work/supervisely/projects/lemons_annotated", sly.OpenMode.READ)
print(project.meta)
# Output:
# +-------+--------+----------------+--------+
# |  Name | Shape  |     Color      | Hotkey |
# +-------+--------+----------------+--------+
# |  kiwi | Bitmap |  [255, 0, 0]   |        |
# | lemon | Bitmap | [81, 198, 170] |        |
# +-------+--------+----------------+--------+
# Tags
# +------+------------+-----------------+--------+---------------+--------------------+
# | Name | Value type | Possible values | Hotkey | Applicable to | Applicable classes |
# +------+------------+-----------------+--------+---------------+--------------------+
property name

Project name.

Returns

Project name.

Return type

str

Usage example
import supervisely as sly
project = sly.Project("/home/admin/work/supervisely/projects/lemons_annotated", sly.OpenMode.READ)
print(project.name)
# Output: 'lemons_annotated'
property parent_dir

Project parent directory.

Returns

Path to project parent directory

Return type

str

Usage example
import supervisely as sly
project = sly.Project("/home/admin/work/supervisely/projects/lemons_annotated", sly.OpenMode.READ)
print(project.parent_dir)
# Output: '/home/admin/work/supervisely/projects'
property total_items

Total number of items in project.

Returns

Total number of items in project

Return type

int

Usage example
import supervisely as sly
project = sly.Project("/home/admin/work/supervisely/projects/lemons_annotated", sly.OpenMode.READ)
print(project.total_items)
# Output: 12
property type

Project type.

Returns

Project type.

Return type

str

Usage example
import supervisely as sly
project = sly.VideoProject("/home/admin/work/supervisely/projects/video", sly.OpenMode.READ)
print(project.type)
# Output: 'videos'