[e698c9]: / __pycache__ / metrics.cpython-311.pyc

Download this file

25 lines (22 with data), 2.8 kB

§

#™"eÉãó:—ddlZddlmZd„Zd	d„Zd„Zd„Zd„Z	dS)
éN)Úbackendcó¶—| ¦«| ¦«z}|dkrtjS||z ¦«}d|z|zS)a“Computes soerensen-dice coefficient.

    compute the soerensen-dice coefficient between the ground truth mask `mask_gt`
    and the predicted mask `mask_pred`.

    Args:
    mask_gt: 3-dim Numpy array of type bool. The ground truth mask.
    mask_pred: 3-dim Numpy array of type bool. The predicted mask.

    Returns:
    the dice coeffcient as float. If both masks are empty, the result is NaN.
    ré)ÚsumÚnpÚNaN)Úmask_gtÚ	mask_predÚ
volume_sumÚvolume_intersects    úhc:\Users\mrami\OneDrive\Desktop\Bleeding Detection\Image-Segmentation\Submission_segmentation\metrics.pyÚ
dice_scorersV€ð—’‘” §¢¡¤Ñ0€JؐQ‚€ÝŒvˆ
Ø )Ñ+×0Ò0Ñ2Ô2ÐØÐ
Ñ 
Ñ*Ð*óécó—tjtj||z¦«d¬¦«}d|z|ztjtj|¦«d¦«tjtj|¦«d¦«z|zzS)z…
    Dice = (2*|X & Y|)/ (|X|+ |Y|)
         =  2*sum(|A*B|)/(sum(A^2)+sum(B^2))
    ref: https://arxiv.org/pdf/1606.04797v1.pdf
    éÿÿÿÿ)Úaxisg@)ÚKrÚabsÚsquare)Úy_trueÚy_predÚsmoothÚintersections    r
Ú	dice_coefrst€õ”5œ˜v¨™Ñ/Ô/°bÐ9Ñ9Ô9€LØÑ Ñ&­1¬5µ´¸&Ñ1AÔ1AÀ"Ñ+EÔ+EÍÌÍaÌhÐW]ÑN^ÔN^Ð_aÑHbÔHbÑ+bÐekÑ+kÑlÐlrcó(—dt||¦«z
S©Nr)r©rrs  r
Údice_coef_lossr!s€ØYv˜vÑ
&Ô
&Ñ&Ð&rcóê—tj|¦«}tj|¦«}tj||z¦«}|dztj|¦«tj|¦«z|z
dzzS)Ngð?)rÚflattenr)rrÚy_true_fÚy_pred_frs     r
Újacard_coefr$$sd€ÝŒy˜Ñ Ô €HÝŒy˜Ñ Ô €HÝ”5˜ HÑ,Ñ-Ô-€LØ˜3Ñ¥1¤5¨¡?¤?µQ´U¸8±_´_Ñ#DÀ|Ñ#SÐVYÑ#YÑZÐZrcó(—dt||¦«z
Sr)r$rs  r
Újacard_coef_lossr&+s€Ø[˜ Ñ
(Ô
(Ñ(Ð(r)r)
ÚnumpyrÚkerasrrrrrr$r&©rr
ú<module>r*s„ðØÐÐÐØÐÐÐÐÐð+ð+ð+ð&mðmðmðmð'ð'ð'ð[ð[ð[ð)ð)ð)ð)ð)r