def create_instance_of_schema(schema: type["BaseSchema"], **data) -> "BaseSchema":
"""Create a row in a Schema."""
# Import here to avoid circular imports
from pixano.features.schemas import (
create_bbox,
create_bbox3d,
create_cam_calibration,
create_compressed_rle,
create_image,
create_keypoints,
create_keypoints3d,
create_sequence_frame,
create_track,
create_tracklet,
create_video,
is_base_schema,
is_bbox,
is_bbox3d,
is_cam_calibration,
is_compressed_rle,
is_image,
is_keypoints,
is_keypoints3d,
is_sequence_frame,
is_track,
is_tracklet,
is_video,
)
if is_image(schema, strict=True):
return create_image(**data)
elif is_video(schema, strict=True):
return create_video(**data)
elif is_sequence_frame(schema, strict=True):
return create_sequence_frame(**data)
elif is_tracklet(schema, strict=True):
return create_tracklet(**data)
elif is_track(schema, True):
return create_track(**data)
elif is_bbox(schema, True):
return create_bbox(**data)
elif is_bbox3d(schema, True):
return create_bbox3d(**data)
elif is_cam_calibration(schema, True):
return create_cam_calibration(**data)
elif is_compressed_rle(schema, True):
return create_compressed_rle(**data)
elif is_keypoints(schema, True):
return create_keypoints(**data)
elif is_keypoints3d(schema, True):
return create_keypoints3d(**data)
elif is_base_schema(schema, False):
return schema(**data)
raise ValueError(f"Schema {schema} is not a base schema.")