detectron2.model_zoo package

Model Zoo API for Detectron2: a collection of functions to create common model architectures and optionally load pre-trained weights as released in MODEL_ZOO.md.

detectron2.model_zoo.get(config_path, trained: bool = False)[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) – If True, will initialize the model with the trained model zoo weights. If False, the checkpoint specified in the config file’s MODEL.WEIGHTS is 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.

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_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