

     def getitem(self, idx):
         # read in PIL image and target in COCO format
         img, target = super(CocoDetection, self).getitem(idx)
         # preprocess image and target: converting target to DETR format,
         # resizing + normalization of both image and target)
         image_id = self.ids[idx]
         target = {"image_id": image_id, "annotations": target}
         encoding = self.image_processor(images=img, annotations=target, return_tensors="pt")
         pixel_values = encoding["pixel_values"].squeeze()  # remove batch dimension
         target = encoding["labels"][0]  # remove batch dimension
         return {"pixel_values": pixel_values, "labels": target}