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: A helper function. Applies DETR detection to a single PIL image.
docstr_tok: ["A","helper","function",".","Applies","DETR","detection","to","a","single","PIL","image","."]
code: def _detect(self, im, model, device):
      """A helper function. Applies DETR detection to a single PIL image."""
  
      def box_cxcywh_to_xyxy(x):
          """Convert bounding box format from [cx, cy, w, h] to [xmin, ymin, xmax, ymax], when c is "center"."""
          x_c, y_c, w, h = x.unbind(1)
          b = [
              (x_c - 0.5 * w),
              (y_c - 0.5 * h),
              (x_c + 0.5 * w),
              (y_c + 0.5 * h),
          ]
          return torch.stack(b, dim=1).clip(0, 1)
  
      def rescale_bboxes(out_bbox, size):
          """Rescale bounding boxes from the DETR model's normalized output to the original image size."""
          img_w, img_h = size
          b = box_cxcywh_to_xyxy(out_bbox)
          b = b * torch.tensor(
              [img_w, img_h, img_w, img_h], dtype=torch.float32
          )
          return b
  
      # Apply the transform to the image.
      img = self.transforms(im).unsqueeze(0)
  
      # propagate through the model
      with torch.no_grad():
          outputs = model(img.to(device))
  
      # keep only predictions with 0.7+ confidence
      probas = outputs["logits"].softmax(-1)[0, :, :-1].cpu()
      keep = probas.max(-1).values > 0.7
  
      # convert boxes from [0; 1] normalized units to image scales.
      bboxes_scaled = rescale_bboxes(
          outputs["pred_boxes"][0, keep].cpu(), im.size
      )
      return probas[keep], bboxes_scaled
  
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 4 for calling the COCODETRData obj's underlying member method code with example usage: obj._detect(im, model, device) and returns: probas,  bboxes_scaled, torch, b