You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/02/27 07:09:15 UTC

[GitHub] [incubator-mxnet] djaym7 opened a new issue #17706: Help convert this to support symbol -- F. compatible

djaym7 opened a new issue #17706: Help convert this to support symbol -- F. compatible
URL: https://github.com/apache/incubator-mxnet/issues/17706
 
 
   CODE : 
   
   
   
   def bbox_overlaps_ciou(bboxes1, bboxes2,F,denorm):
       '''
        Calculate the Centralized Intersection over Union (cIoU) of two bounding boxes.
       Parameters
       in CV axes are like this
       
    0,0|-------|
       |       |
       |       |
       |       |(1,1)
       ----------
       bb1 : dict
           Keys: {'x1', 'x2', 'y1', 'y2'}
           The (x1, y1) position is at the top left corner,
           the (x2, y2) position is at the bottom right corner
       bb2 : dict
           Keys: {'x1', 'x2', 'y1', 'y2'}
           The (x, y) position is at the top left corner,
           the (x2, y2) position is at the bottom right corner
       Returns
       -------
       float
           in [0, 1]
       '''
       rows = denorm
       cols = denorm
       cious = F.zeros((22743, 22743))
   
   [removethis.txt](https://github.com/apache/incubator-mxnet/files/4259985/removethis.txt)
   
       w1 = bboxes1[:, 2] - bboxes1[:, 0]
       h1 = bboxes1[:, 3] - bboxes1[:, 1]
       w2 = bboxes2[:, 2] - bboxes2[:, 0]
       h2 = bboxes2[:, 3] - bboxes2[:, 1]
       
       w1 = F.clip(w1,a_min=0.000001,a_max=10000)
       h1 = F.clip(h1,a_min=0.000001,a_max=10000)
       w2 = F.clip(w2,a_min=0.000001,a_max=10000)
       h2 = F.clip(h2,a_min=0.000001,a_max=10000)
       
       area1 = w1 * h1
       area2 = w2 * h2
   
       center_x1 = (bboxes1[:, 2] + bboxes1[:, 0]) / 2
       center_y1 = (bboxes1[:, 3] + bboxes1[:, 1]) / 2
       center_x2 = (bboxes2[:, 2] + bboxes2[:, 0]) / 2
       center_y2 = (bboxes2[:, 3] + bboxes2[:, 1]) / 2
   
       inter_max_xy = F.minimum(bboxes1[:, 2:],bboxes2[:, 2:])
       inter_min_xy = F.maximum(bboxes1[:, :2],bboxes2[:, :2])
       out_max_xy = F.maximum(bboxes1[:, 2:],bboxes2[:, 2:])
       out_min_xy = F.minimum(bboxes1[:, :2],bboxes2[:, :2])
   
       inter = F.clip((inter_max_xy - inter_min_xy), a_min=0,a_max=1000)
       
       inter_area = inter[:, 0] * inter[:, 1]
       if inter_area.sum()==0:
           return F.zeros(1)
   
       inter_diag = (center_x2 - center_x1)**2 + (center_y2 - center_y1)**2
       outer = (out_max_xy - out_min_xy)
       outer_diag = (outer[:, 0] ** 2) + (outer[:, 1] ** 2)
       
       union = area1+area2-inter_area
       u = (inter_diag) / outer_diag
       iou = inter_area / union
   
       with autograd.pause():
           arctan = F.arctan(w2 / h2) - F.arctan(w1 / h1)
           v = (4 / (math.pi ** 2)) * F.power((mx.nd.arctan(w2 / h2) - F.arctan(w1 / h1)), 2)
           S = 1 - iou
           alpha = v / (S + v)
           w_temp = 2 * w1
       ar = (8 / (math.pi ** 2)) * arctan * ((w1 - w_temp) * h1)
       cious = iou - (u + alpha * ar)
       cious = F.clip(cious,a_min=-1.0,a_max = 1.0)
       if exchange:
           cious = cious.T
       return cious

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] djaym7 closed issue #17706: deleted

Posted by GitBox <gi...@apache.org>.
djaym7 closed issue #17706: deleted
URL: https://github.com/apache/incubator-mxnet/issues/17706
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services