<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vijay Dubey on Medium]]></title>
        <description><![CDATA[Stories by Vijay Dubey on Medium]]></description>
        <link>https://medium.com/@vijayshankerdubey550?source=rss-39c34cac19d7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6lPDVNvt8g9U7-hchWlSTg.png</url>
            <title>Stories by Vijay Dubey on Medium</title>
            <link>https://medium.com/@vijayshankerdubey550?source=rss-39c34cac19d7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:23:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vijayshankerdubey550/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mask RCNN]]></title>
            <link>https://medium.com/@vijayshankerdubey550/mask-rcnn-f419b9d9db6b?source=rss-39c34cac19d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f419b9d9db6b</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[object-detection]]></category>
            <dc:creator><![CDATA[Vijay Dubey]]></dc:creator>
            <pubDate>Tue, 06 Oct 2020 02:46:34 GMT</pubDate>
            <atom:updated>2020-10-06T02:46:34.885Z</atom:updated>
            <content:encoded><![CDATA[<h3>Table of Contents</h3><ul><li>Terminology</li><li>Understanding MaskRCNN</li><li>References</li></ul><h4>Terminology</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*aOpCosxtPYFDUiexAIWCew.png" /></figure><ul><li><strong>Classification(a): </strong>Just predicting the class of the objects present in the image.</li><li><strong>Object Detection(b): </strong>Classification as well as localization of the objects by predicting bounding boxes</li><li><strong>Semantic Segmentation(c): </strong>Partition the image into semantically meaningful parts, <em>and</em> to classify each part into one of the pre-determined classes, in othere words all pixels classified as belonging to one particular class are grouped together.</li><li><strong>Instance Segmentation(d)</strong>: Segment out each instance present in the image separately, irrespective of them belonging to the same class or not.</li></ul><h3>Understanding Mask RCNN</h3><h4>Novelty</h4><ul><li>Mask RCNN focusses on <strong>pixel-to-pixel alignment</strong>,which is the main missing piece of Fast/Faster R-CNN, by replacing ROIpool with ROIalign layer and this achieves improvement in predicting not only the masks, but also improves the classification and detection predictions significantly.</li><li>Also, <strong>mask and class prediction are decoupled</strong>, unlike the FCNs.A binary mask is predicted for each class independently, and the network’s RoI classification branch predicts the category. In contrast, FCNs usually perform per-pixel multi-class categorization,which couples segmentation and classification, and works poorly for instance segmentation</li></ul><p>We will discuss both of these ahead.</p><h4>Architecture</h4><ul><li>Two models have been experimented for the backbone(similar to the Faster R-CNN)architecture for feature extraction, namely ResNets and FPN(Feature Pyramid Networks)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*S9iwQpSz-tdiPoMrKxPbbQ.png" /><figcaption>Mask RCNN with FPN backbone</figcaption></figure><ul><li>MaskRCNN adds a third branch(in <strong>parallel</strong>), that outputs the object mask, with the two output branches of Faster R-CNN(discussed above) for each candidate object.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*Zi5UsM7K4Ahv1s-CJOA4yA.png" /><figcaption><a href="https://arxiv.org/pdf/1703.06870.pdf">source</a></figcaption></figure><p>We observe from the above image that the mask branch outputs K mxm binary masks <strong>for each RoI,</strong> where<strong> K is the number of classes</strong>(80 here, for COCO). This follows that each layer in the mask branch must maintain the explicit m×m object spatial layout, which in turn requires that the feature maps be well aligned with the image to preserve the explicit per-pixel spatial correspondence, which is ensured by the <strong>RoIalign </strong>layer, as discussed below.</p><h4>ROI Align</h4><p>RoI pooling contains two step of coordinates quantization: from original image into feature map (<strong>divide by stride</strong>) and from feature map into roi feature (use grid). <strong>For </strong>example in ROIpool, for the feature map, we calculate [x/16] for each x on the image, where 16 is a feature map stride and likewise, quantization is performed when dividing into bins like 2X2 above.<strong>Those quantizations cause a huge loss of location precision. In ROIalign, we use x/16 to properly align the extracted features with input pixels. </strong>See the example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*2PxtTlAUSxxddMOvr3XnoA.png" /></figure><p>To select 15 pixels from the original image, we just select <strong>15 * 25/128 ~= 2.93</strong> pixels while In RoIPool, we would have <strong>rounded and selected 2 pixels </strong>causing a slight misalignment. Also, we use <a href="https://en.wikipedia.org/wiki/Bilinear_interpolation">bilinear interpolation</a> to get a <strong>precise idea of what would be at pixel 2.93</strong>.</p><h4>Bilinear Interpolation</h4><p>We spent quite a lot of time understanding this and how is it used to estimate the pixel values at non-integer points. Here is a brief overview of the approach:</p><h4>RoIPool vs RoIAlign</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*xbD0BLxC-BQr04-zwORalw.png" /><figcaption>A feature map</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*qpJdC8-IgX4zOU-o1LK_1Q.png" /><figcaption>Imposing the RoI on the feature map and dividing into 2x2 grids</figcaption></figure><p>Doing RoIPool, if the expected warped output size is 2x2, we quantize the division, by taking floor(x/2) ,ceil(x/2) and floor(y/2) ,ceil(y/2), where x and y are width and height of the RoI. Then maxpooling is done in each of the bins to get a 2x2 size output, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/184/1*dVXITengv7Ort7ueWm1XhA.png" /></figure><p>For RoIAlign, as described in the paper, firstly, the RoI is divided into <strong>equal dimension</strong> bins(<strong>3.5x2.5</strong> in this case) and then, we use bilinear interpolation to compute the exact values of the input features at four regularly sampled locations(indicated by <strong>red x</strong>) in each RoI bin, and aggregate the result(using max or average).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*X9LoFdTJ1noP_agLBMR6zw.png" /><figcaption>RoIAlign with the same RoI as above</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*sTRf9qHE3sT18NzNnvknag.png" /><figcaption>Bilinear Interpolated values</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/111/1*BgAXbjw_OrXS4ZvLOMguQA.png" /><figcaption>After MaxPooling</figcaption></figure><h4>Loss Function</h4><p>The multi-task loss function is a sum of classification, localization and segmentation loss, defined as :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*kr8wYtcsXUcd2fZq9-5hEQ.png" /></figure><p>The former two are same as Faster RCNN. Since, for the mask branch, the total output is of size<strong> <em>K</em>⋅<em>m</em>²</strong>. To this a per-pixel sigmoid is applied, and <strong>Lmask </strong>is the average binary cross-entropy loss. <strong>Note that, not </strong>all the K masks contribute to the loss, but only the p-th mask, where p is the class label of the ground truth box, to which that RoI is associated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*cpXSD6QcskkA1elXq7yENg.png" /></figure><p><strong>Note</strong>: The mask target is the intersection between an RoI and its associated ground-truth mask</p><h4>Multinomial vs. Independent Masks</h4><ul><li>Replace <strong>softmax with sigmoid</strong>, in order to learn a mask for each class. Also since the classification branch already predicted the class, there is no need of using softmax again.</li><li>Mask R-CNN <strong>decouples mask and class prediction, i.e. </strong>the classification does not depend on mask prediction or vice-a-versa. Also, as the existing box branch predicts the class label, we generate a mask for each class without competition among classes (by a per-pixel sigmoid and a binary loss).</li><li>Using a per-pixel softmax and a multinomial loss (as commonly used in FCN), couples the tasks of mask and class prediction, and results in a severe loss in mask AP (5.5 points).</li><li>The result suggests that <strong>once the instance has been classified as a whole (by the box branch), it is sufficient to predict a binary mask without concern for the categories</strong>, which makes the model easier to train.</li></ul><h3>Results and Experiments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*aoZNvL7Vc1KkO3ffYexXiQ.png" /><figcaption>Instance segmentation mask AP on COCO test-dev, without any image augmentation,etc.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*3QU-OR4PCr8BkiPrL5Cpeg.png" /><figcaption>Decoupling via per class binary masks (sigmoid) vs multinomial masks (softmax).</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*Tv_OtO2MKWzc1Ur-BUGgsQ.png" /><figcaption>Improvements in Segmentation as well as detection caused by RoIAlign</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*ELss-Q-HggFIF8ERe54d-g.png" /><figcaption>Fully convolutional networks (FCN) vs.<br>multi-layer perceptrons (MLP) for mask prediction</figcaption></figure><p>FCNs improve results as they take advantage of explicitly encoding spatial layout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*ZTSpVzeqAZCtPB295dAVuA.png" /><figcaption>Object detection single-model results (bounding box AP), vs. state-of-the-art</figcaption></figure><p>The model, having RoIAlign instead of RoIPool in FasterRCNN performs better than the .On the other hand, it is 0.9 points box AP lower than Mask R-CNN solely due to the benefits of <strong>multi-task training</strong>.</p><h3>References</h3><ul><li><a href="https://engineering.matterport.com/splash-of-color-instance-segmentation-with-mask-r-cnn-and-tensorflow-7c761e238b46">https://engineering.matterport.com/splash-of-color-instance-segmentation-with-mask-r-cnn-and-tensorflow-7c761e238b46</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f419b9d9db6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Popular Object Detection datasets —  Analysis and Statistics]]></title>
            <link>https://medium.com/@vijayshankerdubey550/popular-object-detection-datasets-analysis-and-statistics-66acdacc3aa9?source=rss-39c34cac19d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/66acdacc3aa9</guid>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[dataset]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Vijay Dubey]]></dc:creator>
            <pubDate>Tue, 06 Oct 2020 02:34:59 GMT</pubDate>
            <atom:updated>2020-10-06T02:34:59.456Z</atom:updated>
            <content:encoded><![CDATA[<h3>Popular Object Detection datasets — Analysis and Statistics</h3><h3>Table of contents</h3><ul><li>Motivation</li><li>Issues with Datasets</li><li>Statistics used</li><li>Insights into COCO, VOC and DOTA datasets</li><li>References</li></ul><h3>Motivation</h3><p>The evolution of various models and techniques to achieve precise object detection(Classification + Localization) has been very fast in the recent times. Naturally a question arises, that given a dataset, which architecture and technique would <strong>best suit</strong>(time, memory, performance ) the dataset to achieve precise object detection, out of the plethora of object detection architectures and algorithms available out there.</p><p>To know more about the state of the art <strong>evaluation metrics </strong>for Object Detection algorithms, please refer here.//ADD a link</p><h3>Issues with Datasets</h3><p>There are multiple issues that a dataset can have that might lead to an object detection algorithm performing poorly. Some of them are listed below:</p><ul><li><strong>Intra-class variability : </strong>The dataset might have limited or no range of image variability i.e the <strong>appearance and shape</strong> of objects<br>might not vary a lot within each class. For the model to generalize well, it is important that training instances inside a class have greater variability among them. For example, views from different angles and orientations of cars will help to learn a more robust model, compared to one that is learned with images that have only front view of the car. In addition, the same object can appear vastly different under different viewing conditions, such as those resulting from changes in lighting, viewpoint and imaging techniques.</li><li><strong>Inter-class variability</strong> — The <strong>viewpoints and orientations</strong> of different instances in each category tend to be similar. A successful object detection approach must therefore be able to represent images in a manner that renders them invariant to such intra-class variations, but at the same time distinguishes images of the object class from all other images</li><li><strong>Image size</strong> : The sizes of the training examples might be all over the scatter plot i.e. a significant variation ranging from too small images to too large images. Some algorithms do resizing of the images, but if some images are really big then resizing them would lead to a <strong>loss of significant information</strong>. Also large image sizes have <strong>high memory </strong>as well as computational requirements.</li><li><strong>Class Imbalance</strong> : It has been established that class imbalance can have significant detrimental effect on training of traditional classifiers including multi-layer perceptrons . It affects both <strong>convergence during the training</strong> phase and <strong>generalization</strong> of a model on the test set.</li><li><strong>Object size to image size</strong> : The variation in image resolutions, sizes of objects and patterns depicted,and image scales, hampers CNN training and …, because the<strong> task-relevant information</strong> varies over spatial scales. Three main sources of natural variation are <strong>the location</strong>, the <strong>viewpoint</strong>, and the <strong>size of an object or pattern</strong>. Variations in location are dealt with very well by a CNN, which follows naturally from the weight sharing employed in the convolution layers. CNNs can also handle variations in viewpoint by creating filters that respond to viewpoint-invariant features . Size variations pose a particular challenge in CNNs, especially when dealing with image corpora containing images of varying resolutions and depicting objects and patterns at different sizes and scales.</li><li><strong>Background clutter</strong> : It has been observed that in cluttered backgrounds, both RCNN and FRCNN algorithm produces many false positives. More details and methods of overcoming is discussed in <a href="http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w11/Roy_Deep_Learning_Based_ICCV_2017_paper.pdf">this</a> paper.</li><li><strong>Occlusion</strong> : Objects that are heavily occluded are more difficult for a classification algorithm than unobstructed objects. More details and methods of overcoming is discussed in <a href="https://www.hindawi.com/journals/cin/2016/6425257/">this</a> paper.</li></ul><h3>Statistics used</h3><p>One needs to have a clear understanding of the dataset before using it on an algorithm and its inconvenient to look at the images manually, given the size of these datasets. Having a look at the following statistics would give a nice overview of the dataset and would be helpful in selecting an algorithm:</p><ul><li>Number of objects per category</li><li>Number of objects contained in a single image</li><li>Size of the images present in the dataset</li><li>Ratio of areas of Object size and Image size, for each object present in the image</li><li>Overlap between objects</li></ul><p>Now we will show the above statistics on some publicly available datasets and <strong>try to reason why some algorithms and optimizers work good, while some perform poorly on these datasets.</strong></p><h3>Insights into COCO, VOC and DOTA datasets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DN-VbcrEZ2tIDt47TZDzow.png" /><figcaption>Number of objects per category</figcaption></figure><p>Other than the Person class, which has a lot of training instances, the VOC dataset is fairly balanced on the other classes. In COCO also, the majority class is the person class. In the DOTA dataset, We observe that ship and small vehicles dominate the dataset, while classes as helicopter and fields are very less. That’s why we use only the instances of 6 classes, namely ship, large and small vehicle, plane, bridge and storage tank for training and inference purposes. Also that the other categories are not so relevant for our case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8HNLiyE1HIkPOraPVp2GA.png" /><figcaption>Number of objects contained in an image</figcaption></figure><p>Majority of images in the VOC dataset(<strong>around 85%</strong>) contains only 1 object instances, where as COCO has more number of training images as well as only 10% of images have 1 object per image. The satellite images are very dense and have a lot of objects ranging from around 40–50 objects(majority) to a few hundreds of objects in some images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XpHL23fUqbgxk5SCxhCCKQ.png" /><figcaption>Height vs Width of Image</figcaption></figure><p>Majority of the images in VOC are around in the range of 400–500 pixels(height and width both) and there is not a lot of difference in the height and width of a particular image, as can be observed from the diagonal(Y=X) nature of the graph. The minimum size is around 200X200, so very small images are not there. COCO has slightly larger images in the range of 400–650 pixels(height and width both). However, it also has some very small images around 100–150 pixels. There is a lot of variation in the image sizes of the DOTA dataset, but majority of the images are clustered in the range 1000–2500 pixels. However there are few images of sizes as large as 8k to 10k pixels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wJE7TYfIFLuUmx4i5uPXGw.png" /><figcaption>Ratio of area of Object to the area of Image</figcaption></figure><p>From the VOC histogram, it can be seen that are are comparatively larger objects with little or no contextual information. However COCO’s focus is on non-iconic images with context and background to learn robust models, as mentioned in the paper. In DOTA dataset, the satellite images are quite large in size and the object sizes are really small(a few pixels only). So the <strong>ratio is quite close to 0 </strong>for majority of the objects. This motivates us to crop the images into several patches and use it for training and inference, instead of resizing it to a smaller size, as used by the standard object detectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzVVCnIZBJhq-2aKgxwzqw.png" /><figcaption>Measuring Overlap between objects in an Image with IoU</figcaption></figure><p>Majority of the objects in all the three datasets do not overlap with each other as can be seen from the above graphs. However there is some overlap with an IoU of around 0.1 and still fewer further. In the DOTA dataset, we converted the <strong>OBB(Oriented Bounding Boxes)</strong> to horizontal ones(by taking the min and max x,y coordinates and drawing the rectangle), yet we observe that there is very less overlap. This motivates us to use these horizontal bounding boxes on standard object detection algorithms like Yolov3 or RetinaNet, hoping that there won’t be a significant degradation in performance as compared to Mask-RCNN, which is included in<strong> future work</strong>.</p><h3>References</h3><ul><li><a href="https://www.robots.ox.ac.uk/~vgg/publications/2006/Ponce06/ponce06.pdf">https://www.robots.ox.ac.uk/~vgg/publications/2006/Ponce06/ponce06.pdf</a></li><li><a href="http://ilab.usc.edu/publications/doc/Borji_etal16cvpr.pdf">http://ilab.usc.edu/publications/doc/Borji_etal16cvpr.pdf</a></li><li><a href="https://arxiv.org/pdf/1710.05381.pdf">https://arxiv.org/pdf/1710.05381.pdf</a></li><li><a href="https://arxiv.org/pdf/1602.01255.pdf">https://arxiv.org/pdf/1602.01255.pdf</a></li><li><a href="http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w11/Roy_Deep_Learning_Based_ICCV_2017_paper.pdf">http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w11/Roy_Deep_Learning_Based_ICCV_2017_paper.pdf</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66acdacc3aa9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evaluation Metrics for Object detection algorithms]]></title>
            <link>https://medium.com/@vijayshankerdubey550/evaluation-metrics-for-object-detection-algorithms-b0d6489879f3?source=rss-39c34cac19d7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0d6489879f3</guid>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Vijay Dubey]]></dc:creator>
            <pubDate>Tue, 06 Oct 2020 02:28:58 GMT</pubDate>
            <atom:updated>2020-10-06T02:28:58.223Z</atom:updated>
            <content:encoded><![CDATA[<h4>Table of contents</h4><ul><li>Different competitions, different metrics</li><li>Important definitions</li><li>Metrics</li><li>VOC AP and mAP</li><li>COCO mAP</li><li>References</li></ul><h4>Different competitions, different metrics</h4><p><a href="http://host.robots.ox.ac.uk/pascal/VOC/">PASCAL VOC Challenge</a> : The official documentation explaining their criteria for object detection metrics can be accessed <a href="http://host.robots.ox.ac.uk/pascal/VOC/voc2012/htmldoc/devkit_doc.html#SECTION00050000000000000000">here</a>.The current metrics used by the current PASCAL VOC object detection challenge are the <strong>Precision x Recall curve</strong> and <strong>Average Precision</strong>, which we will be discussing ahead.</p><p><a href="https://competitions.codalab.org/competitions/5181">COCO Detection Challenge</a> : This challenge uses different metrics to evaluate the accuracy of object detection of different algorithms. <a href="http://cocodataset.org/#detection-eval">Here</a> you can find a documentation explaining the 12 metrics used for characterizing the performance of an object detector on COCO. These metrics will be discussed in the <em>coming sections</em>.</p><p><a href="https://storage.googleapis.com/openimages/web/challenge.html">Google Open Images Dataset V4 Competition</a> also uses mean Average Precision (mAP) over the 500 classes to evaluate the object detection task.</p><h4>Important definitions</h4><ul><li><strong>Intersection Over Union (IOU)</strong> :Intersection Over Union (IOU) is measure based on Jaccard Index that evaluates the overlap between two bounding boxes. It requires a ground truth bounding box and a predicted bounding box. By applying the IOU we can tell if a detection is valid (True Positive) or not (False Positive).<br>IOU is given by the overlapping area between the predicted bounding box and the ground truth bounding box divided by the area of union between them:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/0*kN4uVSbsfToA57av" /></figure><ul><li><strong>True Positive(TP)</strong> : A correct detection. Detection with IOU ≥ <em>threshold</em></li><li><strong>False Positive (FP)</strong>: A wrong detection. Detection with IOU &lt; <em>threshold</em></li><li><strong>False Negative(FN)</strong> : A ground truth not detected</li><li><strong>True Negative(TN)</strong> : It would represent a corrected misdetection. In the object detection task there are many possible bounding boxes that should not be detected within an image. Thus, TN would be all possible bounding boxes that were corrrectly not detected (<em>so many possible boxes within an image</em>). That’s why it is not used by the metrics.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*FzEa-a81b3EOQGAOaxeOrQ.jpeg" /><figcaption>The confusion Matrix</figcaption></figure><ul><li><strong>Precision</strong> :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/0*hycnj_FV0baIfud6" /><figcaption>percentage of correct positive predictions</figcaption></figure><ul><li><strong>Recall</strong> :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/0*_iKaceY7ZjkyyEnV" /><figcaption>percentage of true positive detected among all relevant ground truths</figcaption></figure><h4>Metrics</h4><ul><li><strong>Precision x Recall curve </strong>: The Precision x Recall curve is a good way to evaluate the performance of an object detector as the confidence is changed. There is a curve for <em>each object class</em>. An object detector of a particular class is considered good if its prediction stays high as recall increases, which means that if you vary the confidence threshold, the precision and recall will still be high. This statement can be more intuitively understood by looking at the above equations of P and R and keeping in mind that <strong>TP+FN = all ground truth = constant</strong>, so Recall increases, means TP increased, hence FN will decrease. As TP has increased, only if FP decreases, will the Precision remain high i.e. the <em>model will be doing less mistakes</em> and hence will be good. Usually, Precision x Recall curve start with high precision values, <em>decreasing</em> as recall increases. You can see an example of the Precision x Recall curve in the next topic (Average Precision).</li><li><strong>Average Precision(AP)</strong> : It is calculated using area under the curve (<strong>AUC</strong>) of the Precision x Recall curve. As AP curves are often zigzag curves, comparing different curves (different detectors) in the same plot usually is not an easy task. In practice AP is the precision averaged across all recall values between 0 and 1.</li><li><strong>Mean Average Precision(mAP) : </strong>The<strong> </strong>mAP score is calculated by taking the <em>mean AP over all classes </em><strong>and/or</strong> over all IoU thresholds, depending on the competition.</li></ul><h4>VOC AP and mAP</h4><p>PASCAL VOC 2012 challenge uses the <strong>interpolated average precision</strong>. It tries to summarize the shape of the Precision x Recall curve by averaging the precision at a set of eleven equally spaced recall levels [0, 0.1, 0.2, … , 1]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/0*c7iWFDWShpeDfIYq" /></figure><p>with</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/154/0*cgIDhEjdbOmpXwT1" /><figcaption><em>p(r~) is the </em>measured precision at recall r~</figcaption></figure><p>Instead of using the precision observed at each point, the AP is obtained by interpolating the precision at each level <em>r</em> taking the <strong>maximum precision </strong>whose recall value is greater than <em>r.</em></p><p><strong>An illustrative example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/0*WcTr5iSB1LFWIQmk.png" /><figcaption>7 images with 15 ground truth objects(green boxes)and 24 detected objects(red boxes)</figcaption></figure><p>Please observe the following table. The last column identifies the detections as TP or FP. In this example a TP is considered if <strong>IOU≥30%</strong>, otherwise it is a FP. <strong>Note that</strong>, in some images there are more than one detection overlapping a ground truth that are TP (Images 2, 3, 4, 5, 6 and 7). For those cases the detection with the <em>highest IOU</em> is taken, discarding the other detections, as described in PASCAL VOC paper:</p><blockquote>A prediction is positive if IoU &gt; 0.5. If there are 5 detections of a single object , only 1 with the highest IoU is counted correct detection(TP) and rest 4 are false detections(FP)</blockquote><p>The P-R curve is plotted by calculating the precision and recall values of the accumulated TP or FP detections. For this, first we need to order the detections by their confidences, then we calculate the precision and recall for each accumulated detection as shown in the table below: <br><strong>Note</strong>: Total gt boxes = 15. So, recall will always be calculated as <strong>(Acc TP)/15</strong> in this case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/0*OzPuxaVbrBd6YSs2.png" /></figure><p>For obtaining the interpolated average precision, the interpolated precision values are obtained by taking the<strong> maximum precision</strong> whose <strong>recall value is greater than its current recall value. </strong>The follwing curve is obtained:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/0*loGWHJTsPkDqzbyr.png" /></figure><p>For getting the <em>AP for a given class</em>, we just need to calculate the <strong><em>AUC</em></strong><em>(Area Under Curve) of the interpolated precision</em>.</p><p>For <em>PASCAL VOC challenge</em>, only 1 IoU threshold of 0.5 is considered. So the <em>mAP</em> is the average of AP of all <strong>20 object classes.</strong></p><h4>COCO mAP</h4><p>For the COCO 2017 challenge, the mAP was calculated by averaging the AP over all <em>80 object categories</em> <strong>AND</strong> all <em>10 IoU thresholds</em> from 0.5 to 0.95 with a step size of 0.05. The authors hypothesize that <strong>averaging over IoUs rewards detectors with better localization</strong>.</p><p>To make it more clear, first the AP is calculated for IoU threshold of 0.5 for each class i.e. We calculate the precision at every recall value(0 to 1 with a step size of 0.01), then it is repeated for IoU thresholds of 0.55,0.60,…,.95 and finally average is taken over all the 80 classes and all the 10 thresholds to get the primary metric used in the challenge.</p><p>Some more metrics have been defined in the challenge, like AP across scales for evaluating detections based on the <strong>object size</strong> inside the image and seeing whether the model is doing good for just large objects or just small objects or is it doing good for objects of varying sizes. The authors have defined s<strong>mall objects </strong>with those having <strong>area(h*w)</strong> less than 32² (on pixel scale)<strong>, medium objects</strong> as those having area between 32² and 96² and<strong> large objects </strong>with <strong>area(h*w) greater than 96².</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*JgY6tcvlMirLUAfUe2AgTw.png" /><figcaption>All the metrics used for COCO evaluation</figcaption></figure><p><strong>NOTE</strong> : All the metrics are computed allowing for <strong>at most 100 top-scoring </strong>detections per image (across all categories). More details can be found <a href="http://cocodataset.org/#detection-eval">here</a>.</p><h4>References</h4><ul><li><a href="http://cocodataset.org/#detection-eval">http://cocodataset.org/#detection-eval</a></li><li><a href="https://arxiv.org/pdf/1405.0312.pdf">https://arxiv.org/pdf/1405.0312.pdf</a> — COCO paper</li><li><a href="http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf">http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf</a> — VOC paper</li><li><a href="https://github.com/rafaelpadilla/Object-Detection-Metrics">https://github.com/rafaelpadilla/Object-Detection-Metrics</a></li><li><a href="https://storage.googleapis.com/openimages/web/challenge.html">https://storage.googleapis.com/openimages/web/challenge.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0d6489879f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>