2025-01-09 19:38:06,328 - modelscope - INFO - Save weights to ./workdirs/damoyolo_s/epoch_1_ckpt.pth
2025-01-09 19:38:06,978 - modelscope - INFO - Start evaluation (5 images).
100%|██████████| 1/1 [00:00<00:00, 2.25it/s]
2025-01-09 19:38:07,432 - modelscope - INFO - Total run time: 0:00:00.453139 (0.09062781333923339 s / img per device, on 1 devices)
2025-01-09 19:38:07,433 - modelscope - INFO - Model inference time: 0:00:00.173360 (0.03467192649841309 s / img per device, on 1 devices)
2025-01-09 19:38:07,480 - modelscope - INFO - Preparing results for COCO format
2025-01-09 19:38:07,481 - modelscope - INFO - Preparing bbox results
KeyError Traceback (most recent call last)
Cell In[20], line 33
18 kwargs = dict(
19 model=model_id,
20 gpu_ids=[ # 指定训练使用的gpu
(...)
29 work_dir='./workdirs',
30 )
31 trainer = build_trainer(
32 name=Trainers.tinynas_damoyolo, default_args=kwargs)
---> 33 trainer.train() # 训练log将会保存在./workdirs/damoyolo_s/train_log.txt
File /usr/local/lib/python3.10/site-packages/modelscope/trainers/cv/image_detection_damoyolo_trainer.py:151, in ImageDetectionDamoyoloTrainer.train(self)
149 else:
150 trainer = DamoyoloTrainer(self.cfg, None, None)
--> 151 trainer.train(local_rank=0)
File /usr/local/lib/python3.10/site-packages/modelscope/trainers/cv/image_detection_damoyolo_trainer.py:498, in DamoyoloTrainer.train(self, local_rank)
496 if (cur_iter + 1) % self.eval_interval_iters == 0:
497 time.sleep(0.003)
--> 498 self.evaluate(local_rank, self.cfg.dataset.val_ann)
499 self.model.train()
500 synchronize()
File /usr/local/lib/python3.10/site-packages/modelscope/trainers/cv/image_detection_damoyolo_trainer.py:565, in DamoyoloTrainer.evaluate(self, local_rank, val_ann)
562 os.makedirs(output_folder, exist_ok=True)
564 for data_loader_val in self.val_loader:
--> 565 inference(
566 evalmodel,
567 data_loader_val,
568 device=self.device,
569 output_folder=output_folder,
570 )
File /usr/local/lib/python3.10/site-packages/modelscope/models/cv/tinynas_detection/damo/apis/detector_inference.py:116, in inference(model, data_loader, iou_types, box_only, device, expected_results, expected_results_sigma_tol, output_folder, multi_gpu_infer)
107 torch.save(predictions, os.path.join(output_folder, 'predictions.pth'))
109 extra_args = dict(
110 box_only=box_only,
111 iou_types=iou_types,
112 expected_results=expected_results,
113 expected_results_sigma_tol=expected_results_sigma_tol,
114 )
--> 116 return evaluate(
117 dataset=dataset,
118 predictions=predictions,
119 output_folder=output_folder,
120 **extra_args)
File /usr/local/lib/python3.10/site-packages/modelscope/msdatasets/dataset_cls/custom_datasets/damoyolo/evaluation/init.py:24, in evaluate(dataset, predictions, output_folder, kwargs)
18 args = dict(
19 dataset=dataset,
20 predictions=predictions,
21 output_folder=output_folder,
22 kwargs)
23 if isinstance(dataset, datasets.COCODataset):
---> 24 return coco_evaluation(**args)
25 else:
26 dataset_name = dataset.class.name
File /usr/local/lib/python3.10/site-packages/modelscope/msdatasets/dataset_cls/custom_datasets/damoyolo/evaluation/coco/init.py:15, in coco_evaluation(dataset, predictions, output_folder, box_only, iou_types, expected_results, expected_results_sigma_tol)
6 def coco_evaluation(
7 dataset,
8 predictions,
(...)
13 expected_results_sigma_tol,
14 ):
---> 15 return do_coco_evaluation(
16 dataset=dataset,
17 predictions=predictions,
18 box_only=box_only,
19 output_folder=output_folder,
20 iou_types=iou_types,
21 expected_results=expected_results,
22 expected_results_sigma_tol=expected_results_sigma_tol,
23 )
File /usr/local/lib/python3.10/site-packages/modelscope/msdatasets/dataset_cls/custom_datasets/damoyolo/evaluation/coco/coco_eval.py:49, in do_coco_evaluation(dataset, predictions, box_only, output_folder, iou_types, expected_results, expected_results_sigma_tol)
47 if 'bbox' in iou_types:
48 logger.info('Preparing bbox results')
---> 49 coco_results['bbox'] = prepare_for_coco_detection(predictions, dataset)
51 results = COCOResults(*iou_types)
52 logger.info('Evaluating predictions')
File /usr/local/lib/python3.10/site-packages/modelscope/msdatasets/dataset_cls/custom_datasets/damoyolo/evaluation/coco/coco_eval.py:88, in prepare_for_coco_detection(predictions, dataset)
85 scores = prediction.get_field('scores').tolist()
86 labels = prediction.get_field('labels').tolist()
---> 88 mapped_labels = [
89 dataset.contiguous_category_id_to_json_id[i] for i in labels
90 ]
91 coco_results.extend([{
92 'image_id': original_id,
93 'category_id': mapped_labels[k],
94 'bbox': box,
95 'score': scores[k],
96 } for k, box in enumerate(boxes)])
97 return coco_results
File /usr/local/lib/python3.10/site-packages/modelscope/msdatasets/dataset_cls/custom_datasets/damoyolo/evaluation/coco/coco_eval.py:89, in (.0)
85 scores = prediction.get_field('scores').tolist()
86 labels = prediction.get_field('labels').tolist()
88 mapped_labels = [
---> 89 dataset.contiguous_category_id_to_json_id[i] for i in labels
90 ]
91 coco_results.extend([{
92 'image_id': original_id,
93 'category_id': mapped_labels[k],
94 'bbox': box,
95 'score': scores[k],
96 } for k, box in enumerate(boxes)])
97 return coco_results
新人提问大佬别笑话
我自己通过lableme 标注了15张图,10张拿来训练 看日志训练完成了,结果验证结果报错了吧