글 작성자: 만렙개발자

 

 

1. build model with config.yaml file

2. load weights with model.pth file

import torch

from detectron2.config import get_cfg
from detectron2.modeling import build_model
from detectron2.checkpoint import DetectionCheckpointer

config_path = 'config.yaml'
model_path = 'model_final.pth'

cfg = get_cfg()
cfg.merge_from_file(config_path)

model = build_model(cfg)
DetectionCheckpointer(model).load(model_path)