diff --git a/README.md b/README.md index 4c65329..c1931cd 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ - [Sequential PCD](#sequential-pcd) - [DICOM](#dicom) - [Common](#common) +- [Appendix](#appendix) - [Annotation](#annotation) - [Project](#project) - [Dataset](#dataset) @@ -2174,6 +2175,35 @@ Example of a single history object } ``` + +## Appendix + +Processing of various types of appendix information is supported. + +### Import Camera Calibration + +Import camera calibration and image appendix information for tasks in pcd and sequential pcd projects. + + +```python +client.import_appendix_file(project="YOUR_PROJECT_SLUG", file_path="ZIP_FILE_PATH") +``` + +The folder structure inside the ZIP file is as follows + +``` +. +└── task_name + ├── content_name_1.pcd + │   ├── 000001.png + │   └── 000001.yaml + └── content_name_2.pcd + ├── 000002.png + ├── 000002.yaml + ├── 000003.png + └── 000003.yaml +``` + ## Annotation ### Create Annotation diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 1d96d57..a0d392d 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -1974,6 +1974,32 @@ def create_sequential_pcd_task( return self.api.post_request(endpoint, payload=payload) + def import_appendix_file( + self, + project: str, + file_path: str, + ) -> list: + """ + Import calibration file zip. + project is slug of your project (Required). + file_path is a path to data. Supported extensions are zip (Required). + """ + + if not utils.is_appendix_supported_ext(file_path): + raise FastLabelInvalidException("Supported extensions are zip.", 422) + + endpoint = "contents/imports/appendix/batch" + payload = {"project": project} + signed_url = self.__get_signed_path( + project=project, + file_name=os.path.basename(file_path), + file_type="application/zip", + ) + self.api.upload_zipfile(url=signed_url["url"], file_path=file_path) + payload["fileKey"] = signed_url["name"] + + return self.api.post_request(endpoint, payload=payload) + # Task Update def update_task( diff --git a/fastlabel/utils/__init__.py b/fastlabel/utils/__init__.py index 43f4763..3b90d73 100644 --- a/fastlabel/utils/__init__.py +++ b/fastlabel/utils/__init__.py @@ -42,6 +42,10 @@ def is_dicom_supported_ext(file_path: str) -> bool: return file_path.lower().endswith((".zip")) +def is_appendix_supported_ext(file_path: str) -> bool: + return file_path.lower().endswith((".zip")) + + def is_pcd_supported_ext(file_path: str) -> bool: # .ply is not yet supported. To support it, modification of the API # needs to be considered as well.