class_docstr: RT-DETR Object Detection model, as described in https://arxiv.org/abs/2304.08069.
class_docstr_tok: ["RT-DETR","Object","Detection","model",",","as","described","in","https",":","\/\/arxiv.org\/abs\/2304.08069","."]
docstr: Construct RT-DETR Object Detection model from a config object.
  
  Args:
      config: configuration object for RT-DETR.
  
  .. note::
      For ``config.neck_hidden_dim``, ``config.neck_dim_feedforward``, ``config.neck_expansion``, and
      ``config.head_num_decoder_layers``, if they are ``None``, their values will be replaced with the
      default values depending on the ``config.model_type``. See the source code for the default values.
docstr_tok: ["Construct","RT-DETR","Object","Detection","model","from","a","config","object",".","Args",":","config",":","configuration","object","for","RT-DETR",".","..","note",":",":","For","``","config.neck_hidden_dim","``",",","``","config.neck_dim_feedforward","``",",","``","config.neck_expansion","``",",","and","``","config.head_num_decoder_layers","``",",","if","they","are","``","None","``",",","their","values","will","be","replaced","with","the","default","values","depending","on","the","``","config.model_type","``",".","See","the","source","code","for","the","default","values","."]
code: def from_config(config: RTDETRConfig) -> RTDETR:
      """Construct RT-DETR Object Detection model from a config object.
  
      Args:
          config: configuration object for RT-DETR.
  
      .. note::
          For ``config.neck_hidden_dim``, ``config.neck_dim_feedforward``, ``config.neck_expansion``, and
          ``config.head_num_decoder_layers``, if they are ``None``, their values will be replaced with the
          default values depending on the ``config.model_type``. See the source code for the default values.
      """
      model_type = config.model_type
      if isinstance(model_type, int):
          model_type = RTDETRModelType(model_type)
      elif isinstance(model_type, str):
          model_type = getattr(RTDETRModelType, model_type)
  
      backbone: ResNetD | PPHGNetV2
  
      if model_type == RTDETRModelType.resnet18d:
          backbone = ResNetD.from_config(18)
          neck_hidden_dim = config.neck_hidden_dim or 256
          neck_dim_feedforward = config.neck_dim_feedforward or 1024
          head_num_decoder_layers = config.head_num_decoder_layers or 3
          neck_expansion = config.neck_expansion or 0.5
  
      elif model_type == RTDETRModelType.resnet34d:
          backbone = ResNetD.from_config(34)
          neck_hidden_dim = config.neck_hidden_dim or 256
          neck_dim_feedforward = config.neck_dim_feedforward or 1024
          head_num_decoder_layers = config.head_num_decoder_layers or 4
          neck_expansion = config.neck_expansion or 0.5
  
      elif model_type == RTDETRModelType.resnet50d:
          backbone = ResNetD.from_config(50)
          neck_hidden_dim = config.neck_hidden_dim or 256
          neck_dim_feedforward = config.neck_dim_feedforward or 1024
          head_num_decoder_layers = config.head_num_decoder_layers or 6
          neck_expansion = config.neck_expansion or 1.0
  
      elif model_type == RTDETRModelType.resnet101d:
          backbone = ResNetD.from_config(101)
          neck_hidden_dim = config.neck_hidden_dim or 384
          neck_dim_feedforward = config.neck_dim_feedforward or 2048
          head_num_decoder_layers = config.head_num_decoder_layers or 6
          neck_expansion = config.neck_expansion or 1.0
  
      elif model_type == RTDETRModelType.hgnetv2_l:
          backbone = PPHGNetV2.from_config("L")
          neck_hidden_dim = config.neck_hidden_dim or 256
          neck_dim_feedforward = config.neck_dim_feedforward or 1024
          head_num_decoder_layers = config.head_num_decoder_layers or 6
          neck_expansion = config.neck_expansion or 1.0
  
      elif model_type == RTDETRModelType.hgnetv2_x:
          backbone = PPHGNetV2.from_config("X")
          neck_hidden_dim = config.neck_hidden_dim or 384
          neck_dim_feedforward = config.neck_dim_feedforward or 2048
          head_num_decoder_layers = config.head_num_decoder_layers or 6
          neck_expansion = config.neck_expansion or 1.0
  
      model = RTDETR(
          backbone,
          HybridEncoder(
              backbone.out_channels,
              neck_hidden_dim,
              neck_dim_feedforward,
              neck_expansion,
          ),
          RTDETRHead(
              num_classes=config.num_classes,
              hidden_dim=config.head_hidden_dim,
              num_queries=config.head_num_queries,
              in_channels=[neck_hidden_dim] * 3,
              num_decoder_layers=head_num_decoder_layers,
          ),
      )
  
      if config.checkpoint:
          model.load_checkpoint(config.checkpoint)
      return model
  
file_path: kornia/kornia/contrib/models/rt_detr/model.py
imports: from __future__ import annotations
  from dataclasses import dataclass
  from enum import Enum
  from typing import Optional
  from kornia.contrib.models.base import ModelBase
  from kornia.contrib.models.rt_detr.architecture.hgnetv2 import PPHGNetV2
  from kornia.contrib.models.rt_detr.architecture.hybrid_encoder import HybridEncoder
  from kornia.contrib.models.rt_detr.architecture.resnet_d import ResNetD
  from kornia.contrib.models.rt_detr.architecture.rtdetr_head import RTDETRHead
  from kornia.core import Tensor
label_desc: Use image node_id 2 for calling the RTDETR obj's underlying member method code with example usage: obj.from_config(config) and returns: model