Ë
    Fêñi©  ã                  ór   — d dl mZ d dlmZ d dlmZmZ 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zy)é    )Úannotations)ÚPath)ÚSAMÚYOLONc
           
     ó~  — t        |«      }t        |«      }t        | «      } |	s| j                  | j                  › d�z  }	t        |	«      j                  dd¬«        || d||||||¬«      }
|
D �]?  }|j                  j                  j                  «       j                  «       x}sŒ9|j                  j                  } ||j                  |dd|¬«      }|d   j                  j                  }t        t        |	«      t        |j                  «      j                  z  › d�d	d
¬«      5 }t!        |«      D ]o  \  }}|j#                  «       sŒt%        t&        |j)                  d«      j                  «       «      }|j+                  ||   › d�dj-                  |«      z   dz   «       Œq 	 ddd«       �ŒB y# 1 sw Y   �ŒNxY w)aŠ  Automatically annotate images using a YOLO object detection model and a SAM segmentation model.

    This function processes images in a specified directory, detects objects using a YOLO model, and then generates
    segmentation masks using a SAM model. The resulting annotations are saved as text files in YOLO format.

    Args:
        data (str | Path): Path to a folder containing images to be annotated.
        det_model (str): Path or name of the pre-trained YOLO detection model.
        sam_model (str): Path or name of the pre-trained SAM segmentation model.
        device (str): Device to run the models on (e.g., 'cpu', 'cuda', '0'). Empty string for auto-selection.
        conf (float): Confidence threshold for detection model.
        iou (float): IoU threshold for filtering overlapping boxes in detection results.
        imgsz (int): Input image resize dimension.
        max_det (int): Maximum number of detections per image.
        classes (list[int], optional): Filter predictions to specified class IDs, returning only relevant detections.
        output_dir (str | Path, optional): Directory to save the annotated results. If None, creates a default directory
            based on the input data path.

    Examples:
        >>> from ultralytics.data.annotator import auto_annotate
        >>> auto_annotate(data="ultralytics/assets", det_model="yolo26n.pt", sam_model="mobile_sam.pt")
    Ú_auto_annotate_labelsT)Úexist_okÚparents)ÚstreamÚdeviceÚconfÚiouÚimgszÚmax_detÚclassesF)ÚbboxesÚverboseÚsaver   r   z.txtÚwzutf-8)Úencodingéÿÿÿÿú ú
N)r   r   r   ÚparentÚstemÚmkdirÚboxesÚclsÚintÚtolistÚxyxyÚorig_imgÚmasksÚxynÚopenÚpathÚ	enumerateÚanyÚmapÚstrÚreshapeÚwriteÚjoin)ÚdataÚ	det_modelÚ	sam_modelr   r   r   r   r   r   Ú
output_dirÚdet_resultsÚresultÚ	class_idsr   Úsam_resultsÚsegmentsÚfÚiÚsÚsegments                       ú\/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/ultralytics/data/annotator.pyÚauto_annotater<   
   s¢  € ôD �Y“€IÜ�I“€Iä�‹:€DÙØ—[‘[ d§i¡i [Ð0EÐ#FÑFˆ
ÜˆÓ×Ñ D°$ÐÔ7áØ�T &¨t¸ÀEÐSZÐdkô€Kð ó 
OˆØŸ™×(Ñ(×,Ñ,Ó.×5Ñ5Ó7Ð7ˆ9Ñ7Ø—L‘L×%Ñ%ˆEÙ# F§O¡O¸EÈ5ÐW\ÐekÔlˆKØ" 1‘~×+Ñ+×/Ñ/ˆHäœ˜jÓ)¬D°·±Ó,=×,BÑ,BÑBÐCÀ4ÐHÈ#ÐX_Ô`ð OÐdeÜ% hÓ/ò O‘D�A�qØ—u‘u•wÜ"%¤c¨1¯9©9°R«=×+?Ñ+?Ó+AÓ"B˜ØŸ™ 9¨Q¡< .°Ð 2°S·X±X¸gÓ5FÑ FÈÑ MÕNñO÷Oñ Oñ
O÷Oñ Oús   Ä'"F2Å
AF2Æ2F<	)	z
yolo26x.ptzsam_b.ptÚ g      Ð?gÍÌÌÌÌÌÜ?i€  i,  NN)r.   z
str | Pathr/   r*   r0   r*   r   r*   r   Úfloatr   r>   r   r   r   r   r   zlist[int] | Noner1   zstr | Path | NoneÚreturnÚNone)Ú
__future__r   Úpathlibr   Úultralyticsr   r   r<   © ó    r;   ú<module>rF      s¨   ðõ #å ç !ð
 "ØØØØØØØ $Ø$(ð8OØ
ð8Oàð8Oð ð8Oð ð	8Oð
 ð8Oð 
ð8Oð ð8Oð ð8Oð ð8Oð "ð8Oð 
ô8OrE   