Use this file to discover all available pages before exploring further.
Use create_project_from_cvat_start() to initiate a CVAT project import into Encord.The import runs asynchronously and returns an import UUID, that is then passed to create_project_from_cvat_get_result() to poll for the final import status and retrieve the created project information.
Your Encord Ontology must match the labels and attributes defined in the CVAT export.
# Import dependenciesfrom encord import EncordUserClientfrom encord.orm.project import ReviewModefrom encord.utilities.client_utilities import LocalImportSSH_PATH = "/Users/chris-encord/ssh-private-key.txt" # Replace with the file path to your SSH private key# Path to the exported CVAT folder. It must contain:# <CVAT_EXPORT_DIR>/annotations.xml <- the CVAT XML export# <CVAT_EXPORT_DIR>/images/ <- referenced image files## Export using:# "CVAT for images 1.1"## Ensure:# "Save images" is enabled.CVAT_EXPORT_DIR = "/Users/chris-encord/cvat-exports/b1"# Name of the Encord dataset/project to create.DATASET_NAME = "b1"# Create Encord client using SSH private key authentication.user_client = EncordUserClient.create_with_ssh_private_key( ssh_private_key_path=SSH_PATH, # For US platform users use: # domain="https://api.us.encord.com" domain="https://api.encord.com",)# Step 1:# Start the asynchronous CVAT import.## This uploads the images and submits the CVAT annotations.xml file.cvat_import_uuid = user_client.create_project_from_cvat_start( import_method=LocalImport(file_path=CVAT_EXPORT_DIR), dataset_name=DATASET_NAME, review_mode=ReviewMode.UNLABELLED, transform_bounding_boxes_to_polygons=False,)print(f"CVAT import started. import_uuid={cvat_import_uuid}")# Step 2:# Poll until the import process completes.result = user_client.create_project_from_cvat_get_result(cvat_import_uuid)# Step 3:# Check whether the import succeeded.if hasattr(result, "project_hash"): print( f"Import succeeded. " f"project_hash={result.project_hash}, " f"dataset_hash={result.dataset_hash}" ) # Optional: # Display warnings, errors, or informational messages returned by the import. issues = getattr(result, "issues", None) if issues and (issues.errors or issues.warnings or issues.info): print(f"Import issues: {issues}")else: print(f"Import failed. issues={getattr(result, 'issues', None)}")