def _decode_detection_ann(self, buffer: io.IOBase) -> torch.Tensor: result = VOCDetection.parse_voc_xml( ElementTree.parse(buffer).getroot()) # type: ignore[arg-type] objects = result["annotation"]["object"] bboxes = [obj["bndbox"] for obj in objects] bboxes = [[ int(bbox[part]) for part in ("xmin", "ymin", "xmax", "ymax") ] for bbox in bboxes] return BoundingBox(bboxes)
def _parse_detection_ann(self, buffer: BinaryIO) -> Dict[str, Any]: return cast( Dict[str, Any], VOCDetection.parse_voc_xml( ElementTree.parse(buffer).getroot())["annotation"])