import logging from control_models.base import ControlModel, get_bool from typing import List, Dict logger = logging.getLogger(__name__) class KeypointLabelsModel(ControlModel): """ Class representing a KeypointLabels control tag for YOLO model. """ type = "KeyPointLabels" model_path = ( "yolov8n-pose.pt" # Adjust the model path to your keypoint detection model ) add_bboxes: bool = True point_size: float = 1 point_threshold: float = 0 point_map: Dict = {} def __init__(self, **data): super().__init__(**data) self.add_bboxes = get_bool(self.control.attr, "model_add_bboxes", "true") self.point_size = float(self.control.attr.get("model_point_size", 1)) self.point_threshold = float(self.control.attr.get("model_point_threshold", 0)) self.point_map = self.build_point_mapping() @classmethod def is_control_matched(cls, control) -> bool: # Check object tag type if control.objects[0].tag != "Image": return False return control.tag == cls.type def build_point_mapping(self): """Build a mapping between points and Label Studio labels, e.g.