class_docstr: ⚡ Constructor for the DETR Object Detection Model
  Warning: Currently support only DETR
class_docstr_tok: ["\u26a1","Constructor","for","the","DETR","Object","Detection","Model","Warning",":","Currently","support","only","DETR"]
code: def __init__(
      self,
      lr,
      lr_backbone,
      weight_decay,
      id2label,
      label2id,
      train_dataloader,
      val_dataloader,
      model_path="facebook/detr-resnet-50",
  ):
      super().__init__()
  
      self.train_dl = train_dataloader
      self.val_dl = val_dataloader
  
      # Load the base model
      model = DetrForObjectDetection.from_pretrained(model_path)
      state_dict = model.state_dict()
  
      # Remove class weights
      del state_dict["class_labels_classifier.weight"]
      del state_dict["class_labels_classifier.bias"]
  
      # Define new model with custom class classifier
      model = DetrForObjectDetection(
          DetrConfig.from_pretrained(
              model_path,
              num_labels=len(id2label),
              id2label=id2label,
              label2id=label2id,
          )
      )
      model.load_state_dict(state_dict, strict=False)
      self.model = model
  
      # Learning Rate
      # See https://github.com/PyTorchLightning/pytorch-lightning/pull/1896
      self.lr = lr
      self.lr_backbone = lr_backbone
      self.weight_decay = weight_decay
  
file_path: HugsVision/hugsvision/models/Detr.py
imports: import torch
  import pytorch_lightning
  from transformers import DetrConfig, DetrForObjectDetection
label_desc: Use image node_id 1 to create a new Detr object from inherited base classes: pl with example: obj = Detr(lr, lr_backbone, weight_decay, id2label, label2id, train_dataloader, val_dataloader, model_path)