# Object Detection in Detectron2

Here is a list of the parameters that you can try to play around with in Detectron2.

{% embed url="<https://github.com/facebookresearch/detectron2/blob/654e2f40b07f40c9cb7be2e0c2266a59a7c9f158/detectron2/config/defaults.py>" %}

### Process

1. **Region Proposal Network (RPN):** The RPN is responsible for generating object proposals in an image. It takes an image as input and outputs a set of bounding box proposals, along with their objectness scores. These proposals serve as potential regions of interest (ROIs) for further processing.
   * `MODEL.RPN.PRE_NMS_TOPK_TRAIN`: The RPN proposals are ranked based on their objectness scores. This configuration option determines the number of top-scoring RPN proposals to keep before applying non-maximum suppression (NMS) during training. It limits the number of proposals to reduce computational overhead.
   * `MODEL.RPN.NMS_THRESH`: This option sets the IoU (Intersection over Union) threshold for NMS during training. Proposals with IoU higher than this threshold are considered redundant and suppressed, keeping only the highest-scoring proposal.
2. **ROI Heads:** The ROI Heads module takes the region proposals generated by the RPN and performs object classification and bounding box regression on these proposals to obtain the final predictions.
   * `MODEL.ROI_HEADS.IOU_THRESHOLDS`: This configuration option specifies a list of IoU thresholds to assign ground-truth labels to the region proposals during training. For example, if the IoU threshold is set to 0.5, any proposal with an IoU greater than or equal to 0.5 with a ground-truth box will be labeled as a positive sample.
   * `MODEL.ROI_HEADS.NMS_THRESH_TEST`: After classification and bounding box regression, NMS is applied to the predicted boxes to remove redundant detections during testing. This option sets the IoU threshold for NMS during inference.
   * `MODEL.ROI_HEADS.SCORE_THRESH_TEST`: This option sets the minimum confidence score threshold for retaining detections during inference. Detections with scores lower than this threshold are discarded as false positives.

{% embed url="<https://medium.com/p/47b2e794fabd>" %}
For more implementation details, check out this awesome guide.
{% endembed %}
