hustvl / ViTMatte

[Information Fusion (Vol.103, Mar. '24)] Boosting Image Matting with Pretrained Plain Vision Transformers
MIT License
339 stars 33 forks source link

I don't understand the following lines of code, please advise? #7

Closed goldwater668 closed 1 year ago

goldwater668 commented 1 year ago

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)

JingfengYao commented 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.