TannerGilbert / Object-Detection-and-Image-Segmentation-with-Detectron2

Object Detection and Image Segmentation with Detectron2
https://gilberttanner.com/blog/detectron-2-object-detection-with-pytorch
MIT License
153 stars 40 forks source link

Custom_mapper in instance segmentation #3

Closed morganaribeiro closed 3 years ago

morganaribeiro commented 3 years ago

Custom_mapper in instance segmentation

I would like to apply the "data augmentation in Detectron2":

Does it only serve for the "balloon detection" example you performed or does it also serve for "instance segmentation"? Because I am trying to apply it to a custom fish dataset, however, during the model inference, the segmented images + box and the label on the image are not appearing.

1. Please check the output images after this code in Colab:

from detectron2.utils.visualizer import ColorMode
dataset_dicts = DatasetCatalog.get('dataset_test')
for d in random.sample(dataset_dicts, 3):    
    im = cv2.imread(d["file_name"])
    outputs = predictor(im)  # format is documented at https://detectron2.readthedocs.io/tutorials/models.html#model-output-format
    v = Visualizer(im[:, :, ::-1],
                   metadata=fish_metadata, 
                   scale=0.5, 
                   instance_mode=ColorMode.IMAGE_BW   # remove the colors of unsegmented pixels. This option is only available for segmentation models
    )
    out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
    cv2_imshow(out.get_image()[:, :, ::-1])

Link to access the Colab code: Detectron2-Fish-segmentation @TannerGilbert Would you help me?

TannerGilbert commented 3 years ago

It should work for other data-set too. I'd try changing the augmentations and increasing the maximum number of steps. If this doesn't help, I'd remove the augmentations and retrain the model to see if the augmentations are really the problem.

I hope this helps. If you find anything out, let me know.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days