Ë
    ¼Ó^jÛ  ã                  óˆ   — d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ 	 d	 	 	 	 	 	 	 d	d„Z	 	 	 d
	 	 	 	 	 	 	 	 	 	 	 dd„Zy)é    )ÚannotationsN)ÚImage)Ú	ImageType)Úpillow_to_cv2c                óˆ  — t        | t        j                  «      rt        | «      } t        j                  |¬«       | j
                  dk(  rt        j                  | |¬«       n7t        j                  t        j                  | t        j                  «      «       t        j                  d«       t        j                  «        y)a™  
    Plots image using matplotlib.

    Args:
        image: The frame to be displayed ImageType
             is a flexible type, accepting either `numpy.ndarray` or `PIL.Image.Image`.
        size: The size of the plot in inches.
        cmap: the colormap to use for single channel images.

    Examples:
        ```pycon
        >>> import cv2
        >>> import numpy as np
        >>> import matplotlib
        >>> matplotlib.use('Agg')  # Prevents the GUI window from popping up
        >>> import supervision as sv
        >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
        >>> sv.plot_image(image=image, size=(16, 16))
        ...

        ```
    )Úfigsizeé   ©ÚcmapÚoffN)Ú
isinstancer   r   ÚpltÚfigureÚndimÚimshowÚcv2ÚcvtColorÚCOLOR_BGR2RGBÚaxisÚshow)ÚimageÚsizer   s      úe/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/supervision/utils/notebook.pyÚ
plot_imager      sr   € ô2 �%œŸ™Ô%Ü˜eÓ$ˆä‡J�J�tÕà‡z�z�Q‚Ü�
‰
�5˜tÖ$ä�
‰
”3—<‘< ¤s×'8Ñ'8Ó9Ô:ä‡H�HˆU„OÜ‡H�H…Jó    c                óš  — |\  }}t        | «      D ].  \  }}t        |t        j                  «      sŒ!t        |«      | |<   Œ0 t	        | «      ||z  kD  rt        d«      ‚t        j                  |||¬«      \  }	}
t        |
j                  «      D ]§  \  }}|t	        | «      k  rƒ| |   j                  dk(  r|j                  | |   |¬«       n6|j                  t        j                  | |   t        j                  «      «       |�"|t	        |«      k  r|j                  ||   «       |j                  d«       Œ© t        j                   «        y)aâ  
    Plots images in a grid using matplotlib.

    Args:
       images: A list of images as ImageType
             is a flexible type, accepting either `numpy.ndarray` or `PIL.Image.Image`.
       grid_size: A tuple specifying the number
            of rows and columns for the grid.
       titles: A list of titles for each image.
            Defaults to None.
       size: A tuple specifying the width and
            height of the entire plot in inches.
       cmap: the colormap to use for single channel images.

    Raises:
       ValueError: If the number of images exceeds the grid size.

    Examples:
        ```pycon
        >>> import cv2
        >>> import numpy as np
        >>> import matplotlib
        >>> matplotlib.use('Agg')  # Prevents the GUI window from popping up
        >>> import supervision as sv
        >>> from PIL import Image
        >>> image1 = np.zeros((100, 100, 3), dtype=np.uint8)
        >>> image2 = Image.new('RGB', (100, 100))
        >>> image3 = np.zeros((100, 100, 3), dtype=np.uint8)
        >>> images = [image1, image2, image3]
        >>> titles = ["Image 1", "Image 2", "Image 3"]
        >>> sv.plot_images_grid(images, grid_size=(2, 2), titles=titles, size=(16, 16))
        ...

        ```
    ziThe number of images exceeds the grid size. Please increase the grid size or reduce the number of images.)ÚnrowsÚncolsr   r	   r
   Nr   )Ú	enumerater   r   r   ÚlenÚ
ValueErrorr   ÚsubplotsÚflatr   r   r   r   r   Ú	set_titler   r   )ÚimagesÚ	grid_sizeÚtitlesr   r   r   r   ÚidxÚimgÚ_figÚaxesÚaxs               r   Úplot_images_gridr-   2   s$  € ðT �L€Eˆ5ä˜fÓ%ò -‰ˆˆSÜ�cœ5Ÿ;™;Õ'Ü'¨Ó,ˆF�3ŠKð-ô ˆ6ƒ{�U˜U‘]Ò"Üð/ó
ð 	
ô
 —‘ E°ÀÔE�J€Dˆ$ä˜TŸY™YÓ'ò 
‰ˆˆRØ”�V“ÒØ�c‰{×Ñ 1Ò$Ø—	‘	˜& ™+¨D�	Õ1à—	‘	œ#Ÿ,™, v¨c¡{´C×4EÑ4EÓFÔGàÐ! c¬C°«KÒ&7Ø—‘˜V C™[Ô)à
�‰��ð
ô ‡H�H…Jr   )©é   r/   Úgray)r   r   r   útuple[int, int]r   ú
str | NoneÚreturnÚNone)Nr.   r0   )r%   zlist[ImageType]r&   r1   r'   zlist[str] | Noner   r1   r   r2   r3   r4   )Ú
__future__r   r   Úmatplotlib.pyplotÚpyplotr   ÚPILr   Úsupervision.draw.baser   Úsupervision.utils.conversionr   r   r-   © r   r   ú<module>r<      s“   ðÝ "ã 
Ý Ý å +Ý 6ð LRð$Øð$Ø+ð$Ø>Hð$à	ó$ðT  $Ø$ØðCØðCàðCð ðCð ð	Cð
 ðCð 
ôCr   