title: Calculating IOU for bounding box predictions
body: <p><a href="https://i.stack.imgur.com/qv8D0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qv8D0.png" alt="enter image description here" /></a></p>
  <p>I have these two bounding boxes as given in the image. the box cordinates are given as below :</p>
  <p>box 1 = [0.23072851 0.44545859 0.56389928 0.67707491]
  box 2 = [0.22677664 0.38237819 0.85152483 0.75449795]</p>
  <p>The coordinate are like this : ymin, xmin, ymax, xmax</p>
  <p>I am calculating IOU as follows :</p>
  <pre class="lang-py prettyprint-override"><code>def get_iou(box1, box2):
      &quot;&quot;&quot;
      Implement the intersection over union (IoU) between box1 and box2
          
      Arguments:
          box1 -- first box, numpy array with coordinates (ymin, xmin, ymax, xmax)
          box2 -- second box, numpy array with coordinates (ymin, xmin, ymax, xmax)
      &quot;&quot;&quot;
      # ymin, xmin, ymax, xmax = box
      
      y11, x11, y21, x21 = box1
      y12, x12, y22, x22 = box2
      
      yi1 = max(y11, y12)
      xi1 = max(x11, x12)
      yi2 = min(y21, y22)
      xi2 = min(x21, x22)
      inter_area = max(((xi2 - xi1) * (yi2 - yi1)), 0)
      # Calculate the Union area by using Formula: Union(A,B) = A + B - Inter(A,B)
      box1_area = (x21 - x11) * (y21 - y11)
      box2_area = (x22 - x12) * (y22 - y12)
      union_area = box1_area + box2_area - inter_area
      # compute the IoU
      iou = inter_area / union_area
      return iou
  </code></pre>
  <p>Based on my understanding these 2 boxes completely overlap each other so IOU should be 1. However I get an IOU of <strong>0.33193138665968164</strong>
  . Is there something which I am doing wrong or I am interpreting it in an incorrect way. Any suggestions in this regard would be helpful.</p>