detectron2.model_zoo¶
Model Zoo API for Detectron2: a collection of functions to create common model architectures listed in MODEL_ZOO.md, and optionally load their pre-trained weights.
-
detectron2.model_zoo.get_checkpoint_url(config_path)[source]¶ Returns the URL to the model trained using the given config
- Parameters
config_path (str) – config file name relative to detectron2’s “configs/” directory, e.g., “COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml”
- Returns
str – a URL to the model
-
detectron2.model_zoo.get(config_path, trained: bool = False, device: Optional[str] = None)[source]¶ Get a model specified by relative path under Detectron2’s official
configs/directory.- Parameters
config_path (str) – config file name relative to detectron2’s “configs/” directory, e.g., “COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml”
trained (bool) – see
get_config().device (str or None) – overwrite the device in config, if given.
- Returns
nn.Module – a detectron2 model. Will be in training mode.
Example:
from detectron2 import model_zoo model = model_zoo.get("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml", trained=True)
-
detectron2.model_zoo.get_config_file(config_path)[source]¶ Returns path to a builtin config file.
- Parameters
config_path (str) – config file name relative to detectron2’s “configs/” directory, e.g., “COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml”
- Returns
str – the real path to the config file.
-
detectron2.model_zoo.get_config(config_path, trained: bool = False)[source]¶ Returns a config object for a model in model zoo.
- Parameters
config_path (str) – config file name relative to detectron2’s “configs/” directory, e.g., “COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml”
trained (bool) – If True, will set
MODEL.WEIGHTSto trained model zoo weights. If False, the checkpoint specified in the config file’sMODEL.WEIGHTSis used instead; this will typically (though not always) initialize a subset of weights using an ImageNet pre-trained model, while randomly initializing the other weights.
- Returns
CfgNode or omegaconf.DictConfig – a config object