Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detectron2 Cannot find field 'gt_masks' in the given Instances! #225

Open
1 of 2 tasks
Kamal-Moha opened this issue Nov 23, 2023 · 0 comments
Open
1 of 2 tasks

Detectron2 Cannot find field 'gt_masks' in the given Instances! #225

Kamal-Moha opened this issue Nov 23, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Kamal-Moha
Copy link

Search before asking

  • I have searched the Roboflow Notebooks issues and found no similar bug report.

Notebook name

Train Detectron2 Segmentation on Custom Data

Bug

I have created a COCO json data using Roboflow and using that dataset in colab. In my roboflow, it clearly states that y dataset has exactly 2 classes.
image

But when run the below Detectron2 code to train m object detection model,

from detectron2.engine import DefaultTrainer

cfg = get_cfg()
cfg.merge_from_file(model_zoo.get_config_file("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml"))
cfg.DATASETS.TRAIN = ("my_dataset_train",)
cfg.DATASETS.TEST = ()
cfg.DATALOADER.NUM_WORKERS = 2
cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")  # Let training initialize from model zoo
cfg.SOLVER.IMS_PER_BATCH = 2  # This is the real "batch size" commonly known to deep learning people
cfg.SOLVER.BASE_LR = 0.00025  # pick a good LR
cfg.SOLVER.MAX_ITER = 300    
cfg.SOLVER.STEPS = []        # do not decay learning rate
cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 128   # The "RoIHead batch size"
cfg.MODEL.ROI_HEADS.NUM_CLASSES = 2  # has two classes(crop & weed).
os.makedirs(cfg.OUTPUT_DIR, exist_ok=True)
trainer = DefaultTrainer(cfg)
trainer.resume_or_load(resume=False)
trainer.train()

While running the code, it shows my dataset has 3 categories which is wrong.
image

This eventually leads the training code to get the below error;

AttributeError: Cannot find field 'gt_masks' in the given Instances!

Please, I need help as I have been stuck on this for the past 48 hours.

Environment

  • Google Colab

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@Kamal-Moha Kamal-Moha added the bug Something isn't working label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant