§
    à©ºjbT  ã                  óV  — d Z ddlmZ ddlZddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZmZmZmZ ed	         Zd
Zed         Zed         Zed         Zed         Zed         Zed         ZdZdZd)d*d„Zd„ Zdad+d„Zddœd„Z d,d„Z!d-d„Z"d-d „Z#d.d-d"„Z$d-d#„Z%d-d$„Z&d.d-d%„Z'd/d,d'„Z(d0d1d(„Z)dS )2uC   Interactive eval dashboard â€” Plotly charts for the browse server.é    )ÚannotationsNé   )ÚTIDE_ERROR_ORDERÚ_report_curvesÚ_top_confusion_keep)ÚPlotData)Ú_build_metric_rows)ÚCHROME_DARKÚEVAL_COLORS_DARKÚSEQUENTIAL_DARKÚSERIES_COLORS_DARKÚplot_bgz#242427ÚtextÚlabelÚtickÚgridé   z>'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serifz8'IBM Plex Mono', ui-monospace, SFMono-Regular, monospaceÚ	overridesúdict | NoneÚreturnÚdictc                ó¾  — ddt           ii}dt          i}t          t          t          t          t          ¬¦  «        }| r•t          | ¦  «        } |                      dd¦  «        }|�.|                     t          |t          ¦  «        rd|in|¦  «         |                     |                      dd¦  «        pi ¦  «         |                     | ¦  «         ||d<   ||d<   |S )a  Dark-theme axis styling, merged with per-chart *overrides*.

    ``title.font`` (not the plotly<6-only ``titlefont``) is the spelling valid
    on both plotly 5 and 6. A string ``title`` override is normalized to
    ``{"text": ...}`` so the themed title font survives the merge.
    ÚfontÚcolor)Ú	gridcolorÚzerolinecolorÚ	linecolorÚ	tickcolorÚtitleNr   Útickfont)	Ú_TEXT_PRIMARYÚ_TEXT_SECONDARYr   Ú_BORDER_SUBTLEÚ_TEXT_TERTIARYÚpopÚupdateÚ
isinstanceÚstr)r   Útitle_styleÚtickfont_styleÚaxisr   s        úa/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/hotcoco/dashboard.pyÚ
_dark_axisr-       så   € ð   '­=Ð!9Ð:€KØ#¥_Ð5€NÝÝ µÍ.Õdrðñ ô €Dð ð Ý˜‘O”Oˆ	Ø—’˜g tÑ,Ô,ˆØÐØ×Òµ*¸UÅCÑ2HÔ2HÐS ¨˜˜ÈeÑTÔTÐTØ×Ò˜iŸmšm¨J¸Ñ=Ô=ÐCÀÑDÔDÐDØ�Š�IÑÔÐØ€Dˆ�MØ%€DˆÑØ€Kó    c                 ó*  — ddl m} t          i dt          t          t          t
          d¬¦  «        t          t          t
          t          ¬¦  «        t          dt          t          ¬¦  «        t          t          dd	d	d
¬¦  «        t          |                      dd¦  «        ¦  «        t          |                      dd¦  «        ¦  «        t          dt          t
          ¬¦  «        ¬¦  «        ¬¦  «        }|                     | ¦  «          |j        di |¤ŽS )um  Return a Plotly layout dict matching the browse dark theme.

    We set all dark-theme colors manually instead of using
    ``template="plotly_dark"`` because the built-in template embeds
    defaults for every trace type: scatter3d, scattergeo, mesh3d, and the rest.
    The cartesian partial bundle doesn't include those trace modules, so
    Plotly.js errors out trying to register them and nothing renders.

    ``xaxis``/``yaxis`` overrides are merged *into* the themed axis rather
    than replacing it â€” a caller that only sets a title and a range must not
    silently lose the grid, tick, and font colors.
    r   Nzrgba(0,0,0,0)é   )Úfamilyr   Úsize)ÚbgcolorÚ
font_colorÚbordercolor)r3   r   Úactivecoloré<   é   é(   ©ÚlÚrÚtÚbÚxaxisÚyaxis©r   )r3   r   )ÚtemplateÚpaper_bgcolorÚplot_bgcolorr   Ú
hoverlabelÚmodebarÚcolorwayÚmarginr?   r@   Úlegend© )Úplotly.graph_objectsÚgraph_objectsr   Ú_BG_ELEVATEDÚ
_FONT_BODYr!   Ú_BG_SURFACEr#   r$   Ú_ACCENTr   r-   r%   r&   ÚLayout)r   ÚgoÚbases      r,   Ú_dark_layoutrT   8   sû   € ð &Ð%Ð%Ð%Ð%Ð%åØØ%Ý!Ý�­=¸rÐBÑBÔBÝ¥½ÕSaÐbÑbÔbÝ˜_µNÕPWÐXÑXÔXÝ#Ý�b˜B "¨Ð+Ñ+Ô+Ý˜Ÿš w°Ñ5Ô5Ñ6Ô6Ý˜Ÿš w°Ñ5Ô5Ñ6Ô6Ý˜Oµ$½]Ð2KÑ2KÔ2KÐLÑLÔLðñ ô €Dð 	‡K‚K�	ÑÔÐØˆ2Œ9ÐÐ�tÐÐÐr.   Únamer(   c           	     óÒ   — t           €Gddlm} ddlm}m}  | |t           |t          ¦  «        j        dz  ¦  «        ¦  «        d¬¦  «        a t            	                    | ¦  «        S )a  Load a Jinja template from the app's templates directory.

    The dashboard renders its native-HTML fragments (the per-category AP
    leaderboard) from ``templates/partials/`` like the rest of the app,
    rather than concatenating HTML strings next to a Jinja environment.
    Nr   )ÚPath)ÚEnvironmentÚFileSystemLoaderÚ	templatesT)ÚloaderÚ
autoescape)
Ú
_jinja_envÚpathlibrW   Újinja2rX   rY   r(   Ú__file__ÚparentÚget_template)rU   rW   rX   rY   s       r,   Ú_get_templaterc   [   s‚   € õ ÐØ Ð Ð Ð Ð Ð à8Ð8Ð8Ð8Ð8Ð8Ð8Ð8à �[Ð(8Ð(8½¸T¸TÅ(¹^¼^Ô=RÐU`Ñ=`Ñ9aÔ9aÑ(bÔ(bÐosÐtÑtÔtˆ
Ý×"Ò" 4Ñ(Ô(Ð(r.   ©Úpost_scriptc               ó<   — |                       dd|dddœ|¬¦  «        S )z+Render a Plotly figure to an HTML fragment.FT)Ú
responsiveÚdisplaylogo)Ú	full_htmlÚinclude_plotlyjsÚdiv_idÚconfigre   )Úto_html)Úfigrk   re   s      r,   Ú_to_htmlro   l   s4   € à�;Š;ØØØØ"°5Ð9Ð9Øð ñ ô ð r.   ú
list[dict]c                óò   ‡— t          | t          ¦  «        r| nt          j        | ¦  «        Št          ‰¦  «        \  }}}d„ |D ¦   «         dd…         }|r|                     |¦  «         ˆfd„|D ¦   «         S )ah  Extract headline metrics for KPI tile display.

    Accepts a ``PlotData`` (the orchestrator already built one) or a COCOeval.

    Returns a list of {key, value} dicts in display order: the first three AP
    metrics plus the primary AR metric, in the evaluator's canonical order.

    Derived from `metric_defs()` through the same helper the PDF report uses,
    never from a hardcoded list of names. The hardcoded version listed AR100 /
    AR10 / AR1 and so found no AR metric at all on keypoints (which reports
    "AR") or LVIS (which reports "AR@300"), silently rendering three tiles
    instead of four.
    c                ó   — g | ]\  }}}|‘Œ	S rJ   rJ   )Ú.0ÚkeyÚ_s      r,   ú
<listcomp>zkpi_tiles.<locals>.<listcomp>‹   s   € Ð2Ð2Ð2™Y˜S ! Q�SÐ2Ð2Ð2r.   Né   c                óL   •— g | ] }|‰j                              |d ¦  «        dœ‘Œ!S )ç        )rt   Úvalue)ÚmetricsÚget)rs   ÚkÚdatas     €r,   rv   zkpi_tiles.<locals>.<listcomp>�   s3   ø€ ÐQÐQÐQ¸a�A ¤× 0Ò 0°°CÑ 8Ô 8Ð9Ð9ÐQÐQÐQr.   )r'   r   Úfrom_coco_evalr	   Úappend)Údata_or_evalÚap_rowsru   Ú
ar_kpi_keyÚheadline_keysr~   s        @r,   Ú	kpi_tilesr…   z   s�   ø€ õ & lµHÑ=Ô=Ðhˆ<ˆ<Å8ÔCZÐ[gÑChÔCh€DÝ/°Ñ5Ô5Ñ€GˆQ�
à2Ð2¨'Ð2Ñ2Ô2°2°A°2Ô6€MØð )Ø×Ò˜ZÑ(Ô(Ð(àQÐQÐQÐQÀ=ÐQÑQÔQÐQr.   c                ó¦  — ddl m} t          |                      ¦   «         d         ¦  «        \  }}}|                     t          dt          dddgt          ¬¦  «        t          dddgt          ¬¦  «        dt          t          d	¬
¦  «        ¬¦  «        ¬¦  «        ¬¦  «        }t          |¦  «        D ]_\  }}d„ ||         D ¦   «         }| 	                    | 
                    ||dd|d›�t          |dk    rdnd¬¦  «        d¬¦  «        ¦  «         Œ`|                     dddddt          t          dd¬¦  «        ¬¦  «         t          |d¦  «        S )a  IoU-sweep PR curves with hover showing threshold values.

    The curves come from `report()["curves"]`, which exists precisely to hand a
    renderer "the slice a chart actually draws": one aggregate precision curve
    per IoU threshold, already averaged over categories with the -1.0 sentinel
    excluded, sharing the evaluator's own `rec_thrs` x-axis. Re-deriving that
    here from the raw 5-D precision array meant a second place that had to agree
    about which area range, which maxDets, and what -1.0 means.
    r   NÚcurvesÚRecallr   ©r   Úranger   Ú	Precisioni¸  é   ©r2   ©r   )r   r?   r@   ÚheightrI   ©Úlayoutc                óX   — g | ]'}t          j        |¦  «        rd nt          |¦  «        ‘Œ(S ©N)ÚnpÚisnanÚfloat)rs   Úps     r,   rv   z#chart_pr_curves.<locals>.<listcomp>°   s/   € ÐIÐIÐI°1•R”X˜a‘[”[Ð.ˆTˆT¥e¨A¡h¤hÐIÐIÐIr.   ÚlineszIoU=ú.2fg      @g      ø?)ÚwidthzJRecall: %{x:.3f}<br>Precision: %{y:.3f}<extra>IoU=%{fullData.name}</extra>)ÚxÚyÚmoderU   ÚlineÚhovertemplaterž   Údot©r   rš   Údash©ÚtypeÚx0Úy0Úx1Úy1rž   z	pr-curves)rK   rL   r   ÚreportÚFigurerT   r   r#   Ú	enumerateÚ	add_traceÚScatterÚ	add_shaper$   ro   )	Ú	coco_evalrR   Ú
recall_ptsÚiou_thrsÚ	precisionrn   Út_idxÚiou_thrrœ   s	            r,   Úchart_pr_curvesrµ   •   s‹  € ð &Ð%Ð%Ð%Ð%Ð%å&4°Y×5EÒ5EÑ5GÔ5GÈÔ5QÑ&RÔ&RÑ#€J�˜)à
�)Š)ÝØÝ˜X¨a°¨V½~ÐNÑNÔNÝ˜[°°A°Å.ÐQÑQÔQØÝ�T r˜]™]œ]Ð+Ñ+Ô+ð
ñ 
ô 
ð ñ ô €Cõ $ HÑ-Ô-ð 
ð 
‰ˆˆwð JÐI¸	À%Ô8HÐIÑIÔIˆà�ŠØ�JŠJØØØØ)˜GÐ)Ð)Ð)Ý u°¢z z  °sÐ;Ñ;Ô;Øjð ñ ô ñ		
ô 		
ð 		
ð 		
ð ‡M‚M�v !¨¨a°A½DÅ~Ð]^ÐejÐ<kÑ<kÔ<k€MÑlÔlÐlå�C˜Ñ%Ô%Ð%r.   c                óè  ‡‡‡‡— |                       d¬¦  «        }|                     di ¦  «        }t          |                     ¦   «         d„ d¬¦  «        }|r)t	          d„ |D ¦   «         ¦  «        t          |¦  «        z  ndŠt          d„ |D ¦   «         d	¬
¦  «        Št          |¦  «        ŠdŠˆˆˆˆfd„t          |d¦  «        D ¦   «         }t          d¦  «         	                    |‰‰‰¬¦  «        S )zBPer-category AP as a native HTML leaderboard with expand/collapse.T)Ú	per_classr·   c                ó   — | d         S )Nr   rJ   )r›   s    r,   ú<lambda>z'chart_per_category_ap.<locals>.<lambda>Ë   s
   € °A°a´D€ r.   )rt   Úreversec              3  ó    K  — | ]	\  }}|V — Œ
d S r“   rJ   ©rs   ru   Úvs      r,   ú	<genexpr>z(chart_per_category_ap.<locals>.<genexpr>Ì   ó&   è è € Ð&Ð&™˜˜1�!Ð&Ð&Ð&Ð&Ð&Ð&r.   ry   c              3  ó    K  — | ]	\  }}|V — Œ
d S r“   rJ   r¼   s      r,   r¾   z(chart_per_category_ap.<locals>.<genexpr>Í   r¿   r.   g      ð?©Údefaulté   c           	     óf   •— g | ]-\  }\  }}|||‰d k    r|‰z  dz  nd|‰k    |‰k    o‰‰k    dœ‘Œ.S )r   éd   ry   )ÚrankrU   ÚapÚpctÚ
above_meanÚhiddenrJ   )rs   rÆ   rU   rÇ   Úcollapsed_nÚmax_apÚmean_apÚtotals       €€€€r,   rv   z)chart_per_category_ap.<locals>.<listcomp>Ñ   su   ø€ ð 
ð 
ð 
ñ ˆD‘*�4˜ð ØØØ*0°1ª*¨*�B˜‘K #Ñ%Ð%¸#Ø š-Ø˜[Ò(Ð@¨U°[Ò-@ð	
ð 	
ð
ð 
ð 
r.   r   zpartials/per_category_ap.html)ÚrowsrÍ   rÎ   rË   )
Úresultsr|   ÚsortedÚitemsÚsumÚlenÚmaxr«   rc   Úrender)	r¯   rÐ   r·   rÒ   rÏ   rË   rÌ   rÍ   rÎ   s	        @@@@r,   Úchart_per_category_apr×   Æ   s&  øøøø€ à×Ò¨$ÐÑ/Ô/€GØ—’˜K¨Ñ,Ô,€Iå�9—?’?Ñ$Ô$¨.¨.À$ÐGÑGÔG€EØ7<ÐE�cÐ&Ð& Ð&Ñ&Ô&Ñ&Ô&­¨U©¬Ñ3Ð3À#€GÝÐ&Ð& Ð&Ñ&Ô&°Ð4Ñ4Ô4€FÝ�‰JŒJ€EØ€Kð
ð 
ð 
ð 
ð 
ð 
ð 
õ !*¨%°Ñ 3Ô 3ð
ñ 
ô 
€Dõ Ð8Ñ9Ô9×@Ò@Ø˜7¨%¸[ð Añ ô ð r.   ç      à?c                ó  ‡‡‡— ddl m} |                      |¬¦  «        }t          |d         ¦  «        }|dgz   Št	          j        |d         t          ¬¦  «        Št	          j        |d         t          ¬¦  «        }t          ‰t          |¦  «        ¦  «        }|�D‰t	          j	        ||¦  «                 Š|t	          j	        ||¦  «                 }ˆfd	„|D ¦   «         Št          ‰¦  «        Šg }t          ‰¦  «        D ]j}g }	t          ‰¦  «        D ]A}
|	                     d
‰|         › d‰|
         › d‰||
f         d›d|||
f         d›�¦  «         ŒB|                     |	¦  «         Œk‰dk    }|rˆˆfd„t          ‰¦  «        D ¦   «         nd}|                     t          dt          ddt          t          t           d¬¦  «        ¬¦  «        t          ddt          t          t           d¬¦  «        ¬¦  «        t#          dd‰z  dz   ¦  «        t          dddd¬¦  «        d ¬!¦  «        ¬"¦  «        }|                     |                     ‰                     ¦   «         ‰‰||rd#ndt          t#          d$t+          dd%‰z  ¦  «        ¦  «        ¬&¦  «        |d'dt,          d         gd(t,          d)         gd)t,          d*         ggt          d+t          t           ¬,¦  «        ¬-¦  «        dd)¬.¦  «        ¦  «         d/}t/          |d0|¬1¦  «        S )2z%Interactive confusion matrix heatmap.r   N©r´   Ú	cat_namesÚBGÚ
normalized)ÚdtypeÚmatrixc                ó    •— g | ]
}‰|         ‘ŒS rJ   rJ   )rs   ÚiÚlabelss     €r,   rv   z*chart_confusion_matrix.<locals>.<listcomp>ó   s   ø€ Ð*Ð*Ð* �&˜”)Ð*Ð*Ð*r.   zGT: z
<br>Pred: z
<br>Rate: ú.3fz<br>Count: z,.0fr8   c                óJ   •‡— g | ]Šˆˆfd „t          ‰¦  «        D ¦   «         ‘ŒS )c                óX   •— g | ]&}‰‰         |         d k    r‰‰         |         d›nd‘Œ'S )g{®Gáz„?r™   Ú rJ   )rs   Újr~   rá   s     €€r,   rv   z5chart_confusion_matrix.<locals>.<listcomp>.<listcomp>  s>   ø€ Ð	MÐ	MÐ	M¸q  a¤¨¤¨dÒ!2Ð!2ˆT�!ŒW�QŒZÐ
Ð
Ð
¸Ð	MÐ	MÐ	Mr.   )rŠ   )rs   rá   r~   Úns    @€€r,   rv   z*chart_confusion_matrix.<locals>.<listcomp>  s9   øø€ Ð`Ð`Ð`ÐRSÐ	MÐ	MÐ	MÐ	MÐ	MÅEÈ!ÁHÄHÐ	MÑ	MÔ	MÐ`Ð`Ð`r.   Ú	Predictedé-   rŒ   )r   r2   )r   Ú	tickangler   r    zGround TruthÚreversed)r   Ú	autoranger   r    i&  é   éx   r9   rÅ   r:   F)r   r?   r@   r�   rH   Údragmoder�   z%{text}é   éÈ   r�   r   rØ   r   é   ÚRaterA   )r   r    )Úzr›   rœ   r   ÚtexttemplateÚtextfontÚ	hovertextÚ	hoverinfoÚ
colorscaleÚcolorbarÚzminÚzmaxa<  
    var plotDiv = document.getElementById('{plot_id}');
    plotDiv.on('plotly_click', function(data) {
        var pt = data.points[0];
        var gtCat = pt.y;
        if (gtCat === 'BG') return;
        window.location.href = '/?categories=' + encodeURIComponent(gtCat) + '&eval_filter=has_errors';
    });
    zconfusion-matrixrd   )rK   rL   Úconfusion_matrixÚlistr”   Úasarrayr–   r   rÔ   Úix_rŠ   r€   rª   rT   r   r#   r"   rÕ   r¬   ÚHeatmapÚtolistÚminr   ro   )r¯   r´   rR   ÚcmrÛ   ÚcountsÚkeepÚ
hover_textrá   Úrowrç   Ú	show_textr   rn   Úclick_scriptr~   râ   rè   s                  @@@r,   Úchart_confusion_matrixr  ä   sh  øøø€ à%Ð%Ð%Ð%Ð%Ð%à	×	#Ò	#¨GÐ	#Ñ	4Ô	4€BÝ�R˜”_Ñ%Ô%€IØ˜$˜Ñ€FåŒ:�b˜Ô&­eÐ4Ñ4Ô4€DÝŒZ˜˜8œ­EÐ2Ñ2Ô2€Få˜t¥S¨¡^¤^Ñ4Ô4€DØÐØ•B”F˜4 Ñ&Ô&Ô'ˆØ�œ˜t TÑ*Ô*Ô+ˆØ*Ð*Ð*Ð* TÐ*Ñ*Ô*ˆåˆF‰Œ€Að €JÝ�1‰XŒXð ð ˆØˆÝ�q‘”ð 	xð 	xˆAØ�JŠJÐv˜f QœiÐvÐv°6¸!´9ÐvÐvÈÈQÐPQÈTÌ
ÐvÐvÐvÐciÐjkÐmnÐjnÔcoÐvÐvÐvÑwÔwÐwÐwØ×Ò˜#ÑÔÐÐð �R’€IàdmÐwÐ`Ð`Ð`Ð`Ð`ÕW\Ð]^ÑW_ÔW_Ð`Ñ`Ô`Ð`Ðswð 	ð �)Š)ÝØÝØ!¨R½>ÕTXÕ_nÐuwÐTxÑTxÔTxðñ ô õ Ø$Ø$Ý(Ý¥O¸"Ð=Ñ=Ô=ð	ñ ô õ �s˜B ™F S™LÑ)Ô)Ý˜#  r¨SÐ1Ñ1Ô1Øð
ñ 
ô 
ð ñ ô €Cð$ ‡M‚MØ
�
Š
Ø�kŠk‰mŒmØØØØ&/Ð9˜˜°TÝ�s 1¥c¨"¨c°Q©hÑ&7Ô&7Ñ8Ô8Ð9Ñ9Ô9Ø ØØ�O¨AÔ.Ð/°#µÀqÔ7IÐ1JÈQÕP_Ð`aÔPbÐLcÐdÝ µ½OÐ1LÑ1LÔ1LÐMÑMÔMØØð 	ñ 	
ô 	
ñô ð ð"€Lõ �CÐ+¸ÐFÑFÔFÐFr.   c                ó6  ‡— t          | t          ¦  «        r| n|                      ¦   «         }|d         Š|d         }|                     di ¦  «        }dddddd	d
œ}t	          ˆfd„t
          D ¦   «         d¬¦  «        pd}g }t
          D ]q}||         \  }}	‰                     |d¦  «        }
|                     |d¦  «        }|dk    r|
|z  dz  nd}|                     d|	› d|› d|d›d|
d›d|d›d�¦  «         Œrdd                     |¦  «        z   d|d›d�z   S )uô   TIDE error breakdown as native HTML bars.

    Accepts the output of ``coco_eval.tide_errors()`` or a COCOeval to call it
    on â€” the orchestrator needs the same dict for the card subtitle, and TIDE is
    a full re-walk of the matches.
    Údelta_apÚap_baser  )ÚClassificationzPredicted wrong class)ÚLocalizationzPoor bounding box overlap)z	Cls + LoczWrong class and poor overlap)Ú	Duplicatez"Redundant detection of same object)Ú
BackgroundzDetection on background region)ÚMissedzFailed to detect a ground truth)ÚClsÚLocÚBothÚDupeÚBkgÚMissc              3  óD   •K  — | ]}‰                      |d ¦  «        V — ŒdS )ry   N)r|   )rs   r}   r  s     €r,   r¾   z$chart_tide_errors.<locals>.<genexpr>P  s1   øè è € ÐBÐB¨A�8—<’<  3Ñ'Ô'ÐBÐBÐBÐBÐBÐBr.   gü©ñÒMbP?rÁ   ry   r   rÅ   z6<div class="tide-row"><span class="tide-label" title="z">zG</span><span class="tide-bar-wrap"><span class="tide-bar" style="width:z.1fz*%"></span></span><span class="tide-delta">ú.4fz </span><span class="tide-count">ú,z</span></div>uj   <div class="tide-header"><span class="tide-header-label">Î”AP impact if error type were fixed</span></div>ú
zv<div class="tide-footer"><span class="tide-footer-label">Baseline AP @ IoU=0.50</span><span class="tide-footer-value">rã   )r'   r   Útide_errorsr|   rÕ   r   r€   Újoin)Útide_or_evalÚtider  r  ÚdescriptionsÚmax_valrÏ   rt   r   ÚdescÚvalÚcountrÈ   r  s                @r,   Úchart_tide_errorsr(  9  s²  ø€ õ & lµDÑ9Ô9ÐYˆ<ˆ<¸|×?WÒ?WÑ?YÔ?Y€DØ�JÔ€HØ�9Œo€GØ�XŠX�h Ñ#Ô#€Fð
 ;Ø<Ø=ØCØ?Ø=ðð €Lõ ÐBÐBÐBÐBÕ1AÐBÑBÔBÈEÐRÑRÔRÐ[ÐV[€Gà€DÝð 
ð 
ˆØ" 3Ô'‰ˆˆtØ�lŠl˜3 Ñ$Ô$ˆØ—
’
˜3 Ñ"Ô"ˆØ'.°¢{ {ˆs�W‰}˜sÑ"Ð"¸ˆØ�ŠðØ/3ðð Ø7<ðð ð 47ÐFðð ð
 ),Ð8ðð ð ).Ð8ðð ð ñ		
ô 		
ð 		
ð 		
ð	à—9’9˜T‘?”?ñ	#ð&à+2Ð?ð&ð &ð &ñ	ðr.   c                ó  — ddl m} |                      ¦   «         }|d         }|d         }|d         }d„ |D ¦   «         }d„ |D ¦   «         }d„ |D ¦   «         }|r |d         d	         |d         d
         z
  dz  nd}	g g g }}}
t          |||¦  «        D ]K\  }}}|dk    r?|
                     |¦  «         |                     |¦  «         |                     |¦  «         ŒL|                     t          dt          dddgt          ¬¦  «        t          dddgt          ¬¦  «        d¬¦  «        ¬¦  «        }| 	                    dddddt          t          dd¬¦  «        ¬¦  «         |                     |                     |
||	t          t          d¬¦  «        d|d¬¦  «        ¦  «         |                     ddddd|d ›d!|d ›�d"d#t          d$t          t           ¬%¦  «        t"          t          dd&¬'¦  «         t%          |d(¦  «        S ))z,Reliability diagram with ECE/MCE annotation.r   NÚbinsÚeceÚmcec                ó6   — g | ]}|d          |d         z   dz  ‘ŒS )Ú	bin_lowerÚ	bin_upperró   rJ   ©rs   r>   s     r,   rv   z%chart_calibration.<locals>.<listcomp>y  s*   € ÐEÐEÐE¸1�!�K”. 1 [¤>Ñ1°QÑ6ÐEÐEÐEr.   c                ó   — g | ]
}|d          ‘ŒS )Úavg_accuracyrJ   r0  s     r,   rv   z%chart_calibration.<locals>.<listcomp>z  s   € Ð2Ð2Ð2¨�!�NÔ#Ð2Ð2Ð2r.   c                ó   — g | ]
}|d          ‘ŒS )r'  rJ   r0  s     r,   rv   z%chart_calibration.<locals>.<listcomp>{  s   € Ð'Ð'Ð'˜Qˆa�ŒjÐ'Ð'Ð'r.   r/  r.  g333333ë?gÃõ(\�Âµ?Ú
Confidencer   r‰   ÚAccuracyi¤  )r   r?   r@   r�   r�   rž   r    r¡   r£   gffffffæ?)r   ÚopacityzQConfidence: %{x:.2f}<br>Accuracy: %{y:.3f}<br>Count: %{customdata}<extra></extra>)r›   rœ   rš   ÚmarkerrU   Ú
customdatarŸ   gffffffî?gš™™™™™©?ÚpaperzECE = r  z
<br>MCE = FÚrighté   )r2   r1   r   é   )r›   rœ   ÚxrefÚyrefr   Ú	showarrowÚalignr   r3   r5   ÚborderwidthÚ	borderpadÚcalibration)rK   rL   rC  Úzipr€   rª   rT   r   r#   r®   r$   r¬   ÚBarrP   Úadd_annotationÚ
_FONT_MONOr!   rO   ro   )r¯   rR   Úcalr*  r+  r,  Ú	midpointsÚ
accuraciesr  Ú	bin_widthÚmid_neÚacc_neÚcnt_neÚmÚaÚcrn   s                    r,   Úchart_calibrationrR  p  sl  € à%Ð%Ð%Ð%Ð%Ð%à
×
Ò
Ñ
!Ô
!€CØˆvŒ;€DØ
ˆeŒ*€CØ
ˆeŒ*€CàEÐEÀÐEÑEÔE€IØ2Ð2¨TÐ2Ñ2Ô2€JØ'Ð' $Ð'Ñ'Ô'€FØHLÐW��a”˜Ô%¨¨Q¬°Ô(<Ñ<ÀÑDÐDÐRW€Ið    R�FˆF€FÝ�y *¨fÑ5Ô5ð ð ‰ˆˆ1ˆaØˆqŠ5ˆ5Ø�MŠM˜!ÑÔÐØ�MŠM˜!ÑÔÐØ�MŠM˜!ÑÔÐøà
�)Š)ÝØÝ˜\°!°Q°Å>ÐRÑRÔRÝ˜Z°°1¨vÅÐPÑPÔPØð	
ñ 
ô 
ð ñ ô €Cð ‡M‚M�v !¨¨a°A½DÅ~Ð]^ÐejÐ<kÑ<kÔ<k€MÑlÔlÐlð ‡M‚MØ
�ŠØØØÝ�g¨sÐ3Ñ3Ô3ØØØmð 	ñ 	
ô 	
ñ
ô 
ð 
ð ×ÒØ
Ø
ØØØ2�cÐ2Ð2Ð2¨Ð2Ð2Ð2ØØÝ�r¥*µMÐBÑBÔBÝÝ"ØØð ñ ô ð õ �C˜Ñ'Ô'Ð'r.   c                ó
  — ddl m} t          | t          ¦  «        r| n|                      |¬¦  «        }|                     di ¦  «        }|sdS t          d         t          d         t          d         t          d	         d
œ}i }|                     ¦   «         D ]U}|                     dd¦  «        }| 	                    |g ¦  «         
                    |                     dd¦  «        ¦  «         ŒV|                     t          dt          dddgt          ¬¦  «        t          dt          ¬¦  «        ddt          t          d¬¦  «        ¬¦  «        ¬¦  «        ¬¦  «        }	d
D ]•}|                     |g ¦  «        }
|
sŒ|	                     |                     |
d|                     dd¦  «                             ¦   «         t          |                     |t$          ¦  «        ¬¦  «        d¬ ¦  «        ¦  «         Œ–t'          |	d!¦  «        S )"zËHistogram of per-image F1 scores, colored by error profile.

    Accepts the output of ``coco_eval.image_diagnostics()`` or a COCOeval to
    call it on. ``iou_thr`` applies only in the latter case.
    r   NrÚ   Úimg_summaryz:<p class='empty-state'>No image diagnostics available.</p>ÚtpÚfpÚfnr   )ÚperfectÚfp_heavyÚfn_heavyÚmixedÚerror_profiler[  Úf1ry   zF1 ScoregÍÌÌÌÌÌð?r‰   zImage Count)r   r   Ústackih  rŒ   r�   rŽ   )r   r?   r@   Úbarmoder�   rI   r�   r8   ru   ú rA   z:F1: %{x:.2f}<br>Count: %{y}<extra>%{fullData.name}</extra>)r›   ÚnbinsxrU   r7  rŸ   zf1-dist)rK   rL   r'   r   Úimage_diagnosticsr|   r   r   ÚvaluesÚ
setdefaultr€   rª   rT   r#   r¬   Ú	HistogramÚreplacer   r$   ro   )Údiag_or_evalr´   rR   ÚdiagrT  Úprofile_colorsÚ
by_profileÚsÚprofilern   Úscoress              r,   Úchart_f1_distributionrn  µ  s"  € ð &Ð%Ð%Ð%Ð%Ð%å% lµDÑ9Ô9Ðnˆ<ˆ<¸|×?]Ò?]ÐfmÐ?]Ñ?nÔ?n€DØ—(’(˜=¨"Ñ-Ô-€KØð LØKÐKõ $ DÔ)Ý$ TÔ*Ý$ TÔ*Ý# AÔ&ð	ð €Nð *,€JØ×ÒÑ!Ô!ð Dð DˆØ—%’%˜¨Ñ1Ô1ˆØ×Ò˜g rÑ*Ô*×1Ò1°!·%²%¸¸cÑ2BÔ2BÑCÔCÐCÐCà
�)Š)ÝØÝ˜Z°°4¨yÅNÐSÑSÔSÝ˜]µnÐEÑEÔEØØÝ�T r˜]™]œ]Ð+Ñ+Ô+ð
ñ 
ô 
ð ñ 	ô 	€Cð @ð 
ð 
ˆØ—’ ¨Ñ,Ô,ˆØð 	ØØ�ŠØ�LŠLØØØ—_’_ S¨#Ñ.Ô.×4Ò4Ñ6Ô6Ý .×"4Ò"4°W½nÑ"MÔ"MÐNÑNÔNØZð ñ ô ñ	
ô 	
ð 	
ð 	
õ �C˜Ñ#Ô#Ð#r.   r8   c                óœ   — t          | t          ¦  «        r| n|                      |¬¦  «        }|                     dg ¦  «        }|d|…         S )zÄTop suspected label errors for HTML table rendering.

    Accepts the output of ``coco_eval.image_diagnostics()`` or a COCOeval to
    call it on. ``iou_thr`` applies only in the latter case.
    rÚ   Úlabel_errorsN)r'   r   rb  r|   )rg  r´   Útop_nrh  Úerrorss        r,   Úlabel_errors_tablers  ñ  sO   € õ & lµDÑ9Ô9Ðnˆ<ˆ<¸|×?]Ò?]ÐfmÐ?]Ñ?nÔ?n€DØ�XŠX�n bÑ)Ô)€FØ�&�5�&Œ>Ðr.   c                ó€  — |                       ¦   «         }t          j        | ¦  «        }|€|                      d¬¦  «        }|j        |j        |j        t          |¦  «        t          | ¦  «        t          | ¦  «        t          | ¦  «        t          |¦  «        t          | ¦  «        t          |¦  «        t          |¦  «        | j        j        t#          | j        j        ¦  «        t#          | j        j        ¦  «        |d         dœ}|r/	 |                      |¦  «        |d<   n# t*          $ r d|d<   Y n	w xY wd|d<   |S )u„  Compute all dashboard data at once. Returns dict for template rendering.

    Every derived quantity is computed here once and handed to the renderers
    that need it: TIDE feeds both its own card and the card subtitle, the
    per-image diagnostics feed both the F1 histogram and the label-error table,
    and `PlotData` feeds the provenance strip and the KPI tiles. Each of those
    is a full walk over the evaluation, so letting the renderers fetch their own
    ran them twice apiece.

    *diagnostics* is an already-computed ``image_diagnostics(iou_thr=0.5)``
    result â€” the browse server has one cached and passes it through.
    NrØ   rÚ   r  )Ú
provenanceÚprovenance_okÚ
deviationsÚkpiÚpr_curves_htmlÚper_cat_ap_htmlÚconfusion_htmlÚ	tide_htmlÚcalibration_htmlÚf1_dist_htmlrp  Úiou_typeÚnum_categoriesÚ
num_imagesÚtide_ap_baseÚ
slice_data)r  r   r   rb  ru  Úis_benchmark_standardrw  r…   rµ   r×   r  r(  rR  rn  rs  Úparamsr  rÔ   Úcat_idsÚimg_idsÚslice_byÚ	Exception)r¯   ÚslicesÚdiagnosticsr"  r~   Úresults         r,   Úbuild_dashboardr�  ÿ  sO  € ð × Ò Ñ"Ô"€Dõ
 Ô" 9Ñ-Ô-€DàÐØ×1Ò1¸#Ð1Ñ>Ô>ˆð ”oØÔ3Ø”oÝ˜‰ŒÝ)¨)Ñ4Ô4Ý0°Ñ;Ô;Ý0°Ñ;Ô;Ý& tÑ,Ô,Ý-¨iÑ8Ô8Ý-¨kÑ:Ô:Ý*¨;Ñ7Ô7ØÔ$Ô-Ý˜iÔ.Ô6Ñ7Ô7Ý˜)Ô*Ô2Ñ3Ô3Ø˜Yœðð €Fð$ ð $ð	(Ø#,×#5Ò#5°fÑ#=Ô#=ˆF�<Ñ Ð øÝð 	(ð 	(ð 	(Ø#'ˆF�<Ñ Ð Ð ð	(øøøð  $ˆˆ|Ñà€Ms   ÄD$ Ä$D6Ä5D6r“   )r   r   r   r   )rU   r(   )r   rp   )r   r(   )rØ   )rØ   r8   )NN)r   r   )*Ú__doc__Ú
__future__r   Únumpyr”   Ú	plot.corer   r   r   Ú	plot.datar   Úplot.reportr	   Ú
plot.themer
   r   r   r   rO   rM   r!   r"   r$   r#   rP   Ú_CAVEATrN   rG  r-   rT   r]   rc   ro   r…   rµ   r×   r  r(  rR  rn  rs  r�  rJ   r.   r,   ú<module>r–     s/  ðØ IÐ Ià "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð à LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LØ Ð Ð Ð Ð Ð Ø +Ð +Ð +Ð +Ð +Ð +Ø ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ Zð ˜)Ô$€Ø€Ø˜FÔ#€Ø˜gÔ&€Ø˜VÔ$€Ø˜VÔ$€Ø
˜QÔ
€ð ˜QÔ
€àM€
ØG€
ðð ð ð ð ð0ð ð ð@ €
ð)ð )ð )ð )ð" *.ð ð ð ð ð ðRð Rð Rð Rð6+&ð +&ð +&ð +&ðbð ð ð ð<OGð OGð OGð OGð OGðj1ð 1ð 1ð 1ðn?(ð ?(ð ?(ð ?(ðJ6$ð 6$ð 6$ð 6$ð 6$ðxð ð ð ð ð1ð 1ð 1ð 1ð 1ð 1ð 1r.   