Skip to content

Commit b6b70ad

Browse files
authored
Make COCO exports remember original img resolutions (airctic#1142)
* Make COCO exports remember original img resolutions * black formatting
1 parent fc19096 commit b6b70ad

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

icevision/data/convert_records_to_coco_style.py

+8
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ def export_batch_inferences_as_coco_annotations(
132132
)
133133

134134
coco_style_preds = convert_preds_to_coco_style(preds)
135+
imgs_array = [PIL.Image.open(Path(fname)) for fname in img_files]
136+
137+
sizes = [{"x": img._size[0], "y": img._size[1]} for img in imgs_array]
138+
139+
for idx, image in enumerate(coco_style_preds["images"]):
140+
coco_style_preds["images"][idx]["width"] = sizes[idx]["x"]
141+
coco_style_preds["images"][idx]["height"] = sizes[idx]["y"]
142+
135143
finalized_pseudo_labels = {**addl_info, **coco_style_preds}
136144

137145
# Serialize

0 commit comments

Comments
 (0)