text: Title: mode.val(save_json=True),COCO API  AssertionError: Results do not correspond to current coco set.
  Body: ### Search before asking
  
  - [x] I have searched the Ultralytics YOLO [issues](https://github.com/ultralytics/ultralytics/issues) and [discussions](https://github.com/orgs/ultralytics/discussions) and found no similar questions.
  
  
  ### Question
  
  trian.py
  ```
  if __name__ == '__main__':
      from ultralytics import YOLO
      model = YOLO("yolo11n.pt") # load a pretrained model (recommended for training)
      model.train(data="coco8.yaml",device=0,batch=-1)
  ```
  yolo2json.py
  ```
  import os
  import json
  from PIL import Image
   
  # 设置数据集路径
  output_dir = "D:\YOLOv11\datasets\coco8"   #修改为YOLO格式的数据集路径；
  dataset_path = "D:\YOLOv11\datasets\coco8"  # 修改你想输出的coco格式数据集路径
  images_path = os.path.join(dataset_path,"images")
  labels_path = os.path.join(dataset_path,"labels")
   
  # 类别映射
  categories = [
      {"id": 0, "name": "person"},
      {"id": 1, "name": "bicycle"},
      {"id": 2, "name": "car"},
      {"id": 3, "name": "motorcycle"},
      {"id": 4, "name": "airplane"},
      {"id": 5, "name": "bus"},
      {"id": 6, "name": "train"},
      {"id": 7, "name": "truck"},
      {"id": 8, "name": "boat"},
      {"id": 9, "name": "traffic light"},
      {"id": 10, "name": "fire hydrant"},
      {"id": 11, "name": "stop sign"},
      {"id": 12, "name": "parking meter"},
      {"id": 13, "name": "bench"},
      {"id": 14, "name": "bird"},
      {"id": 15, "name": "cat"},  # 修改这里
      {"id": 16, "name": "dog"},
      {"id": 17, "name": "horse"},
      {"id": 18, "name": "sheep"},
      {"id": 19, "name": "cow"},
      {"id": 20, "name": "elephant"},
      {"id": 21, "name": "bear"},
      {"id": 22, "name": "zebra"},
      {"id": 23, "name": "giraffe"},
      {"id": 24, "name": "backpack"},
      {"id": 25, "name": "umbrella"},
      {"id": 26, "name": "handbag"},
      {"id": 27, "name": "tie"},
      {"id": 28, "name": "suitcase"},
      {"id": 29, "name": "frisbee"},
      {"id": 30, "name": "skis"},
      {"id": 31, "name": "snowboard"},
      {"id": 32, "name": "sports ball"},
      {"id": 33, "name": "kite"},
      {"id": 34, "name": "baseball bat"},
      {"id": 35, "name": "baseball glove"},
      {"id": 36, "name": "skateboard"},
      {"id": 37, "name": "surfboard"},
      {"id": 38, "name": "tennis racket"},
      {"id": 39, "name": "bottle"},
      {"id": 40, "name": "wine glass"},
      {"id": 41, "name": "cup"},
      {"id": 42, "name": "fork"},
      {"id": 43, "name": "knife"},
      {"id": 44, "name": "spoon"},
      {"id": 45, "name": "bowl"},
      {"id": 46, "name": "banana"},
      {"id": 47, "name": "apple"},
      {"id": 48, "name": "sandwich"},
      {"id": 49, "name": "orange"},
      {"id": 50, "name": "broccoli"},
      {"id": 51, "name": "carrot"},
      {"id": 52, "name": "hot dog"},
      {"id": 53, "name": "pizza"},
      {"id": 54, "name": "donut"},
      {"id": 55, "name": "cake"},
      {"id": 56, "name": "chair"},
      {"id": 57, "name": "couch"},
      {"id": 58, "name": "potted plant"},
      {"id": 59, "name": "bed"},
      {"id": 60, "name": "dining table"},
      {"id": 61, "name": "toilet"},
      {"id": 62, "name": "tv"},
      {"id": 63, "name": "laptop"},
      {"id": 64, "name": "mouse"},
      {"id": 65, "name": "remote"},
      {"id": 66, "name": "keyboard"},
      {"id": 67, "name": "cell phone"},
      {"id": 68, "name": "microwave"},
      {"id": 69, "name": "oven"},
      {"id": 70, "name": "toaster"},
      {"id": 71, "name": "sink"},
      {"id": 72, "name": "refrigerator"},
      {"id": 73, "name": "book"},
      {"id": 74, "name": "clock"},
      {"id": 75, "name": "vase"},
      {"id": 76, "name": "scissors"},
      {"id": 77, "name": "teddy bear"},
      {"id": 78, "name": "hair drier"},
      {"id": 79, "name": "toothbrush"}
  ]
  
   
  # YOLO格式转COCO格式的函数
  def convert_yolo_to_coco(x_center, y_center, width, height, img_width, img_height):
      x_min = (x_center - width / 2) * img_width
      y_min = (y_center - height / 2) * img_height
      width = width * img_width
      height = height * img_height
      return [x_min, y_min, width, height]
   
   
  # 初始化COCO数据结构
  def init_coco_format():
      return {
          "images": [],
          "annotations": [],
          "categories": categories
      }
   
   
  # 处理每个数据集分区
  for split in ['train',  'val']: #'test'
      coco_format = init_coco_format()
      annotation_id = 1
   
      for img_name in os.listdir(os.path.join(images_path, split)):
          if img_name.lower().endswith(('.png', '.jpg', '.jpeg')):
              img_path = os.path.join(images_path, split, img_name)
              label_path = os.path.join(labels_path, split, img_name.replace("jpg", "txt"))
   
              img = Image.open(img_path)
              img_width, img_height = img.size
              image_info = {
                  "file_name": img_name,
                  "id": len(coco_format["images"]) + 1,
                  "width": img_width,
                  "height": img_height
              }
              coco_format["images"].append(image_info)
   
              if os.path.exists(label_path):
                  with open(label_path, "r") as file:
                      for line in file:
                          category_id, x_center, y_center, width, height = map(float, line.split())
                          bbox = convert_yolo_to_coco(x_center, y_center, width, height, img_width, img_height)
                          annotation = {
                              "id": annotation_id,
                              "image_id": image_info["id"],
                              "category_id": int(category_id) + 1,
                              "bbox": bbox,
                              "area": bbox[2] * bbox[3],
                              "iscrowd": 0
                          }
                          coco_format["annotations"].append(annotation)
                          annotation_id += 1
   
      # 为每个分区保存JSON文件
      with open(os.path.join(output_dir, f"{split}_coco_format.json"), "w") as json_file:
          json.dump(coco_format, json_file, indent=4)
  
  ```
  vail.py
  ```
  if __name__ == '__main__':
      from ultralytics import YOLO
      from pycocotools.coco import COCO 
      from pycocotools.cocoeval import COCOeval
  
      model = YOLO("runs/detect/train11/weights/best.pt") # load a pretrained model (recommended for training)
      results=model.val(data="coco8.yaml",save_json=True,device=0,batch=1)
      
      anno = COCO("D:/YOLOv11/datasets/coco8/val_coco_format.json") # Load your JSON annotations
  
      pred = anno.loadRes(f"{results.save_dir}/predictions.json")   # Load predictions.json
      val = COCOeval(anno, pred, "bbox")
      val.evaluate()
      val.accumulate()
      val.summarize()
  ```
  vail.py 报错
  ```
  (yolov11) D:\YOLOv11>python vail.py
  Ultralytics 8.3.18 🚀 Python-3.11.7 torch-2.6.0+cu126 CUDA:0 (NVIDIA GeForce RTX 4060 Ti, 16380MiB)
  YOLO11n summary (fused): 238 layers, 2,616,248 parameters, 0 gradients, 6.5 GFLOPs
  val: Scanning D:\YOLOv11\datasets\coco8\labels\val.cache... 4 images, 0 backgrounds, 0 corrupt: 100%|██████████| 4/4 [00:00<?, ?it/s]
                   Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|██████████| 4/4 [00:01<00:00,  2.88it/s]
                     all          4         17      0.802       0.66      0.864      0.593
                  person          3         10       0.82      0.461      0.695      0.347
                     dog          1          1      0.707          1      0.995      0.697
                   horse          1          2      0.835          1      0.995      0.473
                elephant          1          2      0.779        0.5      0.508      0.153
                umbrella          1          1      0.669          1      0.995      0.995
            potted plant          1          1          1          0      0.995      0.895
  Speed: 2.2ms preprocess, 26.6ms inference, 0.0ms loss, 14.8ms postprocess per image
  Saving runs\detect\val18\predictions.json...
  Results saved to runs\detect\val18
  loading annotations into memory...
  Done (t=0.00s)
  creating index...
  index created!
  Loading and preparing results...
  Traceback (most recent call last):
    File "D:\YOLOv11\vail.py", line 56, in <module>
      pred = anno.loadRes(f"{results.save_dir}/predictions.json")   # Load predictions.json
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\ProgramData\anaconda3\Lib\site-packages\pycocotools\coco.py", line 327, in loadRes
      assert set(annsImgIds) == (set(annsImgIds) & set(self.getImgIds())), \
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  AssertionError: Results do not correspond to current coco set
  ```
  
  
  ### Additional
  
  I don't know why there's an error