Load pretrained Detectron2 model as a Pytorch model

Any idea of how can I load a detectron2 pretrained model to use it as if it were a normal pytorch model?

Based on this doc it seems that you should be able to create the PyTorch model using:

from detectron2.modeling import build_model
model = build_model(cfg)  # returns a torch.nn.Module

Loading a checkpoint and using this model is also explained in the same doc.

I tryed to save the enrire detectron2 model. I want to run this model only installing pytorch. But fiid that it cant run without detectron2.