Giter Site home page Giter Site logo

训练自己的数据集问题 about yolov6 HOT 25 CLOSED

meituan avatar meituan commented on June 27, 2024
训练自己的数据集问题

from yolov6.

Comments (25)

ExWang avatar ExWang commented on June 27, 2024 3

When generate_coco_format_labels, this repo make img_id by osp.basename(img_path).split('.')[0] in datasets.py. You will get str label.

BUT, when evaluating results, this repo make img_id by int(path.stem) if path.stem.isnumeric() else path.stem in convert_to_coco_format in evaler.py. You may get int label.

Then, coco tools will check these img_id, so lead this AssertionError.

So I suggest to modify image_id = int(path.stem) if path.stem.isnumeric() else path.stem to image_id = path.stem to solve this error.

from yolov6.

mingwz avatar mingwz commented on June 27, 2024 1

Thanks for your reply! I solve the problem by this way. @ExWang

from yolov6.

nidetaoge avatar nidetaoge commented on June 27, 2024 1

Have already pulled the newest commit, but still get the same error:
pred = anno.loadRes(pred_json)
File "/opt/conda/lib/python3.8/site-packages/pycocotools/coco.py", line 341, in loadRes
assert set(annsImgIds) == (set(annsImgIds) & set(self.getImgIds())),
AssertionError: Results do not correspond to current coco set

from yolov6.

mingwz avatar mingwz commented on June 27, 2024

老哥你解决了吗?我也是遇到了相同的问题

from yolov6.

ruoyuchen0903 avatar ruoyuchen0903 commented on June 27, 2024

from yolov6.

ExWang avatar ExWang commented on June 27, 2024

so how can I solve it? 2022-06-27 15:05:30"Nebula Wang" @.>写道: when generate_coco_format_labels, this repo make img_id by osp.basename(img_path).split('.')[0] in datasets.py. You will get 'str' label. BUT, when evaluating results, this repo make img_id by 'int(path.stem) if path.stem.isnumeric() else path.stem'. You may get 'int' label. After, coco tools will check these img_id, so lead this AssertionError — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

image

from yolov6.

moxigk avatar moxigk commented on June 27, 2024

之前的错误是:
TypeError: '<' not supported between instances of 'str' and 'int'

我根据你的方法改了,出现了这个问题
AssertionError: Results do not correspond to current coco set

是不是数据集的名字必须是数字吗?不能包含英文吗或者其他字符吗?

from yolov6.

xiaoluxiaoluxiaolu avatar xiaoluxiaoluxiaolu commented on June 27, 2024

Hello, I would like to know which file needs to be modified

from yolov6.

ExWang avatar ExWang commented on June 27, 2024

Hello, I would like to know which file needs to be modified

no file need to be modified now, some one fix it, pull new repo will slove the problem.

from yolov6.

ExWang avatar ExWang commented on June 27, 2024

之前的错误是: TypeError: '<' not supported between instances of 'str' and 'int'

我根据你的方法改了,出现了这个问题 AssertionError: Results do not correspond to current coco set

是不是数据集的名字必须是数字吗?不能包含英文吗或者其他字符吗?

我看不是必须数字的,最早这个repo生成image_id用的 img_id = osp.basename(img_path).split('.')[0] 是str的id。但是在后面predict的时候,用的 img_id = int(path.stem) if path.stem.isnumeric() else path.stem ,也就是说,假设你的图片名字是数字的,就会转成int的id。这就造成了coco检查img_id的时候,发现他们对不上,引发了这个Error.

不过这个不统一的问题好像在最近的一个commit中修复了,pull一下最新的就行

from yolov6.

Mobu59 avatar Mobu59 commented on June 27, 2024

@nidetaoge have you fixed the problem?

from yolov6.

yutao007 avatar yutao007 commented on June 27, 2024

将这里的images_id修改后,仍然还是报错。感觉这一块有问题没有完全解决。其中我的环境是:
torch 1.10.0+cu111
torchaudio 0.10.0+rocm4.1
torchvision 0.11.0+cu111

修改处
def save_one_json(predn, jdict, path, class_map):
# Save one JSON result {"image_id": 42, "category_id": 18, "bbox": [258.15, 41.29, 348.26, 243.78], "score": 0.236}
#image_id = int(path.stem) if path.stem.isnumeric() else path.stem
image_id = path.stem

报错处
assert set(annsImgIds) == (set(annsImgIds) & set(self.getImgIds())),
AssertionError: Results do not correspond to current coco set
terminate called without an active exception
Aborted (core dumped)

from yolov6.

qybing avatar qybing commented on June 27, 2024

1.把datasets.py文件的img_id = int(path.stem) if path.stem.isnumeric() else path.stem改成img_id = path.stem
2.把evaler.py文件的image_id = int(path.stem) if path.stem.isnumeric() else path.stem改成img_id = path.stem
就可以运行起来了

from yolov6.

Mobu59 avatar Mobu59 commented on June 27, 2024

1.把datasets.py文件的img_id = int(path.stem) if path.stem.isnumeric() else path.stem改成img_id = path.stem 2.把evaler.py文件的image_id = int(path.stem) if path.stem.isnumeric() else path.stem改成img_id = path.stem 就可以运行起来了

Thanks, I made it

from yolov6.

yutao007 avatar yutao007 commented on June 27, 2024

谢谢博主解答,我已经按照提示将datasets.py evaler.py val.py 三个文件中关于image_id的赋值都改成了path.stem
但还是报错,如果别人没错的话,那应该就是我这边数据集或者别的问题了
assert set(annsImgIds) == (set(annsImgIds) & set(self.getImgIds())),
AssertionError: Results do not correspond to current coco set

from yolov6.

yutao007 avatar yutao007 commented on June 27, 2024

问题解决了,要记得删掉先前跑数据生成的json文件。

from yolov6.

luckyeap2020 avatar luckyeap2020 commented on June 27, 2024

之前的错误是: TypeError: '<' not supported between instances of 'str' and 'int'

我根据你的方法改了,出现了这个问题 AssertionError: Results do not correspond to current coco set

是不是数据集的名字必须是数字吗?不能包含英文吗或者其他字符吗?

不用改源代码,只用一个粗暴的方式解决了:

  1. 数据集中文件的名称只用数字
  2. 删除之前训练产生的所有过程文件,即只保留原始数据集的图片和标注

from yolov6.

ruabliuqiu avatar ruabliuqiu commented on June 27, 2024

训练前,自己数据集分布和制作方法跟yolov5一样,不需要json格式标签。我参考这个博主的方法训练成功了,https://blog.csdn.net/DeepLearning_/article/details/125511165?spm=1001.2014.3001.5502

from yolov6.

shenshi19 avatar shenshi19 commented on June 27, 2024

训练前,自己数据集分布和制作方法跟yolov5一样,不需要json格式标签。我参考这个博主的方法训练成功了,https://blog.csdn.net/DeepLearning_/article/details/125511165?spm=1001.2014.3001.5502
兄弟,你的yaml文件是什么样子的,我参考了你发的链接还是有问题的

from yolov6.

Yaomingyang avatar Yaomingyang commented on June 27, 2024

官方已经解决这个问题了,重新下载工程,按照docs/Train_custom_data.md运行即可

from yolov6.

ruabliuqiu avatar ruabliuqiu commented on June 27, 2024

训练前,自己数据集分布和制作方法跟yolov5一样,不需要json格式标签。我参考这个博主的方法训练成功了,https://blog.csdn.net/DeepLearning_/article/details/125511165?spm=1001.2014.3001.5502
兄弟,你的yaml文件是什么样子的,我参考了你发的链接还是有问题的

yaml中只保留train和val,去掉test和anno_path

from yolov6.

yaos666 avatar yaos666 commented on June 27, 2024

1.把datasets.py文件的img_id = int(path.stem) if path.stem.isnumeric() else path.stem改成img_id = path.stem 2.把evaler.py文件的image_id = int(path.stem) if path.stem.isnumeric() else path.stem改成img_id = path.stem 就可以运行起来了

成功啦,必须把datasets.py、evaler.py都改了才能运行起来,只改evaler.py文件还是会报错的哟

from yolov6.

shenshi19 avatar shenshi19 commented on June 27, 2024

1.把datasets.py文件的img_id = int(path.stem) if path.stem.isnumeric() else path.stem改成img_id = path.stem 2.把evaler.py文件的image_id = int(path.stem) if path.stem.isnumeric() else path.stem改成img_id = path.stem 就可以运行起来了

成功啦,必须把datasets.py、evaler.py都改了才能运行起来,只改evaler.py文件还是会报错的哟

新版的好像datasets.py好像img_id-int()那里改了

from yolov6.

suzauddola avatar suzauddola commented on June 27, 2024

Evaluating mAP by pycocotools.
Saving runs/train/ttop_6s_3004/predictions.json...
ERROR in evaluate and save model.
ERROR in training loop or eval/save model.

Training completed in 0.039 hours.
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
Loading and preparing results...
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 "/YOLOv6/yolov6/core/engine.py", line 70, in train
self.train_in_loop()
File "/YOLOv6/yolov6/core/engine.py", line 89, in train_in_loop
self.eval_and_save()
File "/YOLOv6/yolov6/core/engine.py", line 115, in eval_and_save
self.eval_model()
File "/YOLOv6/yolov6/core/engine.py", line 134, in eval_model
results = eval.run(self.data_dict,
File "/yolov6/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/YOLOv6/tools/eval.py", line 83, in run
eval_result = val.eval_model(pred_result, model, dataloader, task)
File "/YOLOv6/yolov6/core/evaler.py", line 127, in eval_model
pred = anno.loadRes(pred_json)
File "/home/suza/.conda/envs/yolov6/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

When generate_coco_format_labels, this repo make img_id by osp.basename(img_path).split('.')[0] in datasets.py. You will get str label.

BUT, when evaluating results, this repo make img_id by int(path.stem) if path.stem.isnumeric() else path.stem in convert_to_coco_format in evaler.py. You may get int label.

Then, coco tools will check these img_id, so lead this AssertionError.

So I suggest to modify image_id = int(path.stem) if path.stem.isnumeric() else path.stem to image_id = path.stem to solve this error.

After changing to "image_id = path.stem" now this error appears !!

from yolov6.

jcrdeep avatar jcrdeep commented on June 27, 2024

#207 (comment)

This resolved in my case

from yolov6.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.