
    kh                     <    d dl mZ d dlmZmZmZmZ  G d d      Zy)    )Integral)ListUnionDictAnyc                   ^    e Zd ZdZ	 	 	 	 	 	 ddedededededefdZed	        Zed
        Z	y)Parsera   Parser base class.

    The attributes listed below make up a public interface common to all parsers. They can be accessed directly
    once the dataset is constructed and annotations are populated.

    Attributes:

        cat_names (list[str]):
            list of category (class) names, with background class at position 0.
        cat_ids (list[union[str, int]):
            list of dataset specific, unique integer or string category ids, does not include background
        cat_id_to_label (dict):
            map from category id to integer 1-indexed class label

        img_ids (list):
            list of dataset specific, unique image ids corresponding to valid samples in dataset
        img_ids_invalid (list):
            list of image ids corresponding to invalid images, not used as samples
        img_infos (list[dict]):
            image info, list of info dicts with filename, width, height for each image sample
    	bbox_yxyx
has_labelsinclude_masksinclude_bboxes_ignoreignore_empty_gtmin_img_sizec                     || _         || _        || _        || _        || _        || _        d| _        g | _        g | _        t               | _
        g | _        g | _        g | _        y)a  
        Args:
            yxyx (bool): output coords in yxyx format, otherwise xyxy
            has_labels (bool): dataset has labels (for training validation, False usually for test sets)
            include_masks (bool): include segmentation masks in target output (not supported yet for any dataset)
            include_bboxes_ignore (bool): include ignored bbox in target output
            ignore_empty_gt (bool): ignore images with no ground truth (no negative images)
            min_img_size (bool): ignore images with width or height smaller than this number
            sub_sample (int): sample every N images from the dataset
           N)yxyxr   r   r   r   r   label_offset	cat_namescat_idsdictcat_id_to_labelimg_idsimg_ids_invalid	img_infos)selfr
   r   r   r   r   r   s          V/var/www/teggl/fontify/venv/lib/python3.12/site-packages/effdet/data/parsers/parser.py__init__zParser.__init__   sl    ( 	$*%:".( %'35EIV 46;=/1    c           	          t        | j                  | j                        D cg c]-  \  }}t        || j                  s|n| j                  |         / c}}S c c}}w )zreturn category names and labels in format compatible with TF Models Evaluator
        list[dict(name=<class name>, id=<class label>)]
        )nameid)zipr   r   r   r   )r   r    cat_ids      r   	cat_dictszParser.cat_dictsA   s^     #&dnndll"C	E $ !%!5!564;O;OPV;WE 	E Es   2Ac                     | j                   r#t        | j                   j                               S t        | j                        rt        | j                  d   t              sJ t        | j                        S )Nr   )r   maxvalueslenr   
isinstancer   )r   s    r   	max_labelzParser.max_labelL   sW    t++22455t||$DLLOX)NNNt||$$r   N)FTFFF    )
__name__
__module____qualname____doc__boolintr   propertyr$   r*    r   r   r	   r	      s    . $#"'*/$) "$2$2 $2  	$2
 $($2 "$2 $2L E E % %r   r	   N)numbersr   typingr   r   r   r   r	   r3   r   r   <module>r6      s     ) )M% M%r   