Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PDF handling to initialise_labels #731

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions encord/constants/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class DataType(StringEnum):
IMAGE = "image"
DICOM_STUDY = "dicom_study"
NIFTI = "nifti"
PDF = "pdf"

# will be displayed if the Encord platform has a new data type that is not present in this SDK version. Please upgrade your SDK version
MISSING_DATA_TYPE = "_MISSING_DATA_TYPE_"
Expand Down
7 changes: 4 additions & 3 deletions encord/objects/ontology_labels_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,7 @@ def _to_encord_data_unit(self, frame_level_data: FrameLevelImageGroupData) -> Di
or data_type == DataType.DICOM
or data_type == DataType.IMAGE
or data_type == DataType.NIFTI
or data_type == DataType.PDF
):
data_sequence = frame_level_data.frame_number

Expand Down Expand Up @@ -1558,7 +1559,7 @@ def _to_encord_labels(self, frame_level_data: FrameLevelImageGroupData) -> Dict[
ret: Dict[str, Any] = {}
data_type = self._label_row_read_only_data.data_type

if data_type == DataType.IMAGE or data_type == DataType.IMG_GROUP:
if data_type == DataType.IMAGE or data_type == DataType.IMG_GROUP or data_type == DataType.PDF:
frame = frame_level_data.frame_number
ret.update(self._to_encord_label(frame))

Expand Down Expand Up @@ -1752,7 +1753,7 @@ def _parse_label_row_dict(self, label_row_dict: dict) -> LabelRowReadOnlyData:
frame_to_image_hash = {item.frame_number: item.image_hash for item in frame_level_data.values()}
data_type = DataType(label_row_dict["data_type"])

if data_type == DataType.VIDEO or data_type == DataType.IMAGE:
if data_type == DataType.VIDEO or data_type == DataType.IMAGE or data_type == DataType.PDF:
data_dict = list(label_row_dict["data_units"].values())[0]
data_link = data_dict["data_link"]
# Dimensions should be always there
Expand Down Expand Up @@ -1819,7 +1820,7 @@ def _parse_labels_from_dict(self, label_row_dict: dict):
for data_unit in label_row_dict["data_units"].values():
data_type = DataType(label_row_dict["data_type"])

if data_type == DataType.IMG_GROUP or data_type == DataType.IMAGE:
if data_type == DataType.IMG_GROUP or data_type == DataType.IMAGE or data_type == DataType.PDF:
frame = int(data_unit["data_sequence"])
self._add_object_instances_from_objects(data_unit["labels"].get("objects", []), frame)
self._add_classification_instances_from_classifications(
Expand Down
Loading