0

I have COCOEvaluator implemented into my Detectron2 network, however I need to output the evaluation metrics (AP) into variable so I can work with it further. I cant figure out how to do that, or what to call? The only thing that "works" is reading the cell output, but that is clumsy and very time ineffective.

I am calling the evaluator by:

 evaluator = COCOEvaluator("test_dataset", output_dir="/content/output")
 val_loader = build_detection_test_loader(cfg, "test_dataset")
 print(inference_on_dataset(predictor.model, val_loader, evaluator))

which outputs metrics as:

Evaluator metrics

I need to output the AP values to variables that could be called in future code. Anyone knows how? Thanks!

Deamoon
  • 3
  • 4

1 Answers1

0

Figured it out, I don't know why I did not try this earlier:

Just write the inference into a file:

                evaluator = COCOEvaluator("manittol_s_test", output_dir="/content/output")
            val_loader = build_detection_test_loader(cfg, "manittol_s_test")

            with open(path,"w") as cpt:
              print(inference_on_dataset(predictor.model, val_loader, evaluator), file=cpt)

and read the needed attributes from that file.

Deamoon
  • 3
  • 4