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.48k stars 7.48k forks source link

instance segmentation metric on custom dataset #1614

Closed skye95git closed 4 years ago

skye95git commented 4 years ago

❓ How to do something using detectron2

Describe what you want to do, including:

  1. what inputs you will provide, if any:
  2. what outputs you are expecting: I have an instance segmentation dataset(just one class:car) labeled with labelme, and I get I get the annotation file in JSON format. Now I want to evaluate the pre-training model on my dataset to get the AP, what should I do? Do I need to register the dataset as If I were training a custom dataset? "from detectron2.evaluation import COCOEvaluator, inference_on_dataset from detectron2.data import build_detection_test_loader evaluator = COCOEvaluator("car_val", cfg, False, output_dir="./output/") val_loader = build_detection_test_loader(cfg, "car_val") inference_on_dataset(trainer.model, val_loader, evaluator)" Can I get an AP by running the above command directly?

❓ What does an API do and how to use it?

Please link to which API or documentation you're asking about from https://detectron2.readthedocs.io/

NOTE:

  1. Only general answers are provided. If you want to ask about "why X did not work", please use the Unexpected behaviors issue template.

  2. About how to implement new models / new dataloader / new training logic, etc., check documentation first.

  3. We do not answer general machine learning / computer vision questions that are not specific to detectron2, such as how a model works, how to improve your training/make it converge, or what algorithm/methods can be used to achieve X.

ppwwyyxx commented 4 years ago

Do I need to register the dataset as If I were training a custom dataset?

yes

Can I get an AP by running the above command directly?

No. the pre-trained model will produce more classes and even if "car" is among them, it won't have the same id as in your dataset.

There is no such feature to automatically evaluate model of one dataset on another dataset. Maybe something like the following will work:

def new_model(inputs):
    outputs = model(inputs)
    # .. filter outputs, keep only cars, change its class ids
    return new_outputs