
    >|h	                     &    d dl Z d dlZd Zd Zd Zy)    Nc                 (   dt        |       k(  rg S | d d df   | d d df   | d d df   | d d df   | d d df   f\  }}}}}||z
  dz   ||z
  dz   z  }|j                         d d d   }g }	|j                  dkD  r|d   }
|	j                  |
       t	        j
                  ||
   ||dd           t	        j
                  ||
   ||dd           }}t	        j                  ||
   ||dd           t	        j                  ||
   ||dd           }}t	        j
                  d||z
  dz         t	        j
                  d||z
  dz         }}||z  ||
   ||dd     z   ||z  z
  z  }t	        j                  ||k        d   }||dz      }|j                  dkD  r|	S )Nr               g        )lenargsortsizeappendnpmaximumminimumwhere)detsthreshx1y1x2y2scoresareasorderkeepixx1yy1xx2yy2whovrindss                      `/var/www/html/test/engine/venv/lib/python3.12/site-packages/face_alignment/detection/sfd/bbox.pynmsr%      s   CI~	!!Q$ZadT!Q$ZadTRSUVRVZWBBF"Wq[R"Wq[)ENNTrT"ED
**q.!HA::beRab	]3RZZ1r%PQPR)}5US::beRab	]3RZZ1r%PQPR)}5USzz#sSy1}-rzz#sSy1}/M1!euQx%ab	"22QU:;xxv&q)dQh **q. K    c                 "   | ddddf   | ddddf   z   dz  |ddddf   z
  }||d   |ddddf   z  z  }| ddddf   | ddddf   z
  |ddddf   z  }t        j                  |      |d   z  }t        j                  ||gd      S )a  Encode the variances from the priorbox layers into the ground truth boxes
    we have matched (based on jaccard overlap) with the prior boxes.
    Args:
        matched: (tensor) Coords of ground truth for each prior in point-form
            Shape: [num_priors, 4].
        priors: (tensor) Prior boxes in center-offset form
            Shape: [num_priors,4].
        variances: (list[float]) Variances of priorboxes
    Return:
        encoded boxes (tensor), Shape: [num_priors, 4]
    Nr   r   r   )r   logconcatenate)matchedpriors	variancesg_cxcyg_whs        r$   encoder/      s     a!enwq!"u~-2VArrE]BF
y|fQUm+,FAqrENWQU^+vae}<D66$<)A,&D >>64.!,,r&   c           
      V   t        j                  |ddddf   | ddddf   |d   z  |ddddf   z  z   |ddddf   t        j                  | ddddf   |d   z        z  fd      }|ddddfxx   |ddddf   dz  z  cc<   |ddddfxx   |ddddf   z  cc<   |S )a  Decode locations from predictions using priors to undo
    the encoding we did for offset regression at train time.
    Args:
        loc (tensor): location predictions for loc layers,
            Shape: [num_priors,4]
        priors (tensor): Prior boxes in center-offset form.
            Shape: [num_priors,4].
        variances: (list[float]) Variances of priorboxes
    Return:
        decoded bounding box predictions
    Nr   r   r   )r   r)   exp)locr+   r,   boxess       r$   decoder4   5   s     NNq"1"uArrE
Yq\1F1ab5MAAq!"us1ab5zIaL899;<=?E 
!RaR%LE!QR%L1$$L	!QR%LE!RaR%L LLr&   )mathnumpyr   r%   r/   r4    r&   r$   <module>r8      s     .-2r&   