YOLOv6 icon indicating copy to clipboard operation
YOLOv6 copied to clipboard

Error in evaluate and save model

Open geekdreamer04 opened this issue 2 years ago • 3 comments

Evaluating mAP by pycocotools. Saving runs/train/exp14/predictions.json... loading annotations into memory... Done (t=6.09s) creating index... index created! Loading and preparing results... ERROR in evaluate and save model. ERROR in training loop or eval/save model.

Training completed in 0.474 hours. Traceback (most recent call last): File "tools/train.py", line 94, in main(args) File "tools/train.py", line 84, in main trainer.train() File "/home/ubuntu/YOLOv6/yolov6/core/engine.py", line 70, in train self.train_in_loop() File "/home/ubuntu/YOLOv6/yolov6/core/engine.py", line 89, in train_in_loop self.eval_and_save() File "/home/ubuntu/YOLOv6/yolov6/core/engine.py", line 115, in eval_and_save self.eval_model() File "/home/ubuntu/YOLOv6/yolov6/core/engine.py", line 134, in eval_model results = eval.run(self.data_dict, File "/home/ubuntu/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context return func(*args, **kwargs) File "/home/ubuntu/YOLOv6/tools/eval.py", line 83, in run eval_result = val.eval_model(pred_result, model, dataloader, task) File "/home/ubuntu/YOLOv6/yolov6/core/evaler.py", line 127, in eval_model pred = anno.loadRes(pred_json) File "/home/ubuntu/anaconda3/envs/pytorch_p38/lib/python3.8/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

@meituan-gengyifei After the training is completed, before the evaluation results, I am getting the following error. I would really appreciate it, to get some insights on how to go about this issue as soon as possible.

geekdreamer04 avatar Jul 05 '22 05:07 geekdreamer04

I faced this issue when I was using custom dataset that was formatted in COCO format Are you using custom dataset? Have you recently cloned the repo? Please follow the directory structure provided in: Train custom set

ShisuiUzumaki avatar Jul 05 '22 06:07 ShisuiUzumaki

Thank you, I could solve the issue by configuring the dataset.yaml file as my data. I am using the COCO dataset itself, but only two classes. Maybe, considering this as a custom dataset scenario makes more sense right now

geekdreamer04 avatar Jul 05 '22 19:07 geekdreamer04

Yes, you will need to set:

# whether it is coco dataset, only coco dataset should be set to True.
is_coco: False

ShisuiUzumaki avatar Jul 06 '22 04:07 ShisuiUzumaki

@ShisuiUzumaki I already follow the directory structure, but still facing the same problem. I have a custom dataset

abdulghani91 avatar Feb 02 '23 15:02 abdulghani91

@ShisuiUzumaki I already follow the directory structure, but still facing the same problem. I have a custom dataset

What is your directory structure? Also, have you set is_coco = False in yaml file

ShisuiUzumaki avatar Feb 03 '23 03:02 ShisuiUzumaki

@ShisuiUzumaki I already set is_coco = False in yaml file, and follow the directory structure as in Train custom data down below is the log of the error its create a Jason file for my dataset annotation but stop with the eval an give the error below.


ERROR in evaluate and save model. ERROR in training loop or eval/save model.

Training completed in 0.074 hours. Traceback (most recent call last): File "D:\yolov\YOLOv6\tools\train.py", line 92, in main(args) File "D:\yolov\YOLOv6\tools\train.py", line 82, in main trainer.train() File "D:\yolov\YOLOv6\yolov6\core\engine.py", line 70, in train self.train_in_loop() File "D:\yolov\YOLOv6\yolov6\core\engine.py", line 89, in train_in_loop self.eval_and_save() File "D:\yolov\YOLOv6\yolov6\core\engine.py", line 115, in eval_and_save self.eval_model() File "D:\yolov\YOLOv6\yolov6\core\engine.py", line 134, in eval_model results = eval.run(self.data_dict, File "C:\Users\abdul\AppData\Roaming\Python\Python310\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "D:\yolov\YOLOv6\tools\eval.py", line 83, in run eval_result = val.eval_model(pred_result, model, dataloader, task) File "D:\yolov\YOLOv6\yolov6\core\evaler.py", line 128, in eval_model cocoEval = COCOeval(anno, pred, 'bbox') File "C:\Users\abdul\AppData\Roaming\Python\Python310\site-packages\pycocotools\cocoeval.py", line 80, in init self.params.imgIds = sorted(cocoGt.getImgIds()) TypeError: '<' not supported between instances of 'int' and 'str'

How to fix this?

abdulghani91 avatar Feb 03 '23 04:02 abdulghani91

@ShisuiUzumaki I already set is_coco = False in yaml file, and follow the directory structure as in Train custom data down below is the log of the error its create a Jason file for my dataset annotation but stop with the eval an give the error below.

ERROR in evaluate and save model. ERROR in training loop or eval/save model.

Training completed in 0.074 hours.

Traceback (most recent call last): File "D:\yolov\YOLOv6\tools\train.py", line 92, in main(args) File "D:\yolov\YOLOv6\tools\train.py", line 82, in main trainer.train() File "D:\yolov\YOLOv6\yolov6\core\engine.py", line 70, in train self.train_in_loop() File "D:\yolov\YOLOv6\yolov6\core\engine.py", line 89, in train_in_loop self.eval_and_save() File "D:\yolov\YOLOv6\yolov6\core\engine.py", line 115, in eval_and_save self.eval_model() File "D:\yolov\YOLOv6\yolov6\core\engine.py", line 134, in eval_model results = eval.run(self.data_dict, File "C:\Users\abdul\AppData\Roaming\Python\Python310\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "D:\yolov\YOLOv6\tools\eval.py", line 83, in run eval_result = val.eval_model(pred_result, model, dataloader, task) File "D:\yolov\YOLOv6\yolov6\core\evaler.py", line 128, in eval_model cocoEval = COCOeval(anno, pred, 'bbox') File "C:\Users\abdul\AppData\Roaming\Python\Python310\site-packages\pycocotools\cocoeval.py", line 80, in init self.params.imgIds = sorted(cocoGt.getImgIds()) TypeError: '<' not supported between instances of 'int' and 'str' How to fix this?

There is a possibility that there is a string in your variables that is being compared with ints. Why not debug it from the given line to see what is happening there?

ShisuiUzumaki avatar Feb 09 '23 03:02 ShisuiUzumaki

@ShisuiUzumaki the names of my dataset images start with numbers. I rename the images with Pic_ (000), but there is space in the name of the images is this the cause of the problem?

what do you mean Why not debug it from the given line?

abdulghani91 avatar Feb 09 '23 15:02 abdulghani91

@ShisuiUzumaki the names of my dataset images start with numbers. I rename the images with Pic_ (000), but there is space in the name of the images is this the cause of the problem?

what do you mean Why not debug it from the given line?

I mean, if you are using pycharm or VS code you could add debug point on the cocoEval = COCOeval(anno, pred, 'bbox'). and jump into thee code and execute line by line to check state of various variables

ShisuiUzumaki avatar Feb 09 '23 15:02 ShisuiUzumaki