
    9i                         S SK r S SKrS SKrSSKJrJr  \" S5      (       a  S SKJr  S SKJ	r	  S r
S r\" S5           SS	 j5       r\S
:X  a  \
" 5       r\" \5        gg)    N   )function_requires_depsis_dep_availablepycocotools)COCO)COCOevalc                      [         R                  " 5       n U R                  S[        SS9  U R                  S[        SS9  U R	                  5       nU$ )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argss     d/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/paddlex/modules/base/utils/coco_eval.pyr   r      sP    $$&F
0sMR
(s<QRDK    c                     U R                   nU R                  n[        R                  R	                  U5      (       d   SR                  U5      5       e[        USUS9  g)z,
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   s      r   json_eval_resultsr   %   sb      44$$L77>>  K-445IJK  %vFr   c                    Uc  Uc   eUc  [        U5      nUR                  U 5      nUS:X  a8  [        X'S5      nSUR                  l        [        U5      UR                  l        O US:X  a  [        X'XU5      nO[        X'U5      nUR                  5         UR                  5         UR                  5         [        R                  R                  5         UR                  $ )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.
proposalr   r   keypoints_crowd)r   loadResr   paramsuseCatslistmaxDetsevaluate
accumulate	summarizesysstdoutflushstats)	jsonfilestylecoco_gtr   max_detssigmasuse_areacoco_dt	coco_evals	            r   r   r   1   s    , )"777y/ooh'G
Wv6	#$	 #'>	 	#	#WuhG	Wu5	JJ??r   __main__)NN)d   i,  i  NT)r   r   r+   
utils.depsr   r   pycocotools.cocor   pycocotools.cocoevalr   r   r   r   __name__r    r   r   <module>r>      sx      	 
 CM""%-	G & ' ''T z<Dd r   