PointcloudProject¶
- class PointcloudProject[source]¶
Bases:
supervisely.project.video_project.VideoProject
PointcloudProject is a parent directory for pointcloud datasets. PointcloudProject object is immutable.
- Parameters
- Usage example
import supervisely as sly project_path = "/home/admin/work/supervisely/projects/ptc_project" project = sly.PointcloudProject(project_path, sly.OpenMode.READ)
Methods
Makes a copy of the
VideoProject
.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 pointcloud project from Supervisely to the given directory.
download_async
Download project to the local directory in binary format.
get_classes_stats
get_item_paths
- rtype
Get train and val items information from project by given train and val counts.
Get train and val items information from project by given train and val datasets names.
Get train and val items information from project by given train and val tags names.
Get URL to video datasets list in Supervisely.
read_single
- rtype
Not available for VideoProject class.
Not available for VideoProject class.
Not available for VideoProject class.
Not available for VideoProject class.
Not available for VideoProject class.
Save given KeyIdMap object to project dir in json format.
Saves given
meta
to project directory in json format.Convert Supervisely project to COCO format.
Not available for VideoProject class.
Convert Supervisely project to Pascal VOC format.
Not available for VideoProject class.
Convert Supervisely project to YOLO format.
Uploads pointcloud project to Supervisely from the given directory.
Uploads project to Supervisely from the given binary file and suitable only for projects downloaded in binary format.
validate
Attributes
Project datasets.
Path to the project directory.
key_id_map
Project meta.
Project name.
Project parent directory.
Total number of items in project.
Project type.
-
copy_data(dst_directory, dst_name=
None
, _validate_item=True
, _use_hardlink=False
)¶ Makes a copy of the
VideoProject
.- Parameters
- 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.
- ds_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_pointclouds=True
, download_related_images=True
, download_pointclouds_info=False
, batch_size=10
, log_progress=True
, progress_cb=None
, **kwargs)[source]¶ Download pointcloud project from Supervisely to the given directory.
- Parameters
- api : sly.Api
Supervisely API address and token.
- project_id : int
Supervisely downloadable project ID.
- dest_dir : str
Destination directory.
- dataset_ids : List[int], optional
Dataset IDs.
- download_pointclouds : bool, optional
Download pointcloud data files or not.
- download_related_images : bool, optional
Download related images or not.
- download_pointclouds_info : bool, optional
Download pointcloud info .json files or not.
- batch_size : int, optional
The number of images in the batch when they are loaded to a host.
- log_progress : bool
Show uploading progress bar.
- progress_cb : tqdm or callable, optional
Function for tracking download progress.
- Returns
None
- Return type
NoneType
- Usage example
import supervisely as sly # Local destination Pointcloud Project folder save_directory = "/home/admin/work/supervisely/source/ptc_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 Project sly.PointcloudProject.download(api, project_id, save_directory) project_fs = sly.PointcloudProject(save_directory, sly.OpenMode.READ)
-
static download_bin(api, project_id, dest_dir=
None
, dataset_ids=None
, batch_size=100
, log_progress=True
, progress_cb=None
, return_bytesio=False
)¶ Download project to the local directory in binary format. Faster than downloading project in the usual way. This type of project download is more suitable for creating local backups. It is also suitable for cases where you don’t need access to individual project files, such as images or annotations.
Binary file contains the following data: - ProjectInfo - ProjectMeta - List of DatasetInfo - List of ImageInfo - Dict of Figures - Dict of AlphaGeometries
- Parameters
- api :
Api
Supervisely API address and token.
- project_id :
int
Project ID to download.
- dest_dir :
str
, optional Destination path to local directory.
- dataset_ids :
list
[int
], optional Specified list of Dataset IDs which will be downloaded. If you want to download nested datasets, you should specify all nested IDs.
- batch_size :
int
, optional Size of a downloading batch.
- log_progress :
bool
, optional Show downloading logs in the output.
- progress_cb :
tqdm
orcallable
, optional Function for tracking download progress. Has a higher priority than log_progress.
- return_bytesio :
bool
, optional If True, returns BytesIO object instead of saving it to the disk.
- api :
- Returns
Path to the binary file or BytesIO object.
- Return type
str
orBytesIO
- Usage example
import supervisely as sly # Local destination Project folder save_directory = "/home/admin/work/supervisely/source/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 Project in binary format project_bin_path = sly.Project.download_bin(api, project_id, save_directory)
- static get_train_val_splits_by_count(project_dir, train_count, val_count)[source]¶
Get train and val items information from project by given train and val counts.
- Parameters
- Raises
ValueError
if total_count != train_count + val_count- Returns
Tuple with lists of train items information and val items information
- Return type
Tuple[List[PointcloudItemInfo], List[PointcloudItemInfo]]
- Usage example
from supervisely.project.pointcloud_project import PointcloudProject project_path = "/home/admin/work/supervisely/projects/pointcloud_project" project = PointcloudProject(project_path, sly.OpenMode.READ) train_count = 4 val_count = 2 train_items, val_items = project.get_train_val_splits_by_count(project_path, train_count, val_count)
- static get_train_val_splits_by_dataset(project_dir, train_datasets, val_datasets)[source]¶
Get train and val items information from project by given train and val datasets names.
- Parameters
- Raises
KeyError
if dataset name not found in project- Returns
Tuple with lists of train items information and val items information
- Return type
Tuple[List[PointcloudItemInfo], List[PointcloudItemInfo]]
- Usage example
import supervisely as sly project_path = "/home/admin/work/supervisely/projects/pointcloud_project" project = sly.PointcloudProject(project_path, sly.OpenMode.READ) train_datasets = ['ds1', 'ds2'] val_datasets = ['ds3', 'ds4'] train_items, val_items = project.get_train_val_splits_by_dataset(project_path, train_datasets, val_datasets)
-
static get_train_val_splits_by_tag(project_dir, train_tag_name, val_tag_name, untagged=
'ignore'
)[source]¶ Get train and val items information from project by given train and val tags names.
- Parameters
- Raises
ValueError
if untagged not in [“ignore”, “train”, “val”]- Returns
Tuple with lists of train items information and val items information
- Return type
Tuple[List[PointcloudItemInfo], List[PointcloudItemInfo]]
- Usage example
import supervisely as sly project_path = "/home/admin/work/supervisely/projects/pointcloud_project" project = sly.PointcloudProject(project_path, sly.OpenMode.READ) train_tag_name = 'train' val_tag_name = 'val' train_items, val_items = project.get_train_val_splits_by_tag(project_path, train_tag_name, val_tag_name)
- static get_url(id)¶
Get URL to video datasets list in Supervisely.
-
static remove_classes(project_dir, classes_to_remove=
None
, inplace=False
)¶ Not available for VideoProject class. :raises:
NotImplementedError
in all cases.- Return type
-
static remove_classes_except(project_dir, classes_to_keep=
None
, inplace=False
)¶ Not available for VideoProject class. :raises:
NotImplementedError
in all cases.- Return type
-
static remove_items_without_both_objects_and_tags(project_dir, inplace=
False
)¶ Not available for VideoProject class. :raises:
NotImplementedError
in all cases.- Return type
-
static remove_items_without_objects(project_dir, inplace=
False
)¶ Not available for VideoProject class. :raises:
NotImplementedError
in all cases.- Return type
-
static remove_items_without_tags(project_dir, inplace=
False
)¶ Not available for VideoProject class. :raises:
NotImplementedError
in all cases.- Return type
- set_key_id_map(new_map)¶
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.
- new_meta :
- 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] | | # +-------+--------+----------------+--------+
-
to_coco(dest_dir=
None
, copy_images=False
, with_captions=False
, log_progress=True
, progress_cb=None
)¶ Convert Supervisely project to COCO format.
- Parameters
- dest_dir :
str
, optional Destination directory.
- copy_images :
bool
Copy images to the destination directory.
- with_captions :
bool
Return captions for images.
- log_progress :
bool
Show uploading progress bar.
- progress_cb : callable, optional
Function for tracking conversion progress (for all items in the project).
- dest_dir :
- Returns
None
- Return type
NoneType
- Usage example
import supervisely as sly # Local folder with Project project_directory = "/home/admin/work/supervisely/source/project" # Convert Project to COCO format sly.Project(project_directory).to_coco(log_progress=True) # or from supervisely.convert import to_coco to_coco(project_directory, dest_dir="./coco_project")
-
static to_detection_task(src_project_dir, dst_project_dir=
None
, inplace=False
, progress_cb=None
)¶ Not available for VideoProject class. :raises:
NotImplementedError
in all cases.- Return type
-
to_pascal_voc(dest_dir=
None
, train_val_split_coef=0.8
, log_progress=True
, progress_cb=None
)¶ Convert Supervisely project to Pascal VOC format.
- Parameters
- dest_dir :
str
, optional Destination directory.
- train_val_split_coef :
float
, optional Coefficient for splitting images into train and validation sets.
- log_progress :
bool
Show uploading progress bar.
- progress_cb : callable, optional
Function for tracking conversion progress (for all items in the project).
- dest_dir :
- Returns
None
- Return type
NoneType
- Usage example
import supervisely as sly # Local folder with Project project_directory = "/home/admin/work/supervisely/source/project" # Convert Project to YOLO format sly.Project(project_directory).to_pascal_voc(log_progress=True) # or from supervisely.convert import to_pascal_voc to_pascal_voc(project_directory, dest_dir="./pascal_voc_project")
-
static to_segmentation_task(src_project_dir, dst_project_dir=
None
, inplace=False
, target_classes=None
, progress_cb=None
, segmentation_type='semantic'
)¶ Not available for VideoProject class. :raises:
NotImplementedError
in all cases.- Return type
-
to_yolo(dest_dir=
None
, task_type='detect'
, log_progress=True
, progress_cb=None
, val_datasets=None
)¶ Convert Supervisely project to YOLO format.
- Parameters
- dest_dir :
str
, optional Destination directory.
- task_type :
str
orTaskType
, optional Task type for YOLO format. Possible values: ‘detection’, ‘segmentation’, ‘pose’.
- log_progress :
bool
Show uploading progress bar.
- progress_cb : callable, optional
Function for tracking conversion progress (for all items in the project).
- val_datasets :
list
[str
], optional List of dataset names for validation. Full dataset names are required (e.g., ‘ds0/nested_ds1/ds3’). If specified, datasets from the list will be marked as val, others as train. If not specified, the function will determine the validation datasets automatically.
- dest_dir :
- Returns
None
- Return type
NoneType
- Usage example
import supervisely as sly # Local folder with Project project_directory = "/home/admin/work/supervisely/source/project" # Convert Project to YOLO format sly.Project(project_directory).to_yolo(log_progress=True) # or from supervisely.convert import to_yolo to_yolo(project_directory, dest_dir="./yolo_project")
-
static upload(directory, api, workspace_id, project_name=
None
, log_progress=True
, progress_cb=None
)[source]¶ Uploads pointcloud project to Supervisely from the given directory.
- Parameters
- directory : str
Path to project directory.
- api : sly.Api
Supervisely API address and token.
- workspace_id : int
Workspace ID, where project will be uploaded.
- project_name : str, optional
Name of the project in Supervisely. Can be changed if project with the same name is already exists.
- log_progress : bool
Show uploading progress bar.
- progress_cb : tqdm or callable, optional
Function for tracking download progress.
- Returns
Project ID and name. It is recommended to check that returned project name coincides with provided project name.
- Return type
- Usage example
import supervisely as sly # Local folder with Pointcloud Project project_directory = "/home/admin/work/supervisely/source/ptc_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 Pointcloud Project project_id, project_name = sly.PointcloudProject.upload( project_directory, api, workspace_id=45, project_name="My Pointcloud Project" )
-
static upload_bin(api, file, workspace_id, project_name=
None
, with_custom_data=True
, log_progress=True
, progress_cb=None
, skip_missed=False
)¶ Uploads project to Supervisely from the given binary file and suitable only for projects downloaded in binary format. This method is a counterpart to
download_bin()
. Faster than uploading project in the usual way.- Parameters
- api :
Api
Supervisely API address and token.
- file :
str
orBytesIO
Path to the binary file or BytesIO object.
- workspace_id :
int
Workspace ID, where project will be uploaded.
- project_name :
str
, optional Name of the project in Supervisely. Can be changed if project with the same name is already exists.
- with_custom_data :
bool
, optional If True, custom data from source project will be added to a new project.
- log_progress :
bool
, optional Show uploading progress bar.
- progress_cb : tqdm or callable, optional
Function for tracking upload progress for datasets. Has a higher priority than log_progress.
- skip_missed :
bool
, optional Skip missed images.
- api :
- Returns
ProjectInfo object.
- Return type
ProjectInfo
- Usage example
import supervisely as sly # Local folder with Project project_path = "/home/admin/work/supervisely/source/project/222_ProjectName" # 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 Project project_info = sly.Project.upload_bin( api, project_path, workspace_id=45, project_name="My Project" )
- property datasets¶
Project datasets.
- Returns
Datasets
- Return type
- 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
- 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
- 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
- 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
- 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
- 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