open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.57k stars 9.46k forks source link

ValueError: need at least one array to concatenate #2928

Closed BeingGod closed 3 years ago

BeingGod commented 4 years ago

I meet a ERROR when I trained my custom dataset whose format is COCO. I browsed some issues but them couldn't help me solve this problem.

My config file

_base_ = './faster_rcnn/faster_rcnn_r50_fpn_iou_1x_coco.py'

dataset_type = 'CocoDataset'
data_root = 'data/coco/'
classes= ('sick',)

data = dict(
    samples_per_gpu=2,
    workers_per_gpu=1,
    train=dict(
        type=dataset_type,
        classes=classes,
        ann_file=data_root + 'annotations/test.json',
    img_prefix=data_root + 'AI_2020_02/'
),
    val=dict(
        type=dataset_type,
        classes=classes,
        ann_file=data_root + 'annotations/test.json',
    img_prefix=data_root + 'AI_2020_02/'
),
    test=dict(
        type=dataset_type,
        classes=classes,
        ann_file=data_root + 'annotations/test.json',
    img_prefix=data_root + 'AI_2020_02/'
))

model = dict(
    roi_head=dict(
        bbox_head=dict(
            num_classes=1,)))

The content of test.json

{"info": {},
 "licenses": [], 
"images": [
{"file_name": "IM_0012.jpg", "height": 512, "width": 512, "id": 0}, 
{"file_name": "IM_0066.jpg", "height": 512, "width": 512, "id": 1},
 {"file_name": "IM_0809.jpg", "height": 512, "width": 512, "id": 2}...], 
"annotations": [
{"segmentation": [[]], "area": 288.0, "iscrowd": 0, "image_id": 0, "bbox": [281.0, 274.0, 16.0, 18.0], "category_id": 0, "id": 0}, 
{"segmentation": [[]], "area": 304.0, "iscrowd": 0, "image_id": 1, "bbox": [280.0, 274.0, 16.0, 19.0], "category_id": 0, "id": 1}, 
{"segmentation": [[]], "area": 272.0, "iscrowd": 0, "image_id": 2, "bbox": [280.0, 276.0, 16.0, 17.0], "category_id": 0, "id": 2},
 {"segmentation": [[]], "area": 288.0, "iscrowd": 0, "image_id": 3, "bbox": [279.0, 276.0, 16.0, 18.0], "category_id": 0, "id": 3}, 
{"segmentation": [[]], "area": 289.0, "iscrowd": 0, "image_id": 4, "bbox": [279.0, 276.0, 17.0, 17.0], "category_id": 0, "id": 4}...], 
"categories": [{"id": 0, "name": "sick"}]}

I make sure the type of image_id and id is int

Besides, I can train coco2017 normally.

BeingGod commented 4 years ago
  1. And I also want to know whether the image_id and id is only or not?
  2. Can share id in different json files? such as the id of IM_0000.jpg is 0 in train.json and the id of IM_0001.jpg is also 0 in val.json.
igonro commented 4 years ago
1. And I also want to know whether the `image_id` and `id` is **only** or not?

2. Can share id in different json files?
   such as the id of `IM_0000.jpg` is **0** in `train.json` and the id of `IM_0001.jpg` is **also 0** in `val.json`.

@BeingGod did you find out anything? I'm facing the same issue and I would like to know the answer to those questions you ask. Thanks!

ghost commented 4 years ago

Same here

gxCaesar commented 4 years ago

ME TOO.

WAMAWAMA commented 4 years ago

maybe you need to modify the mmdet/datasets/xxx.py and mmdet/core/evaluation/class_names.py for matching your own dataset👍

tingfengwanxiao commented 4 years ago

ME TOO.

have you solved it?

gxCaesar commented 4 years ago

Yes,you have to know the detail!

发送自 Windows 10 版邮件应用

发件人: tingfengwanxiao 发送时间: 2020年10月26日 20:12 收件人: open-mmlab/mmdetection 抄送: Caesar; Comment 主题: Re: [open-mmlab/mmdetection] ValueError: need at least one array toconcatenate (#2928)

ME TOO. have you solved it? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tingfengwanxiao commented 4 years ago

he detail!

then,how do you solve the problem,I can check whether I meet the same problem.

vpeopleonatank commented 4 years ago

he detail!

then,how do you solve the problem,I can check whether I meet the same problem.

I get same error message. I found a solution on issues and fixed it by change image_id from type string to int and value of key 'segmentation' from list to list of list like this

"segmentation": [1,2] -> "segmentation": [[1,2]]

All modification is in my coco json annotation!