def from_pretrained(model_name: str) -> RTDETR:
        """Load model from pretrained weights.

        Args:
            model_name: 'rtdetr_r18vd', 'rtdetr_r34vd', 'rtdetr_r50vd_m', 'rtdetr_r50vd', 'rtdetr_r101vd'.

        """
        if model_name not in URLs:
            raise ValueError(f"No pretrained model for '{model_name}'. Please select from {list(URLs.keys())}.")

        state_dict = torch.hub.load_state_dict_from_url(
            URLs[model_name], map_location="cuda:0" if torch.cuda.is_available() else "cpu"
        )

        def map_name(old_name: str) -> str:
            new_name = old_name

            # Encoder renaming
            new_name = re.sub("encoder.pan_blocks", "encoder.ccfm.pan_blocks", new_name)
            new_name = re.sub("encoder.downsample_convs", "encoder.ccfm.downsample_convs", new_name)
            new_name = re.sub("encoder.fpn_blocks", "encoder.ccfm.fpn_blocks", new_name)
            new_name = re.sub("encoder.lateral_convs", "encoder.ccfm.lateral_convs", new_name)

            # Backbone renaming
            new_name = re.sub(".branch2b.", ".convs.branch2b.", new_name)
            new_name = re.sub(".branch2a.", ".convs.branch2a.", new_name)
            new_name = re.sub(".branch2c.", ".convs.branch2c.", new_name)

            return new_name

        def _state_dict_proc(state_dict: dict[str, Tensor]) -> dict[str, Tensor]:
            state_dict = state_dict["ema"]["module"]  # type:ignore
            new_state_dict = {}

            # Apply the regex-based mapping function to each key
            for old_name in state_dict.keys():
                new_name = map_name(old_name)
                new_state_dict[new_name] = state_dict[old_name]

            return new_state_dict

        model = RTDETR.from_name(model_name, num_classes=80)

        model.load_state_dict(_state_dict_proc(state_dict))
        return model
Load model from pretrained weights.

        Args:
            model_name: 'rtdetr_r18vd', 'rtdetr_r34vd', 'rtdetr_r50vd_m', 'rtdetr_r50vd', 'rtdetr_r101vd'.

        
kornia/contrib/models/rt_detr/model.py