Skip to content

Commit

Permalink
Update inputs_annotations.py (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjaychelliah authored Dec 3, 2024
1 parent 639535b commit df05d67
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clarifai/datasets/export/inputs_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ def _save_video_to_archive(self, new_archive: zipfile.ZipFile, hosted_url: str,
def _save_annotation_to_archive(self, new_archive: zipfile.ZipFile, annot_data: List[Dict],
file_name: str) -> None:
"""Gets the annotation response bytestring (from requests) and append to zip file."""
# Fill zero values for missing bounding box keys
for annot in annot_data:
if annot.get('regionInfo') and annot['regionInfo'].get('boundingBox'):
bbox = annot['regionInfo']['boundingBox']
bbox.setdefault('topRow', 0)
bbox.setdefault('leftCol', 0)
bbox.setdefault('bottomRow', 0)
bbox.setdefault('rightCol', 0)
# Serialize the dictionary to a JSON string
json_str = json.dumps(annot_data)
# Convert the JSON string to bytes
Expand Down

0 comments on commit df05d67

Please sign in to comment.