open-mmlab / mmdetection

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

Cannot train retinanet with a single class #2166

Closed manycoding closed 4 years ago

manycoding commented 4 years ago

Describe the bug I cannot get any results from training retinanet with 1 class. Log doesn't contain anything after 2020-02-26 14:50:59,227 - mmdet - INFO - workflow: [('train', 1)], max: 12 epochs, however gpu seems loaded.

Reproduction

  1. What command or script did you run? colab notebook config on gist
    !python tools/train.py "{home}/retinanet_fp16.py"
    !python tools/test.py "{home}/retinanet_fp16.py" {checkpoint_file} --eval mAP
  2. Did you make any modifications on the code or config? Did you understand what you have modified? I set num_classes=2,, yes I understand.
  3. What dataset did you use? I am using my custom dataset with about 70 images and bboxes.

I pickled annotations, here's the first line:

{'ann': {'bboxes': array([[ 25.373676, 293.4756  , 190.30257 , 336.04767 ]], dtype=float32),
  'labels': array([0])},
 'filename': '000001-2020-02-14T16:50:17.554Z.jpg',
 'height': 399,
 'width': 599}

Environment Google Colab with GPU

1.python mmdet/utils/collect_env.py

Liyw979 commented 4 years ago

Have you modify the CustomDataset dataset? The CustomDataset does not has the CLASSES attribute with it, which might leads to your issus.

take the CocoDataset as an example:

@DATASETS.register_module
class CocoDataset(CustomDataset):

    CLASSES = ('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus',
               'train', 'truck', 'boat', 'traffic_light', 'fire_hydrant',
               'stop_sign', 'parking_meter', 'bench', 'bird', 'cat', 'dog',
               'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe',
               'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
               'skis', 'snowboard', 'sports_ball', 'kite', 'baseball_bat',
               'baseball_glove', 'skateboard', 'surfboard', 'tennis_racket',
               'bottle', 'wine_glass', 'cup', 'fork', 'knife', 'spoon', 'bowl',
               'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot',
               'hot_dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
               'potted_plant', 'bed', 'dining_table', 'toilet', 'tv', 'laptop',
               'mouse', 'remote', 'keyboard', 'cell_phone', 'microwave',
               'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock',
               'vase', 'scissors', 'teddy_bear', 'hair_drier', 'toothbrush')
manycoding commented 4 years ago

@liyiwei979621500 I added it and see no difference.

@DATASETS.register_module
class SignDataset(CustomDataset):
    CLASSES = ("sign",)
Liyw979 commented 4 years ago

Is you annotation file in the COCO format?If so, you can try inherit the CocoDataset with CLASSES = ("sign",) I am not sure whether this would help.

manycoding commented 4 years ago

@liyiwei979621500 No, my annotation file is in CustomDataset format. I gave an example above.

xvjiarui commented 4 years ago

Hi @manycoding MMDet v2.0 has been released. You may set num_classes=1 in v2.0. Subset training is also supported in #2340 .

watertianyi commented 4 years ago

@xvjiarui How to label a single category with labelme and instance segmentation? There are cat, cat, cat, cat0, cat1, cat2 or cat-0, cat-1, cat-2, etc. which annotation method is used?thank you!

I use cat-0, cat-1, cat-2 for annotation, and use labelme2coco to convert annotations.json, where the annotation is [], what's the matter?