zylo117 / Yet-Another-EfficientDet-Pytorch

The pytorch re-implement of the official efficientdet with SOTA performance in real time and pretrained weights.
GNU Lesser General Public License v3.0
5.2k stars 1.27k forks source link

about the lable problems #226

Open aii-guo opened 4 years ago

aii-guo commented 4 years ago

你好, 我使用自己的coco dataset, 开始训练(mac的cpu看模型能否正常运行)的时候报错: targets[positive_indices, assigned_annotations[positive_indices, 4].long()] = 1 IndexError: index 18 is out of bounds for dimension 1 with size 18 我想应该是lable的问题,我把 model = EfficientDetBackbone(num_classes=(len(params.obj_list)+100), compound_coef=opt.compound_coef,ratios=eval(params.anchors_ratios), scales=eval(params.anchors_scales)) 的len(params.obj_list) 改为 len(params.obj_list)+100 后可以开始训练,但是训练开始没多久后报错。

我想问这是为什么,因为len(params.obj_list)应该就已经输出了正确的lable数量,但是为什么会直接报错,然后我在这个基础上+100却可以训练,但是一会也会报错呢? 谢谢

zylo117 commented 4 years ago

you should check your dataset first

aii-guo commented 4 years ago

you should check your dataset first

是的,我检测了dataset,确实有问题 error

{ "images": [ { "file_name": "ai_inside_0517_001.png", "height": 2480, "width": 3507, "id": 1 }, { "file_name": "ai_inside_0517_003.png", "height": 2480, "width": 3507, "id": 2 }, { "file_name": "ai_inside_0517_012.png", "height": 2480, "width": 3507, "id": 3 }, { "file_name": "ai_inside_0517_006.png", "height": 2480, "width": 3507, "id": 4 }, { "file_name": "ai_inside_0517_013.png", "height": 2480, "width": 3507, "id": 5 }, { "file_name": "ai_inside_0517_005.png", "height": 2480, "width": 3507, "id": 6 }, { "file_name": "ai_inside_0517_011.png", "height": 2480, "width": 3507, "id": 7 }, { "file_name": "ai_inside_0517_010.png", "height": 2480, "width": 3507, "id": 8 }, { "file_name": "ai_inside_0517_009.png", "height": 2480, "width": 3507, "id": 9 }, { "file_name": "ai_inside_0517_008.png", "height": 3507, "width": 2480, "id": 10 } ], 我的格式是这样的,是不是必须改成你那样的才行?

akb46mayu commented 4 years ago

你试试把annotation的 label 打印出来?理论上讲作者的cocodataset 默认好像是90 个class, 如果你的label 超过了100+90, 那可能是label超过范围了?

aii-guo commented 4 years ago

这个我已经改了project/coco.yml里面的label种类,改成了和自己的模型一样,但是依然报错,我觉得可能是dataset本身有问题

akb46mayu notifications@github.com于2020年4月29日 周三22:21写道:

你试试把annotation的 label 打印出来?理论上讲作者的cocodataset 默认好像是90 个class, 如果你的label 超过了100+90, 那可能是label超过范围了?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zylo117/Yet-Another-EfficientDet-Pytorch/issues/226#issuecomment-621197245, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANG5GKHU3Z6HBV5IPG5OLU3RPASV3ANCNFSM4MTKAVKA .

akb46mayu commented 4 years ago

我之前看了下dataset.py 那个file,那里面的coco label id映射好像是写死的。coco.yml file 好像只是在debug和可视化结果时才有用,那个值你改不改好像都不影响你train。你可能需要把dataset.py 的id映射改对才work。我是用的三个礼拜前的repo。

aii-guo commented 4 years ago

你好,对coco不是很熟悉,是这里吗// 很奇怪的是,我明明数据集只有18个label。。但是这里打印key和value显示有48个label。。可能还是dataset有问题

def load_classes(self):

# load class names (name -> label)
categories = self.coco.loadCats(self.coco.getCatIds())
categories.sort(key=lambda x: x['id'])
# print('categories', categories)

self.classes = {}
self.coco_labels = {}
self.coco_labels_inverse = {}
for c in categories:
    self.coco_labels[len(self.classes)] = c['id']
    self.coco_labels_inverse[c['id']] = len(self.classes)
    self.classes[c['name']] = len(self.classes)

# also load the reverse (label -> name)
self.labels = {}
for key, value in self.classes.items():
    self.labels[value] = key

akb46mayu notifications@github.com于2020年4月29日 周三22:29写道:

我之前看了下dataset.py 那个file,那里面的coco label id映射好像是写死的。coco.yml file 好像只是在debug和可视化结果时才有用,那个值你改不改好像都不影响你train。你可能需要把dataset.py 的id映射改对才work。我是用的三个礼拜前的repo。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zylo117/Yet-Another-EfficientDet-Pytorch/issues/226#issuecomment-621206372, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANG5GKCBLNG6MTIKVWX2VN3RPATR7ANCNFSM4MTKAVKA .

akb46mayu commented 4 years ago

两方面,dataset可能有问题。另一方面你要看看你model 的classification head 输出是否是18。你的classfication head的class输出至少应该大于你label的总数。我推测你的模型定义了18个类,但是data提供了48 个id,所以会报错。 我建议你问问原作者,我之前也不大熟悉coco。你也许需要自己写dataloader,我不大确定哈。

aii-guo commented 4 years ago

我这个加载label的方法肯定有问题。。。我加载出来1272个label。。

2020年4月29日(水) 22:29 akb46mayu notifications@github.com:

我之前看了下dataset.py 那个file,那里面的coco label id映射好像是写死的。coco.yml file 好像只是在debug和可视化结果时才有用,那个值你改不改好像都不影响你train。你可能需要把dataset.py 的id映射改对才work。我是用的三个礼拜前的repo。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zylo117/Yet-Another-EfficientDet-Pytorch/issues/226#issuecomment-621206372, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANG5GKCBLNG6MTIKVWX2VN3RPATR7ANCNFSM4MTKAVKA .

akb46mayu commented 4 years ago

嗯嗯,这可能是原因所在。。。。。

aii-guo commented 4 years ago

我是直接xml文件做成coco的json文件,没有通过txt,你对这方面的数据集制作方法有了解吗

2020年4月29日(水) 22:58 akb46mayu notifications@github.com:

嗯嗯,这可能是原因所在。。。。。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zylo117/Yet-Another-EfficientDet-Pytorch/issues/226#issuecomment-621227020, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANG5GKFT65XCWMP5GSWWZPTRPAW73ANCNFSM4MTKAVKA .

akb46mayu commented 4 years ago

在下不才,目前还没搞这方面的。但是pytorch官网好像有关于dataloader的详细介绍;我记得repo里好像有人是用自己的数据集train的,你可以问问他们试试。

aii-guo commented 4 years ago

嗯嗯好的,谢谢你

akb46mayu notifications@github.com于2020年4月30日 周四00:11写道:

在下不才,目前还没搞这方面的。但是pytorch官网好像有关于dataloader的详细介绍;我记得repo里好像有人是用自己的数据集train的,你可以问问他们试试。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zylo117/Yet-Another-EfficientDet-Pytorch/issues/226#issuecomment-621275280, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANG5GKDNZKWJECA3HCW4PPLRPA7STANCNFSM4MTKAVKA .

akb46mayu commented 4 years ago

不客气哈哈