class_docstr: Class for loading the COCO dataset meant for the DETR ResNet50 model`.
  
  Implement the necessary methods to load the images, labels and generate model predictions in a format comprehensible
   by deepchecks.
class_docstr_tok: ["Class","for","loading","the","COCO","dataset","meant","for","the","DETR","ResNet50","model","`",".","Implement","the","necessary","methods","to","load","the","images",",","labels","and","generate","model","predictions","in","a","format","comprehensible","by","deepchecks","."]
docstr: Infer on a batch of images and return it in deepchecks format.
  
  Return a list of prediction tensors (one for each image) containing in each row:
  [x_min, y_min, width, height, confidence, class_id]
docstr_tok: ["Infer","on","a","batch","of","images","and","return","it","in","deepchecks","format",".","Return","a","list","of","prediction","tensors","(","one","for","each","image",")","containing","in","each","row",":","[","x_min",",","y_min",",","width",",","height",",","confidence",",","class_id","]"]
code: def infer_on_batch(
      self, batch, model, device
  ) -> Union[List[torch.Tensor], torch.Tensor]:
      """Infer on a batch of images and return it in deepchecks format.
  
      Return a list of prediction tensors (one for each image) containing in each row:
      [x_min, y_min, width, height, confidence, class_id]
      """
  
      processed_preds = []
      # Iterate over images in the batch
      for batch_idx in range(len(batch[0])):
          probas, bboxes_scaled = self._detect(
              batch[0][batch_idx], model, device
          )
          bboxes_scaled[:, 2:] = (
              bboxes_scaled[:, 2:] - bboxes_scaled[:, :2]
          )  # xyxy to xywh
  
          if len(probas) > 0:
              processed_pred = torch.cat(
                  [
                      bboxes_scaled,  # xywh bbox coordinates
                      probas.max(dim=1)[0].reshape(
                          (-1, 1)
                      ),  # confidence
                      self._convert_to_80_labels(
                          probas.argmax(dim=1).tolist()
                      ),
                  ],
                  # translated class id
                  dim=1,
              )
              processed_preds.append(processed_pred)
  
      return processed_preds
  
file_path: deepchecks/examples/integrations/hugging_face/deepchecks_hugging_face_tutorial.py
imports: import torch
  from transformers import DetrForObjectDetection
  from typing import Union, List, Iterable
  import numpy
  from deepchecks.vision import VisionData
  import torchvision.transforms
  from deepchecks.vision.datasets.detection import coco_torch
  from deepchecks.vision.datasets.detection import coco_utils
  from deepchecks.vision.vision_data import BatchOutputFormat
  from deepchecks.vision.checks import MeanAveragePrecisionReport
label_desc: Use image node_id 6 for calling the COCODETRData obj's underlying member method code with example usage: obj.infer_on_batch(batch, model, device) and returns: processed_preds