当前位置:网站首页>Detectron2 usage model

Detectron2 usage model

2022-04-23 21:01:00 Top of the program

from Yacs Config Build the model
from yacs Configuration object , Model ( And its sub models ) Can pass build_model、build_backbone、build_roi_heads Equifunction construction :

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

build_model Build a random model with only structural parameters . About how to put existing checkpoint Information about loading into the model and how to use the model object , See below .

load / Save checkpoint

from detectron2.checkpoint import DetectionCheckpointer
DetectionCheckpointer(model).load(file_path_or_url)  # load a file, usually from cfg.MODEL.WEIGHTS

checkpointer = DetectionCheckpointer(model, save_dir="output")
checkpointer.save("model_999")  # save to output/model_999.pth

Detectron2 Checkpoint identification for pytorch Of .pth Format model , And us model zoon Medium .pkl file . More details about its usage , see also API file .

have access to torch.{load,save} Yes .pth File or pickle.{dump,load} Yes .pkl File arbitrary operation .

版权声明
本文为[Top of the program]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/111/202204210545090198.html