
    FPhJ                     (    d dl mZ d dlmZmZ ddZy)    )Path)SAMYOLONc           	         t        |      }t        |      }t        |       } |s| j                  | j                   dz  }t        |      j                  dd        || d|      }|D ][  }|j                  j                  j                         j                         }t        |      sB|j                  j                  } ||j                  |dd|      }	|	d   j                  j                  }
t        t!        t        |      t        |j"                        j                  z         dd	      5 }t%        t        |
            D ]r  }|
|   }t        |      dk(  rt'        t         |
|   j)                  d
      j                               }|j+                  ||    ddj-                  |      z   dz          t 	 ddd       ^ y# 1 sw Y   jxY w)a^  
    Automatically annotates images using a YOLO object detection model and a SAM segmentation model.

    Args:
        data (str): Path to a folder containing images to be annotated.
        det_model (str, optional): Pre-trained YOLO detection model. Defaults to 'yolov8x.pt'.
        sam_model (str, optional): Pre-trained SAM segmentation model. Defaults to 'sam_b.pt'.
        device (str, optional): Device to run the models on. Defaults to an empty string (CPU or GPU, if available).
        output_dir (str | None | optional): Directory to save the annotated results.
            Defaults to a 'labels' folder in the same directory as 'data'.

    Example:
        ```python
        from ultralytics.data.annotator import auto_annotate

        auto_annotate(data='ultralytics/assets', det_model='yolov8n.pt', sam_model='mobile_sam.pt')
        ```
    _auto_annotate_labelsT)exist_okparents)streamdeviceF)bboxesverbosesaver   r   z.txtw 
N)r   r   r   parentstemmkdirboxesclsinttolistlenxyxyorig_imgmasksxynopenstrpathrangemapreshapewritejoin)data	det_model	sam_modelr   
output_dirdet_resultsresult	class_idsr   sam_resultssegmentsfissegments                  eC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\ultralytics/data/annotator.pyauto_annotater5      s   & YIII:D[[dii[0E#FF
D$7Df=KLL$$((*113	y>LL%%E#FOOE5W\eklK"1~++//HT*-V[[0A0F0FFGHMsSWXs8}-A A1v{ !#x{':':2'>'E'E'GHGGGy|nA.'1BBTIJ . TS  TSs   2B
G		G	)z
yolov8x.ptzsam_b.pt N)pathlibr   ultralyticsr   r   r5        r4   <module>r;      s     !*Kr:   