Detectron2: inference_on_dataset(trainer.model, val_loader, evaluator)

Created on 24 Nov 2019  路  3Comments  路  Source: facebookresearch/detectron2

hello everyone, I was following the tutorial on colab (baloon dataset) and I saw that in the line of code " inference_on_dataset (trainer.model, val_loader, evaluator) ", the trainer was passed and not the predictor. Reading the documentation, the inference_on_dataset function takes as input the model in eval mode. Is this a mistake? trying on the balloon dataset, the AP drops 13% passing predictor.model instead of training.model

Most helpful comment

ok, i have other two question:
1) trainer.model is already in eval mode when I pass it as an argument function?
2) if I have already trained the model and kept the weights, do I have to instantiate the trainer to use the inferece_on_dataset function? or can I still use the predictor?

All 3 comments

trainer.model is a model, therefore it's not a mistake.

The predictor in the colab tutorial was built with the same weights but different threshold configuration, therefore predictor.model will produce different results from trainer.model.

ok, i have other two question:
1) trainer.model is already in eval mode when I pass it as an argument function?
2) if I have already trained the model and kept the weights, do I have to instantiate the trainer to use the inferece_on_dataset function? or can I still use the predictor?

  1. inference_on_dataset will use the model in eval mode regardless of its original mode. I'll make the docs more clear on this.
  2. you can use either one. You can also just use build_model to obtain a model and load the weights, following https://detectron2.readthedocs.io/tutorials/models.html
Was this page helpful?
0 / 5 - 0 ratings

Related issues

AntonBaumannDE picture AntonBaumannDE  路  3Comments

ItamarSafriel picture ItamarSafriel  路  4Comments

jinfagang picture jinfagang  路  3Comments

RomRoc picture RomRoc  路  4Comments

choasup picture choasup  路  3Comments