Closed watertianyi closed 1 year ago
# Load model config. The config in 'configs/common/model.py' is ViTMatte-S
config = 'configs/common/model.py'
cfg = LazyConfig.load(config)
# Change some params to ViTMatte-B
cfg.model.backbone.embed_dim = 768
cfg.model.backbone.num_heads = 12
cfg.model.decoder.in_chans = 768
# instantiate and load pretrained weight
model = instantiate(cfg.model)
model.to('cuda')
model.eval()
DetectionCheckpointer(model).load(checkpoint)
If you are still confused, please refer to detectron2 'LazyConfig' for more detail.
config = 'configs/common/model.py' cfg = LazyConfig.load(config) cfg.model.backbone.embed_dim = 768 cfg.model.backbone.num_heads = 12 cfg.model.decoder.in_chans = 768 model = instantiate(cfg.model) model.to('cuda') model.eval() DetectionCheckpointer(model).load(checkpoint)