o
    1j                     @   s   d dl Z d dlZd dlZddlmZmZ edr$d dlmZ d dlm	Z	 dd Z
d	d
 Zed					dddZedkrGe
 Zee dS dS )    N   )function_requires_depsis_dep_availableZpycocotools)COCO)COCOevalc                  C   s4   t  } | jdtdd | jdtdd |  }|S )zParse input argumentsz--prediction_json_pathz./bbox.json)typedefaultz--gt_json_pathz./instance_val.json)argparseArgumentParseradd_argumentstr
parse_args)parserargs r   e/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddlex/modules/base/utils/coco_eval.pyr      s
   r   c                 C   s8   | j }| j}tj|sJ d|t|d|d dS )z4
    cocoapi eval with already exists bbox.json
    z$The json directory:{} does not existbbox)	anno_fileN)prediction_json_pathgt_json_pathospathexistsformatcocoapi_eval)r   r   r   r   r   r   json_eval_results%   s   r   d   i,  i  Tc           	      C   s   |dus
|dus
J |du rt |}|| }|dkr,t||d}d|j_t||j_n|dkr9t|||||}nt|||}|  |  |	  t
j  |jS )a  
    Args:
        jsonfile (str): Evaluation json file, eg: bbox.json
        style (str): COCOeval style, can be `bbox`
        coco_gt (str): Whether to load COCOAPI through anno_file,
                 eg: coco_gt = COCO(anno_file)
        anno_file (str): COCO annotations file.
        max_dets (tuple): COCO evaluation maxDets.
        sigmas (nparray): keypoint labelling sigmas.
        use_area (bool): If gt annotations (eg. CrowdPose, AIC)
                         do not have 'area', please set use_area=False.
    NZproposalr   r   Zkeypoints_crowd)r   ZloadResr   paramsZuseCatslistZmaxDetsevaluate
accumulateZ	summarizesysstdoutflushstats)	ZjsonfilestyleZcoco_gtr   Zmax_detsZsigmasZuse_areaZcoco_dtZ	coco_evalr   r   r   r   1   s    

r   __main__)NNr   NT)r	   r   r"   Z
utils.depsr   r   Zpycocotools.cocor   Zpycocotools.cocoevalr   r   r   r   __name__r   r   r   r   r   <module>   s(   
*