
    Ng                     D    d dl mZ d dlmZmZmZmZ  G d d          ZdS )    )Integral)ListUnionDictAnyc                   l    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	dS )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
    FT    	bbox_yxyx
has_labelsinclude_masksinclude_bboxes_ignoreignore_empty_gtmin_img_sizec                     || _         || _        || _        || _        || _        || _        d| _        g | _        g | _        t                      | _
        g | _        g | _        g | _        dS )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/html/ai-engine/env/lib/python3.11/site-packages/effdet/data/parsers/parser.py__init__zParser.__init__   sr    ( 	$*%:".( %'35EIVV 46;=/1    c                 P      fdt           j         j                  D             S )zreturn category names and labels in format compatible with TF Models Evaluator
        list[dict(name=<class name>, id=<class label>)]
        c                 `    g | ]*\  }}t          |j        s|nj        |                    +S ))nameid)r   r   ).0r"   cat_idr   s      r   
<listcomp>z$Parser.cat_dicts.<locals>.<listcomp>F   s_     E E E $ !%!5W664;OPV;W  E E Er   )zipr   r   r   s   `r   	cat_dictszParser.cat_dictsA   sF    
E E E E #&dndl"C"C	E E E 	Er   c                     | j         r&t          | 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   se     	%t+2244555t|$$NDLOX)N)NNNNt|$$$r   N)FTFFFr
   )
__name__
__module____qualname____doc__boolintr   propertyr)   r/    r   r   r	   r	      s         . $#"'*/$) "$2 $2$2 $2  	$2
 $($2 "$2 $2 $2 $2 $2L E E XE % % X% % %r   r	   N)numbersr   typingr   r   r   r   r	   r7   r   r   <module>r:      sw          ) ) ) ) ) ) ) ) ) ) ) )M% M% M% M% M% M% M% M% M% M%r   