evaluation
Train Config Evaluation App.
The pyodi train-config evaluation
app can be used to evaluate a given mmdetection
Anchor Generator Configuration to train your model using a specific training pipeline.
Procedure
Training performance of object detection model depends on how well generated anchors match with ground truth bounding boxes. This simple application provides intuitions about this, by recreating train preprocessing conditions such as image resizing or padding, and computing different metrics based on the largest Intersection over Union (IoU) between ground truth boxes and the provided anchors.
Each bounding box is assigned with the anchor that shares a largest IoU with it. We call overlap, to the maximum IoU each ground truth box has with the generated anchor set.
Example usage:
pyodi train-config evaluation \\
$TINY_COCO_ANIMAL/annotations/train.json \\
$TINY_COCO_ANIMAL/resources/anchor_config.py \\
--input-size [1280,720]
The app provides four different plots:
Cumulative Overlap
It shows a cumulative distribution function for the overlap distribution. This view helps to distinguish which percentage of bounding boxes have a very low overlap with generated anchors and viceversa.
It can be very useful to determine positive and negative thresholds for your training, these are the values that determine is a ground truth bounding box will is going to be taken into account in the loss function or discarded and considered as background.
Bounding Box Distribution
It shows a scatter plot of bounding box width vs height. The color of each point represent the overlap value assigned to that bounding box. Thanks to this plot we can easily observe pattern such low overlap values for large bounding boxes. We could have this into account and generate larger anchors to improve this matching.
Scale and Mean Overlap
This plot contains a simple histogram with bins of similar scales and its mean overlap value. It help us to visualize how overlap decays when scale increases, as we said before.
Log Ratio and Mean Overlap
Similarly to previous plot, it shows an histogram of bounding box log ratios and its mean overlap values. It is useful to visualize this relation and see how certain box ratios might be having problems to match with generated anchors. In this example, boxes with negative log ratios, where width is much larger than height, overlaps are very small. See how this matches with patterns observed in bounding box distribution plot, where all boxes placed near to x axis, have low overlaps.
API REFERENCE
load_anchor_config_file(anchor_config_file)
Loads the anchor_config_file
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anchor_config_file |
str
|
File with the anchor configuration. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dictionary with the training configuration. |
Source code in pyodi/apps/train_config/train_config_evaluation.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
train_config_evaluation(ground_truth_file, anchor_config, input_size=(1280, 720), show=True, output=None, output_size=(1600, 900), keep_ratio=False)
Evaluates the fitness between ground_truth_file
and anchor_config_file
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ground_truth_file |
Union[str, pd.DataFrame]
|
Path to COCO ground truth file or coco df_annotations DataFrame
to be used from
|
required |
anchor_config |
str
|
Path to MMDetection-like |
required |
input_size |
Tuple[int, int]
|
Model image input size. Defaults to (1333, 800). |
(1280, 720)
|
show |
bool
|
Show results or not. Defaults to True. |
True
|
output |
Optional[str]
|
Output directory where results going to be saved. Defaults to None. |
None
|
output_size |
Tuple[int, int]
|
Size of saved images. Defaults to (1600, 900). |
(1600, 900)
|
keep_ratio |
bool
|
Whether to keep the aspect ratio or not. Defaults to False. |
False
|
Examples:
# faster_rcnn_r50_fpn.py:
anchor_generator=dict(
type='AnchorGenerator',
scales=[8],
ratios=[0.5, 1.0, 2.0],
strides=[4, 8, 16, 32, 64]
)
Source code in pyodi/apps/train_config/train_config_evaluation.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|