§
    ­¸j�  ã                  ó2   — d Z ddlmZ ddlZddlmZ dd„ZdS )aÅ  Torch-free bilinear resize shared by the export inference helpers.

``RFDETR.predict()`` resizes with ``torchvision`` ``antialias=False`` bilinear (half-pixel centers, no low-pass filter).
The export inference paths must reproduce that exact convention so exported models score images the same way the PyTorch
model does. When ``torch`` is importable they call torchvision directly; this module provides the NumPy equivalent for
torch-free deployments.
é    )ÚannotationsN)ÚNDArrayÚsrcúNDArray[np.float32]Úout_hÚintÚout_wÚreturnc                ó  — | j         d         | j         d         }}t          j        |t          j        ¬¦  «        dz   ||z  z  dz
  }t          j        |t          j        ¬¦  «        dz   ||z  z  dz
  }t          j        |d|dz
  ¦  «        }t          j        |d|dz
  ¦  «        }t          j        |¦  «                             t          j        ¦  «        }t          j        |¦  «                             t          j        ¦  «        }t          j        |dz   |dz
  ¦  «        }	t          j        |dz   |dz
  ¦  «        }
||z
  dd…df         }||z
  ddd…f         }d|z  d	|z  k     rat          j	        | |d¬
¦  «        }t          j	        | |
d¬
¦  «        }d|z
  |z  ||z  z   }d|z
  |d|dd…f         z  ||d|	dd…f         z  z   }n¢| d|dd…df         |ddd…f         f         }| d|dd…df         |
ddd…f         f         }| d|	dd…df         |ddd…f         f         }| d|	dd…df         |
ddd…f         f         }d|z
  d|z
  |z  ||z  z   z  |d|z
  |z  ||z  z   z  z   }t          j
        |t          j        ¬¦  «        S )u(  Numpy bilinear resize matching ``F.interpolate(mode="bilinear", align_corners=False)``.

    Half-pixel center convention with no antialias filter â€” the same convention
    ``torchvision.transforms.functional.resize(..., antialias=False)`` and
    ``RFDETR.predict()`` use. Serves as the torch-free fallback for both image
    preprocessing and mask decoding.

    Args:
        src: Source array of shape ``(K, src_h, src_w)``.
        out_h: Target height in pixels.
        out_w: Target width in pixels.

    Returns:
        Float32 array of shape ``(K, out_h, out_w)``.

    Note:
        Replaces ``PIL.Image.resize(BILINEAR)``, which applies an adaptive
        antialias filter when downscaling and a corner-aligned half-pixel
        convention, both of which diverge from ``F.interpolate``.
    éþÿÿÿéÿÿÿÿ)Údtypeg      à?g        é   Né   é   )Úaxis.)ÚshapeÚnpÚarangeÚfloat32ÚclipÚfloorÚastypeÚint64ÚminimumÚtakeÚasarray)r   r   r	   Úsrc_hÚsrc_wÚsrc_yÚsrc_xÚy0Úx0Úy1Úx1ÚdyÚdxÚleftÚrightÚ
horizontalÚoutÚaÚbÚcÚds                        úe/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/rfdetr/export/_resize.pyÚ_bilinear_resize_half_pixelr1      sµ  € ð* ”9˜R”= #¤)¨B¤-ˆ5€EÝŒY�u¥B¤JÐ/Ñ/Ô/°#Ñ5¸%À%¹-ÑHÈ3ÑN€EÝŒY�u¥B¤JÐ/Ñ/Ô/°#Ñ5¸%À%¹-ÑHÈ3ÑN€EÝŒG�E˜3 ¨¡	Ñ*Ô*€EÝŒG�E˜3 ¨¡	Ñ*Ô*€EÝ	Œ�%‰Œ×	Ò	¥¤Ñ	)Ô	)€BÝ	Œ�%‰Œ×	Ò	¥¤Ñ	)Ô	)€BÝ	Œ�B˜‘F˜E A™IÑ	&Ô	&€BÝ	Œ�B˜‘F˜E A™IÑ	&Ô	&€BØ
�"‰*�a�a�a˜�gÔ	€BØ
�"‰*�d˜A˜A˜A�gÔ	€BØˆ5�y�1�u‘9ÒÐõ
 Œw�s˜B RÐ(Ñ(Ô(ˆÝ”˜˜R bÐ)Ñ)Ô)ˆØ˜"‘f ‘_ r¨E¡zÑ1ˆ
Ø�2‰v˜ C¨¨Q¨Q¨Q JÔ/Ñ/°"°zÀ#ÀrÈ1È1È1À*Ô7MÑ2MÑMˆˆà��R˜˜˜˜4˜”[ " T¨1¨1¨1 W¤+Ð-Ô.ˆØ��R˜˜˜˜4˜”[ " T¨1¨1¨1 W¤+Ð-Ô.ˆØ��R˜˜˜˜4˜”[ " T¨1¨1¨1 W¤+Ð-Ô.ˆØ��R˜˜˜˜4˜”[ " T¨1¨1¨1 W¤+Ð-Ô.ˆØ�2‰v˜1˜r™6 Q™,¨¨a©Ñ/Ñ0°2¸!¸b¹&ÀA¹ÈÈQÉÑ9NÑ3OÑOˆÝŒ:�c¥¤Ð,Ñ,Ô,Ð,ó    )r   r   r   r   r	   r   r
   r   )Ú__doc__Ú
__future__r   Únumpyr   Únumpy.typingr   r1   © r2   r0   ú<module>r8      s_   ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  ð/-ð /-ð /-ð /-ð /-ð /-r2   