RCNNConfig
ModelConfigRCNNConfig(num_classes: int = 80, in_channels: int = 3, roi_size: int = 227, context_pad: int = 16, dropout: float = 0.5, score_thresh: float = 0.05, nms_thresh: float = 0.3, max_detections: int = 300, fg_iou_thresh: float = 0.5, bbox_reg_iou_thresh: float = 0.6)Configuration for R-CNN.
R-CNN (Girshick et al., CVPR 2014) applies a CNN independently to each
region proposal (warped to a fixed roi_size × roi_size crop), then
feeds the flattened pool5 features through two FC layers before the
classification and bounding-box regression heads.
Original paper uses AlexNet (5 conv + 3 FC) as the backbone. The effective output of pool5 for a 227 × 227 input is 6 × 6 × 256 = 9 216.
Args:
num_classes: Number of foreground object classes.
Background is automatically added as class 0,
giving (num_classes + 1) output logits.
in_channels: Number of input image channels (3 for RGB).
context_pad: Pixels of image context kept around each proposal
in the warped frame (Appendix A's ).
0 warps the tight box.
roi_size: Each region proposal is warped to this square size
before being forwarded through the backbone.
Original paper: 227.
dropout: Dropout probability applied after fc6 and fc7.
score_thresh: Minimum class-score threshold applied during
post-processing (after softmax). Boxes whose
max class score is below this value are discarded.
nms_thresh: IoU threshold for per-class NMS at inference time.
max_detections: Maximum number of detections returned per image
after NMS.
Note:
Training — two of the paper's three stages. Passing
targetstoforwardtrains stage 1 (CNN fine-tuning, softmax cross-entropy over proposals at IoU >=fg_iou_thresh) and stage 3 (the class-specific bounding-box regressors on pool5 features, restricted to proposals at IoU >bbox_reg_iou_threshper Appendix C).Stage 2 — the per-class linear SVMs that replace the softmax at test time — is not part of the model. It is an offline pass over features cached from a frozen network, with positives drawn only from ground-truth boxes, negatives at IoU < 0.3, and hard negative mining across the whole dataset; the mining is what makes it work, and it is a pipeline rather than a layer.
lucid.models._utils._common.mine_hard_negativesimplements that loop over cached features — score the pool, keep the highest-scoring mistakes, refit, repeat — on top oflucid.models._utils._common.fit_linear_svm. Extracting the features from a frozen network over a whole dataset, and scoring with the resulting weights instead of the softmax, remain the caller's pipeline.
Examples
>>> from lucid.models.vision.rcnn._config import RCNNConfig
>>> cfg = RCNNConfig()
>>> cfg.model_type
'rcnn'
>>> cfg.num_classes, cfg.in_channels
(80, 3)