Skip to content

Commit 6e82160

Browse files
Merge pull request #3 from Clarifai/DEVX-371-export_update
Handling zero values in Clarifai Annotation Json
2 parents 89fc2f2 + 73c5ea4 commit 6e82160

File tree

1 file changed

+4
-5
lines changed
  • clarifai_datautils/image/annotation_conversion

1 file changed

+4
-5
lines changed

clarifai_datautils/image/annotation_conversion/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ def create_item(self, image_path: str) -> DatasetItem:
7171
return DatasetItem(id=image_path.split('.png')[0], media=image_data, annotations=annotations)
7272

7373
def clarifai_bbox_to_datumaro_bbox(self, clarifai_bbox, width, height) -> Tuple[int]:
74-
left_col = clarifai_bbox['leftCol'] * width
75-
top_row = clarifai_bbox['topRow'] * height
76-
right_col = clarifai_bbox['rightCol'] * width
77-
bottom_row = clarifai_bbox['bottomRow'] * height
78-
74+
left_col = clarifai_bbox['leftCol'] * width if 'leftCol' in clarifai_bbox.keys() else 0
75+
top_row = clarifai_bbox['topRow'] * height if 'topRow' in clarifai_bbox.keys() else 0
76+
right_col = clarifai_bbox['rightCol'] * width if 'rightCol' in clarifai_bbox.keys() else 0
77+
bottom_row = clarifai_bbox['bottomRow'] * height if 'bottomRow' in clarifai_bbox.keys() else 0
7978
obj_box = (left_col, top_row, right_col - left_col, bottom_row - top_row)
8079
return obj_box
8180

0 commit comments

Comments
 (0)