
    Ng[y              	       b   d Z ddlZddlmZ ddlmZ ddlZddlZ ej	        g d          Z
dZ ej        ddd          Ze G d	 d
                      Ze G d d                      Z G d d          Zedk    rddlmZ  ed           ed          gZ ed           ed          gZ eee          D ]r\  ZZe                    ee          Ze                                \  ZZ edej         d ee                       edej         d ee                      qdS dS )zZ
Implements object detection metrics: average precision, precision, recall, and f1 score.
    N)	dataclass)Path)
g      ?g?g333333?g?gffffff?g      ?g?g333333?g?gffffff?g?g)\(?g{Gz?c                   <    e Zd ZU dZeed<   eed<   eed<   eed<   dS )#ObjectDetectionAggregatedEvaluationzGClass representing a gathered class-aggregated object detection metricsf1_score	precisionrecallm_apN)__name__
__module____qualname____doc__float__annotations__     a/var/www/html/ai-engine/env/lib/python3.11/site-packages/unstructured/metrics/object_detection.pyr   r      s=         QQOOOMMM
KKKKKr   r   c                       e Zd ZU dZeeef         ed<   eeef         ed<   eeef         ed<   eeef         ed<   ed             Z	dS )!ObjectDetectionPerClassEvaluationz@Class representing a gathered object detection metrics per-classr   r   r	   r
   c                 p   fdt          t                              D             }fdt          t                              D             fdt          t                              D             fdt          t                              D             } | ||          S )Nc                 .    i | ]}|         |         S r   r   ).0iclass_labelsf1s     r   
<dictcomp>zBObjectDetectionPerClassEvaluation.from_tensors.<locals>.<dictcomp>(   s#    MMMqLORUMMMr   c                 .    i | ]}|         |         S r   r   )r   r   r   r   s     r   r   zBObjectDetectionPerClassEvaluation.from_tensors.<locals>.<dictcomp>)   s#    UUUq\!_ilUUUr   c                 .    i | ]}|         |         S r   r   )r   r   r   r	   s     r   r   zBObjectDetectionPerClassEvaluation.from_tensors.<locals>.<dictcomp>*   s#    OOO,q/6!9OOOr   c                 .    i | ]}|         |         S r   r   )r   r   apr   s     r   r   zBObjectDetectionPerClassEvaluation.from_tensors.<locals>.<dictcomp>+   s#    III1QAIIIr   )rangelen)clsr    r   r	   r   r   r   r
   s    `````  r   from_tensorsz.ObjectDetectionPerClassEvaluation.from_tensors&   s    MMMMME#l:K:K4L4LMMMUUUUUE#lBSBS<T<TUUU	OOOOOeC<M<M6N6NOOOIIIIIc,6G6G0H0HIIIs8Y555r   N)
r   r   r   r   dictstrr   r   classmethodr$   r   r   r   r   r      s         JJ3:CJe
sEz
6 6 [6 6 6r   r   c                   ^   e Zd ZeZeZeZ	 d4de	e
j                 de	e
j                 de	e         de	e         de	e         defdZed	ed
edd fd            Zdeeef         fdZededee	e	f         fd            Zed5dedede	e         fd            Zede
j        de
j        dede
j        fd            Zedej        deeef         dej        fd            Zede
j        de
j        de
j        fd            Zde
j        de
j        de
j        de
j        d e
j        d!e
j        d"e
j        d#e
j        de
j        fd$Z 	 	 d6d'e
j        d(e
j        d)ed*eded+edefd,Z!d e
j        d-e
j        de
j        de
j        de
j        defd.Z"d e
j        d-e
j        de
j        d/ed0e
j        d1e#fd2Z$d3S )7ObjectDetectionEvalProcessorcpudocument_predsdocument_targetspages_heightpages_widthr   devicec                     | _         fd|D             | _        fd|D             | _        || _        || _        || _        dS )a  
        Initializes the ObjectDetection prediction and ground truth.

        Args:
            document_preds (list):      list (of length pages of document) of
                                        Tensors of shape (num_predictions, 6)
                                        format: (x1, y1, x2, y2, confidence,class_label)
                                        where x1,y1,x2,y2 are according to image size
            document_targets (list):    list (of length pages of document) of
                                        Tensors of shape (num_targets, 6)
                                        format: (label, x1, y1, x2, y2)
                                        where x,y,w,h are according to image size
            pages_height (list):        list of height of each page in the document
            pages_width (list):         list of width of each page in the document
            class_labels (list):        list of class labels
        c                 :    g | ]}|                               S r   to)r   predr/   s     r   
<listcomp>z9ObjectDetectionEvalProcessor.__init__.<locals>.<listcomp>O   s#    JJJ4twwvJJJr   c                 :    g | ]}|                               S r   r2   )r   targetr/   s     r   r5   z9ObjectDetectionEvalProcessor.__init__.<locals>.<listcomp>P   s%     R R Rv6!2!2 R R Rr   N)r/   r+   r,   r-   r.   r   )selfr+   r,   r-   r.   r   r/   s         `r   __init__z%ObjectDetectionEvalProcessor.__init__5   sc    2 JJJJ>JJJ R R R RAQ R R R(&(r   prediction_file_pathground_truth_file_pathreturnc                 j   t          |          5 }t          j        |          }ddd           n# 1 swxY w Y   t          |          5 }t          j        |          }ddd           n# 1 swxY w Y   t          |d                   t          |d                   k    s
J d            t	          |d                   t	          |d                   k    s
J d            t          t          |d         d           t          |d         d                     D ]\  }}|d	         |d	         k    s-J d
|j         d|d	          d|j         d|d	          d	            |d	         }|d         |d         k    sZJ d|j         d|d         d          d|d         d          d|j         d|d         d          d|d         d          d| d            |d         }	|                     ||	d          }
|                     ||	          }|                     |          \  }} | |
||||	          S )aI  
        Initializes the ObjectDetection prediction and ground truth,
        and converts the data to the required format.

        Args:
            prediction_file_path (Path): path to json file with predictions dump from OD model
            ground_truth_file_path (Path): path to json file with OD ground truth data
        Nobject_detection_classesz5Classes in predictions and ground truth do not match.pagesz:Pages number in predictions and ground truth do not match.c                     | d         S Nnumberr   ps    r   <lambda>z>ObjectDetectionEvalProcessor.from_json_files.<locals>.<lambda>q   s
    AhK r   )keyc                     | d         S rA   r   rC   s    r   rE   z>ObjectDetectionEvalProcessor.from_json_files.<locals>.<lambda>r   s
    Qx[ r   rB   zPage numbers in predictions z (z) and ground truth z) do not match.sizezPage sizes in predictions r   z x    z) do not match for page .T)
prediction)	openjsonloadsortedr"   zipname_process_data_parse_page_dimensions)r#   r:   r;   fpredictions_dataground_truth_data	pred_pagegt_pagepage_numr   r+   r,   r-   r.   s                 r   from_json_filesz,ObjectDetectionEvalProcessor.from_json_filesU   s     &'' 	,1#y||	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,()) 	-Q $	!	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- &'ABCCv89H
 H
 
 
 
B
 
 
 #G,--g&2
 2
 
 
 
G
 
 
 #&#G,2G2GHHH$W-3H3HIII#
 #
 	 	Iw X&'(*;;;;7/C/H 7 7h'7 7<R<W7 7H%7 7 7 <;;
 !*H V$777K-A-F K Kf%a(K K-6v->q-AK K$:$?K KCJ6?STCUK K 6?1%K K @HK K K 8777 ((BC**+;\VZ*[[,,->MM$'$>$>?O$P$P!ks>#3\;P\]]]s   155A,,A03A0c                 |   g }t          | j        | j        | j        | j                  D ]5\  }}}}|                     ||||          }|                    |           6d\  }}}	}
t          | j                  }t          j
        |t          j                  }t          j
        |t          j                  }t          j
        |t          j                  }t          j
        |t          j                  }t          |          rId t          t          |           D             } | j        | \  }}}}}|                                |                                |                                }
}	}|                                }|                    d          }|                    d          }|                    d          }|                    d          }t          |          D ]e\  }}t!          ||                   ||<   t!          ||                   ||<   t!          ||                   ||<   t!          ||                   ||<   ft"                              ||||| j                  }t'          t!          |
          t!          |          t!          |	          t!          |                    }||fS )zGet per document OD metrics.

        Returns:
            tuple: Tuple of ObjectDetectionAggregatedEvaluation and
                ObjectDetectionPerClassEvaluation
        )predstargetsheightwidth)      r`   r`   r`   c                 8    g | ]}t          j        |d           S )r   )torchcat)r   xs     r   r5   z<ObjectDetectionEvalProcessor.get_metrics.<locals>.<listcomp>   s"    $]$]$]UYq!__$]$]$]r   rI   )r    r   r	   r   r   )r   r   r	   r
   )rP   r+   r,   r-   r.    _compute_page_detection_matchingappendr"   r   npfullnanlist_compute_detection_metricsmean	enumerater   r   r$   r   )r8   document_matchingsr\   r]   r^   r_   page_matching_tensorsmean_apmean_precisionmean_recallmean_f1num_clsmean_ap_per_classmean_precision_per_classmean_recall_per_classmean_f1_per_classmatching_info_tensorsap_per_present_classesprecision_per_present_classesrecall_per_present_classesf1_per_present_classespresent_classesap_per_classprecision_per_classrecall_per_classf1_per_classr   class_indexod_per_class_evaluationod_evaluations                                 r   get_metricsz(ObjectDetectionEvalProcessor.get_metrics   s     -0!68I4K[.
 .
 
	= 
	=)E7FE %)$I$I	 %J % %! %%&;<<<<9
5g d'((GGRV44#%77BF#;#;  " 8 8GGRV44!"" %	H$]$]d3HZC[>\>\$]$]$]! 0/&&-*& .2244*//11&++-- *1KN -1133G 266q99L"?"D"DQ"G"G9>>qAA166q99L"+O"<"< H H;16|A1G1G!+.8=>QRS>T8U8U(55:;KA;N5O5O%k216|A1G1G!+.."C"P"P .( * #Q #
 #
 <7^^N++%%w	
 
 
 555r   datac                     g }g }| d         D ]D}|                     |d         d                    |                     |d         d                    E||fS )zX
        Process the page dimensions from the json file to the required format.
        r?   rH   r^   r_   )rf   )r   r-   r.   pages       r   rS   z3ObjectDetectionEvalProcessor._parse_page_dimensions   si    
 M 	6 	6DVX 6777tF|G45555[((r   FrK   c           
      `   g }| d         D ]}g }|d         D ]l}|d         }|                     |          }|d         \  }	}
}}|r$|d         }|                    |	|
||||g           R|                    ||	|
||g           mt          j        |          }|                    |           |S )zQ
        Process the elements from the json file to the required format.
        r?   elementstypebboxprob)indexrf   rb   tensor)r   r   rK   
pages_listr   page_elementselementclass_label	class_idxx1y1x2y2
confidencepage_tensors                  r   rR   z*ObjectDetectionEvalProcessor._process_data   s    
 
M 	+ 	+DM
+ 	F 	F%fo(..{;;	!(BB F!(J!(("b"b*i)PQQQQ!(()RR)DEEEE,}55Kk****r   preds_scores	preds_clstop_kc                    t          j        |          }|                    dd          t          j        |dz   | j                                      dd          k    }|                     dd          |z  }|                    dd          \  }}|d|ddf                             d	          }||                    dd
                   }	|	                    d          S )a  
        Get the indexes of all the top k predictions for every class

        Args:
            preds_scores:   The confidence scores, vector of shape (n_pred)
            preds_cls:      The predicted class, vector of shape (n_pred)
            top_k:          Number of predictions to keep per class, ordered by confidence score

        Returns:
            top_k_idx:     Indexes of the top k predictions. length <= (k * n_unique_class)
        rI   r/   r   T
descendingNFas_tupledim)rb   maxviewaranger/   sortnonzerosplit)
r   r   r   n_unique_clsmaskpreds_scores_per_clssorted_scores_per_clssorting_idxidx_with_satisfying_scores	top_k_idxs
             r   _get_top_k_idx_per_clsz3ObjectDetectionEvalProcessor._get_top_k_idx_per_cls	  s      y++~~b!$$1\%8)
 )
 )

$q"++  ,00Q77$>-A-F-FqUY-F-Z-Z*{%:6E61119%E%M%MW\%M%]%]" : @ @ @ J JK	~~b!!!r   boxes	img_shapec                     | dddgf                              d|d                   | dddgf<   | dddgf                              d|d                   | dddgf<   | S )a*  
        Clips bboxes to image boundaries.

        Args:
            bboxes:         Input bounding boxes in XYXY format of [..., 4] shape
            img_shape:      Image shape (height, width).
        Returns:
            clipped_boxes:  Clipped bboxes in XYXY format of [..., 4] shape
        .r      rI   )minr      )clip)r   r   s     r   "_change_bbox_bounds_for_image_sizez?ObjectDetectionEvalProcessor._change_bbox_bounds_for_image_size$  su     #3A;/44	!4MMcAq6k"3A;/44	!4MMcAq6kr   box1box2c                 x   d } || j                   } ||j                   }t          j        | dddddf         |ddddf                   t          j        | dddddf         |ddddf                   z
                      d                              d          }||dddf         |z   |z
  z  S )a  
        Return intersection-over-union (Jaccard index) of boxes.
        Both sets of boxes are expected to be in (x1, y1, x2, y2) format.

        Args:
            box1: Tensor of shape [N, 4]
            box2: Tensor of shape [M, 4]

        Returns:
            iou:    Tensor of shape [N, M]: the NxM matrix containing the pairwise IoU values
                    for every element in boxes1 and boxes2
        c                 H    | d         | d         z
  | d         | d         z
  z  S )Nr   r   r   rI   r   )boxs    r   box_areaz7ObjectDetectionEvalProcessor._box_iou.<locals>.box_areaF  s%    FSVOAQ88r   Nr   r   )Trb   r   r   clampprod)r   r   r   area1area2inters         r   _box_iouz%ObjectDetectionEvalProcessor._box_iou6  s     	9 	9 	9      YtAAAtQRRK($qqq!""u+6644QSRSQSCTVZ[\[\[\^`_`^`[`Va9b9bbU1XXT!WW 	
 aaag.677r   preds_box_xyxytargets_box_xyxytargets_clspreds_matchedtargets_matchedpreds_idx_to_useiou_thresholdsc	                 8   |                      ||         |          }	||                             dd          |                    dd          k    }
d|	|
<   |	                    dd          \  }}||d         k                        d          D ]\  }}||         }|||f         }|||f         |k    }t	          j        ||ddf          ||ddf                    }t	          j        ||          }d|||f<   d|||f<   |                                r n|S )	a  
        Computes the matching targets based on IoU for regular scenarios.

        Args:
            preds_box_xyxy: (torch.Tensor) Predicted bounding boxes in XYXY format.
            preds_cls: (torch.Tensor) Predicted classes.
            targets_box_xyxy: (torch.Tensor) Target bounding boxes in XYXY format.
            targets_cls: (torch.Tensor) Target classes.
            preds_matched: (torch.Tensor) Tensor indicating which predictions are matched.
            targets_matched: (torch.Tensor) Tensor indicating which targets are matched.
            preds_idx_to_use: (torch.Tensor) Indices of predictions to use.

        Returns:
            targets: Computed matching targets.
        r   rI   r   T)r   stableFr   N)r   r   r   r   rb   logical_andall)r8   r   r   r   r   r   r   r   r   ioucls_mismatch
sorted_ioutarget_sortedpred_selected_itarget_sorted_ipred_itarget_iis_iou_above_thresholdare_candidates_freeare_candidates_goods                       r   _compute_targetsz-ObjectDetectionEvalProcessor._compute_targetsU  s   8 mmN+;<>NOO !!1277A>>+BRBRSTVXBYBYYL
 %(HHTH$J$J!
M 2<nQ>O1O0X0X 1Y 1
 1
 	 	,O_
 &o6F$_o%EFH &00P%QTb%b" #("3vqqqy))OHaaaK,H+H# #
 #("34JL_"`"`
 >BOH&99:9=M&"556 ""$$  r   d   Tr\   r]   r^   r_   return_on_cpuc           
         | j                             | j                  }t          |          }|t          |          dk    rt	          j        d|ft          j        | j                  }	t	          j        d|ft          j        | j                  }
t	          j        g t          j        | j                  }t	          j        g t          j        | j                  }|dddf                             | j                  }|	|
|||fS t	          j        t          |          |t          j        | j                  }	t	          j        t          |          |t          j        | j                  }t	          j        t          |          |t          j        | j                  }
|dddf         |ddddf         |dddf         }}}|dddf         |ddddf         }}| 	                    |||          }d	|
ddddf<   d
|
|<   t          |          dk    r4| 
                    |||f           |                     |||||	|||          }	|	|
|||fS )aC  
        Match predictions (NMS output) and the targets (ground truth) with respect to metric
        and confidence score for a given image.

        Args:
            preds:          Tensor of shape (num_img_predictions, 6)
                            format: (x1, y1, x2, y2, confidence, class_label)
                            where x1,y1,x2,y2 are according to image size
            targets:        targets for this image of shape (num_img_targets, 5)
                            format:     (label, x1, y1, x2, y2)
                            where x1,y1,x2,y2 are according to image size
            height:         dimensions of the image
            width:          dimensions of the image
            top_k:          Number of predictions to keep per class, ordered by confidence score
            return_on_cpu:  If True, the output will be returned on "CPU", otherwise it will be
                            returned on "device"

        Returns:
            preds_matched:      Tensor of shape (num_img_predictions, n_thresholds)
                                True when prediction (i) is matched with a target with respect to
                                the (j)th threshold
            preds_to_ignore:    Tensor of shape (num_img_predictions, n_thresholds)
                                True when prediction (i) is matched with a crowd target with
                                respect to the (j)th threshold
            preds_scores:       Tensor of shape (num_img_predictions),
                                confidence score for every prediction
            preds_cls:          Tensor of shape (num_img_predictions),
                                predicted class for every prediction
            targets_cls:        Tensor of shape (num_img_targets),
                                ground truth class for every target
        r   Nr   )dtyper/   r      rI      TF)r   r3   r/   r"   rb   zerosboolr   float32r   r   r   )r8   r\   r]   r^   r_   r   r   
thresholdsnum_thresholdsr   preds_to_ignorer   r   r   r   	preds_boxtargets_boxr   s                     r   re   z=ObjectDetectionEvalProcessor._compute_page_detection_matching  sp   R (++4;+??
Z=CJJ!OO!KN(;5:VZVabbbM#k1n*=UZX\XcdddO <%-TTTLRu}T[QQQI!!!!Q$-**$+*>>K /<KWWJJej
 
 
  +LL.
4;
 
 
  +JJej
 
 
 .3111b5\5AaC=%PQPQPQSTPT+l9	#*111a4='!!!QqS&/[  66|YPUVV $111,1()w<<!33EFE?KKK 11 	 	M o|YSSr   r   c           	         |                     | j                  |                     | j                  }}|                     | j                  |                     | j                  |                     | j                  }}}| j                             | j                  }| j        }t	          j        |                                          }t          |          |j        d         }
}	t	          j	        |	|
f| j                  }t	          j	        |	|
f| j                  }t	          j	        |	|
f| j                  }t          |          D ]o\  }}||k    ||k    }}|                     ||         ||         ||         |                                ||          \  }}}|||ddf<   |||ddf<   |||ddf<   pd|z  |z  ||z   dz   z  }|||||fS )a  
        Compute the list of precision, recall, MaP and f1 for every class.

        Args:
            preds_matched:      Tensor of shape (num_predictions, n_iou_thresholds)
                                True when prediction (i) is matched with a target with respect
                                to the (j)th IoU threshold
            preds_to_ignore     Tensor of shape (num_predictions, n_iou_thresholds)
                                True when prediction (i) is matched with a crowd target with
                                respect to the (j)th IoU threshold
            preds_scores:       Tensor of shape (num_predictions),
                                confidence score for every prediction
            preds_cls:          Tensor of shape (num_predictions),
                                predicted class for every prediction
            targets_cls:        Tensor of shape (num_targets),
                                ground truth class for every target box to be detected

        Returns:
            ap, precision, recall, f1:  Tensors of shape (n_class, nb_iou_thrs)
            unique_classes:             Vector with all unique target classes
        r   r   )r   r   r   	n_targetsrecall_thresholdsscore_thresholdNr   gؗҜ<)r3   r/   r   r   rb   uniquelongr"   shaper   rm   "_compute_detection_metrics_per_clssum)r8   r   r   r   r   r   r   r   unique_classesn_classnb_iou_thrsr    r   r	   cls_iclass_valuecls_preds_idxcls_targets_idxcls_apcls_precision
cls_recallr   s                         r   rk   z7ObjectDetectionEvalProcessor._compute_detection_metrics  s
   > *7)9)9$+)F)FHZHZKI
 I
 OODK((LL%%NN4;'' "-i !255dkBB.k227799">22M4G4K[';/DDDK+ 6t{KKK	g{3DKHHH"+N";"; 	* 	*E;.7;.F{* +M 77+M: / >)-8)--//"3 / 8  	 "BuaaaxL"/IeQQQh)F5!!!8]V#y6'9E'AB9fb.88r   r   r   r   c                 &   |j         d         }|}t          j        t          j        |          t          j        |                    }	t	          |          dk    rPt          j        || j                  t          j        || j                  t          j        || j                  fS |j        r|j        t          j	        u rt          j
        n|j        }
t          j        |                    |
          d          }||ddf         }|	|ddf         }	||                                         }t          j        |dt          j                  }t          j        |	dt          j                  }||z  }|||z   t          j        t          j                  j        z   z  }|                    d                              d          j                            d          }t          j        | | d          }|dk    r7t          j        || j                  }t          j        || j                  }n||d	z
           }||d	z
           }|                    d	d                              |d	          }t          j        |j                                        |d
          j        }t          j        |t          j        d	|| j                  fd          }t          j        ||d          }|                    d          }|||fS )a  
        Compute the list of precision, recall and MaP of a given class for every recall threshold.

        Args:
            preds_matched:      Tensor of shape (num_predictions, n_thresholds)
                                True when prediction (i) is matched with a target
                                with respect to the(j)th threshold
            preds_to_ignore     Tensor of shape (num_predictions, n_thresholds)
                                True when prediction (i) is matched with a crowd target
                                with respect to the (j)th threshold
            preds_scores:       Tensor of shape (num_predictions),
                                confidence score for every prediction
            n_targets:          Number of target boxes of this class
            recall_thresholds:  Tensor of shape (max_n_rec_thresh)
                                list of recall thresholds used to compute MaP
            score_threshold:    Minimum confidence score to consider a prediction
                                for the computation of precision and recall (not MaP)

        Returns:
            ap, precision, recall:     Tensors of shape (nb_thrs)
        r   r   r   Tr   N)axisr   )rightrI   Fr   )inputr   r   )r   rb   r   logical_notr"   r   r/   is_cudar   r   uint8argsortr3   
contiguouscumsumr   finfofloat64epsflipcummaxvaluessearchsortedr   repeatr   rc   gatherrl   )r8   r   r   r   r   r   r   r   tpsfpsr   sort_indrolling_tpsrolling_fpsrolling_recallsrolling_precisionslowest_score_above_thresholdr	   r   recall_threshold_idxsampled_precision_pointsr    s                         r   r   z?ObjectDetectionEvalProcessor._compute_detection_metrics_per_cls@  s"   @ $)"-m,,e.?.P.P
 
 s88q==K<<<K<<<K<<<  #$(4(:ej(H(H KK# 	
 =!7!7DIII(AAA+(AAA+#H-88:: l3QekBBBl3QekBBB%	1(+%EM(B(B(FF

 044Q77>>qAAHMMaPP (-'9MO+4(
 (
 (
$
 )A--[T[AAAFDK  II %%AA%EFF*+G!+KLI .221b99@@aPP  %1((**,=U 
  
  

 	 #YQDK!P!P!PQWX
 
 

 $)<$,@a$
 $
 $
 
 &**1--9f$$r   N)r*   )F)r   T)%r   r   r   IOU_THRESHOLDSr   SCORE_THRESHOLDr   RECALL_THRESHOLDSr   rj   rb   Tensorintr&   r9   r'   r   rZ   tupler   r   r   staticmethodr%   rS   r   rR   r   rg   ndarrayr   r   r   re   rk   r   r   r   r   r   r)   r)   0   s       #N%O) ) )U\*) u|,) 3i	)
 #Y) 3i) ) ) ) )@ 2^"2^ !%2^ 
(	2^ 2^ 2^ [2^hZ6	24UU	VZ6 Z6 Z6 Z6x 	)T 	)eD$J.? 	) 	) 	) \	)  D D TRVZ    \, "l"/4|"DG"	" " " \"4 z&+CHo	   \" 8u| 85< 8EL 8 8 8 \8<II <I  ,	I
 \I |I I  ,I I 
I I I Ib "TT TT|TT TT 	TT
 TT TT TT 
TT TT TT TTlH9|H9 H9 l	H9
 <H9 \H9 
H9 H9 H9 H9Ty%|y% y% l	y%
 y% !<y% y% y% y% y% y% y%r   r)   __main__)asdictzpths/to/predictions.jsonzpths/to/predictions2.jsonzpths/to/ground_truth.jsonzpths/to/ground_truth2.jsonzMetrics for z:
zPer class Metrics for )r   rM   dataclassesr   pathlibr   numpyrg   rb   r   r   r!  r   r"  r   r   r)   r   r)  prediction_file_pathsground_truth_file_pathsrP   r:   r;   rZ   eval_processorr   metricsper_class_metricsprintrQ   r   r   r   <module>r3     sa     ! ! ! ! ! !           TTT   ELD$//          6 6 6 6 6 6 6 6$I
% I
% I
% I
% I
% I
% I
% I
%X z"""""" "T"<==ttD_?`?`a()))**
 9<69 9 	d 	d44 6EE "8
 
 &4%?%?%A%A""N38NNVVG__NNOOOb'='BbbvvN_G`G`bbcccc' 	d 	dr   