0

I have followed the tutorial from this website https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=U5LhISJqWXgM. The question is: there were images that contained 'person' and many other instances but why weren't they detected and segmented?

from detectron2.utils.visualizer import ColorMode
dataset_dicts = get_balloon_dicts("balloon/val")
for d in random.sample(dataset_dicts, 3):    
    im = cv2.imread(<CUSTOM_IMAGE_CONTAINING_PERSON_DETECTED_WHEN_CUSTOM_WASNT_USED>) <--changed
    outputs = predictor(im)
    v = Visualizer(im[:, :, ::-1],
                   metadata=balloon_metadata, 
                   scale=0.8, 
                   instance_mode=ColorMode.IMAGE_BW   # remove the colors of unsegmented pixels
    )
    v = v.draw_instance_predictions(outputs["instances"].to("cpu"))
    cv2_imshow(v.get_image()[:, :, ::-1])

After downloading a custom photo containing people I ran inference on the image as instructured under Run a pre-trained detectron2 model using the model they used (model_zoo.get_checkpoint_url("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")) but when I use the trained model of the balloons it does not detect the people in the image (the threshold was not the problem since I used 0.5 in both cases). Why is it so and how would I be able to make it show all the instances? Help would be greatly appreciated :D

  • Why would a model trained on balloon dataset detect persons? You need to use model trained on COCO as mentioned in _Run a pre-trained detectron2 model_ section earlier. – kHarshit May 07 '20 at 07:21
  • So once a model is trained on a custom dataset the resulting one can only detect the custom class dataset and not anything else? I am new to this so had ahard time understanding. If this is the case how would I train it on a custom dataset such that it does not "forget" about the "person"/"car" etc so that when i run this new model it detects balloons ans everything it could detect before? – Jayed Ar Rabbi May 07 '20 at 09:32
  • It depends on how you modify the model during transfer learning. In the above example, the final layers were modified to predict only one class (balloon), so it can only predict balloon. To add more classes to existing model, you may look at [link1](https://datascience.stackexchange.com/q/15656/30543), [link2](https://stackoverflow.com/q/59236502/6210807). – kHarshit May 07 '20 at 13:16
  • oka thanks a lot for it :D – Jayed Ar Rabbi May 07 '20 at 13:36

0 Answers0