docstr: 将预测的结果转换成COCOeval指定的格式，针对目标检测任务
code: def prepare_for_coco_detection(self, ann, output):
      """将预测的结果转换成COCOeval指定的格式，针对目标检测任务"""
      # 遍历每张图像的预测结果
      if len(output[0]) == 0:
          return
  
      img_id = ann[2]["img_id"]
      per_image_boxes = output[0]
      per_image_boxes = scale_coords(
          img1_shape=ann[2]["shape"],
          coords=per_image_boxes,
          img0_shape=ann[2]["origin_shape"],
          ratio_pad=ann[2]["ratio_pad"],
      )
      # 对于coco_eval, 需要的每个box的数据格式为[x_min, y_min, w, h]
      # 而我们预测的box格式是[x_min, y_min, x_max, y_max]，所以需要转下格式
      per_image_boxes[:, 2:] -= per_image_boxes[:, :2]
      per_image_classes = output[1].tolist()
      per_image_scores = output[2].tolist()
  
      # 遍历每个目标的信息
      for object_score, object_class, object_box in zip(
          per_image_scores, per_image_classes, per_image_boxes
      ):
          object_score = float(object_score)
          class_idx = int(object_class)
          if self.classes_mapping is not None:
              class_idx = self.classes_mapping[class_idx]
          # We recommend rounding coordinates to the nearest tenth of a pixel
          # to reduce resulting JSON file size.
          object_box = [round(b, 2) for b in object_box.tolist()]
  
          res = {
              "image_id": img_id,
              "category_id": class_idx,
              "bbox": object_box,
              "score": round(object_score, 3),
          }
          self.results.append(res)
  
imports: import os
  import time
  import json
  import copy
  import cv2
  import numpy
  import torch
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  import torchvision
  from pycocotools.coco import COCO
  from pycocotools.cocoeval import COCOeval
  from compression.api import DataLoader, Metric
label_desc: Use image node_id 2 for calling the EvalCOCOMetric obj's underlying member method code with example usage: obj.prepare_for_coco_detection(ann, output) without return types