facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
30.19k stars 7.43k forks source link

AssertionError: RPN requires gt_instances in training! #5064

Open gabrielcustodio opened 1 year ago

gabrielcustodio commented 1 year ago

I can't train object detection:

Dataset dicts: {'bbox': [305, 709, 538, 577], 'bbox_mode': <BoxMode.XYXY_ABS: 0>, 'category_id': 6, 'file_name': '/home/azureuser/projects/1.jpg', 'height': 841, 'image_id': 8309, 'segmentation': [[[305, 709, 538, 577]]], 'width': 595} }

My code:

cfg = get_cfg()
cfg.merge_from_file(model_zoo.get_config_file("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml"))
cfg.DATASETS.TRAIN = ("vda_train_v31",)
cfg.DATASETS.TEST = ()
cfg.DATALOADER.NUM_WORKERS = 2
cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml")  # Let training initialize from model zoo
cfg.SOLVER.IMS_PER_BATCH = 2
cfg.SOLVER.BASE_LR = 0.00025  # pick a good LR 0.00025 
cfg.SOLVER.MAX_ITER = 300    # 300 iterations seems good enough for this toy dataset; you may need to train longer for a practical dataset
cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 128   # faster, and good enough for this toy dataset (default: 512)
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 7  # only has one class (ballon)

trainer = CocoTrainer(cfg)
trainer.resume_or_load(resume=False)
trainer.train()
github-actions[bot] commented 1 year ago

You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the issue template. The following information is missing: "Instructions To Reproduce the Issue and Full Logs"; "Your Environment";

ALIABB17 commented 1 week ago

Hello, i encountered the same issue, did you solve it?