+
    �÷kÆ  ã                   óž   € R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHtH	t	 ]! R4      t
]! R4      tR tR tR tR	 t]R
8X  d
   ]! 4        R# R# )ak  Audit polygon intersections across locally retrieved Khanom COCO variants.

The source variants repeat files and can have different annotations. A unique
pair is keyed by its filename and both exact polygon geometries, not COCO IDs.
No source images are needed. Pixel overlap is an annotation property, not a
guarantee of physical overlap or exhaustive labeling.
N)ÚPath)ÚImageÚ	ImageDrawz/tmp/diatom-mask-cocozresults/l24/overlap-audit.jsonc           
      ó–   € V  Uu. uF8  p\        V4      ^8¼  g   K  \        \        VR,          VR,          4      4      NK:  	  up# u upi )é   :NNé   :é   Nr   )ÚlenÚtupleÚzip)ÚsegmentationÚpolys   & Úresearch/l24_overlap_audit.pyÚpointsr      s<   € Ù:FÓY¹,°$Ì#ÈdË)ÐWXÉ.Ô-ŒE”#�d˜3•i  d¥Ó,Ö-¹,ÑYÐYùÒYs
   …Aœ'Ac                 óB  € \        V R ,          4      \        VR ,          4      r2V'       d	   V'       g   ^ # V UUu. uF  qD F  qUNK  	  K  	  uppV UUu. uF  qD F  qUNK  	  K  	  pppp\        \        R V 4       4      \        R V 4       4      4      p\        \        R V 4       4      \        R V 4       4      4      p	\        \        R V 4       4      \        R V 4       4      4      p
\        \        R V 4       4      \        R V 4       4      4      pW¨8  g   W¹8  d   ^ # \        W¨,
          ^,           4      \        W¹,
          ^,           4      rÜ. pW#3 Fƒ  p\        P
                  ! R	WÍ34      p\        P                  ! V4      pV F;  pTP                  V UUu. uF  w  ppVV,
          VV	,
          3NK  	  upp^R
7       K=  	  VP                  V4       K…  	  ^ RI
Hp VP                  ! V!  P                  4       ^ÿ,          # u uppi u uppi u uppi )r   c              3   ó*   "  € T F	  w  rVx € K  	  R # 5i©N© ©Ú.0ÚxÚ_s   &  r   Ú	<genexpr>Úintersection.<locals>.<genexpr>   s   é € Ð$¡™˜•1£ùó   ‚c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir   r   r   s   &  r   r   r      s   é € Ð);¹±°­!»ùr   c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir   r   ©r   r   Úys   &  r   r   r      s   é € Ð#¡™˜•!£ùr   c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir   r   r   s   &  r   r   r      s   é € Ð(:±r©t¨q­³rùr   c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir   r   r   s   &  r   r   r      s   é € Ð%¡"™$˜!•A£"ùr   c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir   r   r   s   &  r   r   r      s   é € Ð*<¹±°­1»ùr   c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir   r   r   s   &  r   r   r       s   é € Ð&¡2™4˜1•Q£2ùr   c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir   r   r   s   &  r   r   r       s   é € Ð+=¹"±$°!­A»"ùr   Ú1)Úfill)Ú
ImageChops)r   ÚmaxÚminÚintr   Únewr   ÚDrawÚpolygonÚappendÚPILr&   Úlogical_andÚ	histogram)ÚaÚbÚpaÚpbr   ÚpÚaaÚbbÚleftÚtopÚrightÚbottomÚwidthÚheightÚmasksÚpolygonsÚmaskÚdrawr,   r   r   r&   s   &&                    r   ÚintersectionrB      s¸  € Ü�A�nÕ%Ó&¬¨q°Õ/@Ó(Aˆß—RÙÙÔ-™B�Dª 1Ša©‰a™BÒ-¹bÔ/O¹b°dÊ$ÀQ²É$±¹bˆÑ/O€BÜŒsÑ$¡Ó$Ó$¤cÑ);¹Ó);Ó&;Ó<€DÜ
ŒcÑ#¡Ó#Ó#¤SÑ(:±rÓ(:Ó%:Ó
;€CÜ”Ñ%¡"Ó%Ó%¤sÑ*<¹Ó*<Ó'<Ó=€EÜ”Ñ&¡2Ó&Ó&¬Ñ+=¹"Ó+=Ó(=Ó>€FØ„|�v”|Ùô ˜� qÕ(Ó)¬3¨v­|¸aÕ/?Ó+@ˆ6Ø€EØ“HˆÜ�yŠy˜˜u˜oÓ.ˆÜ�~Š~˜dÓ#ˆÛˆGØ�L‰L±gÔ>±g©d¨a°˜1˜T�6 1 S¥5›/±gÒ>ÀQˆLÖGñ  à�‰�TÖñ õ Ø×!Ò! 5Ñ)×3Ñ3Ó5°cÕ:Ð:ùó% .ùÓ/Oùó ?s   »HÁHÆ#Hc                 ó@   € \         P                  ! V R ,          RR7      # )r   )Ú
separators)Ú,Ú:)ÚjsonÚdumps)Ú
annotations   &r   ÚgeometryrJ   1   s   € Ü�:Š:�j Õ0¸ZÔHÐHó    c                  ó|  € \        \        P                  R 4      4      p V '       g   \        R4      h\	        4       / / . 3w  rr4V  EFH  p\
        P                  ! VP                  4       4      pVR,           Uu/ uF  qwR,          VbK  	  pp\        P                  ! \        4      p	VR,           FT  p
\        V
P                  R4      \        4      '       g   \        RV 24      hWšR,          ,          P                  V
4       KV  	  ^ ;r¼V	P                  4        EF)  w  rÞW�,          pVR,          VR	,          VR
,          3pVP!                  V4       \"        P$                  ! V^4       FÕ  w  ppV.\        \'        V4      \'        V4      34      O5pV^,          p\)        VV4      pVV^ 8„  ,          pVP+                  VRV^ ,          R	V^,          R
V^,          RVRVR,          VR,          .RVR,          VR,          .R. /4      R,          P                  VP,                  4       V'       g   KÉ  VV,          VV&   K×  	  EK,  	  VP                  RVP,                  R\/        VR,          4      R\/        VR,          4      RVRV/4       EKK  	  R\/        V 4      R\/        V4      R\/        V4      R\/        V4      R\        VP1                  4       R R7      RVRR/p\2        P4                  P7                  RRR7       \2        P9                  \
        P:                  ! V^R7      R ,           4       \=        \
        P:                  ! VP                  4        UUu/ uF  w  ppVR$9  g   K  VVbK  	  upp^R7      4       \=        R!\
        P:                  ! VR,          R",          ^R7      4       R## u upi u uppi )%z*.jsonzNo source JSON files foundÚimagesÚidÚannotationsr   zUnsupported segmentation in Úimage_idÚ	file_namer<   r=   ÚfilenameÚintersection_pixelsÚannotation_ids_first_variantÚ'reported_annotation_areas_first_variantÚareaÚvariantsÚfileÚpairsÚpairs_with_shared_pixelsÚsource_json_countÚunique_annotated_image_keysÚunique_geometry_pairsÚunique_pairs_with_shared_pixelsÚoverlap_pairsc                 ó   € V R ,          ) # )rS   r   )Úitems   &r   Ú<lambda>Úmain.<locals>.<lambda>X   s   € ÀtÐLaÕGbÑFbrK   )ÚkeyÚdeduplicationzYfilename, dimensions and exact polygon geometries; annotation differences remain distinctT)ÚparentsÚexist_ok)ÚindentÚ
zTop shared-pixel pairs::Né
   NN)rW   r_   )ÚsortedÚSOURCEÚglobÚ
SystemExitÚsetrG   ÚloadsÚ	read_textÚcollectionsÚdefaultdictÚlistÚ
isinstanceÚgetÚ
ValueErrorr-   ÚitemsÚaddÚ	itertoolsÚcombinationsrJ   rB   Ú
setdefaultÚnamer	   ÚvaluesÚOUTPUTÚparentÚmkdirÚ
write_textrH   Úprint)ÚpathsÚunique_imagesrY   ÚhitsrW   ÚpathÚdataÚimrM   ÚgroupedrI   Úvariant_pairsÚvariant_hitsrP   rO   Úimagerd   r1   r2   ÚpairkeyÚpixelsÚresultÚkÚvs                           r   Úmainr“   5   sL  € Ü”6—;‘;˜xÓ(Ó)€EßÜÐ5Ó6Ð6Ü+.«5°"°b¸"Ð+<Ñ(€M˜$ÜˆÜ�zŠz˜$Ÿ.™.Ó*Ó+ˆØ)-¨h®Ó8© 2�T•(˜B’,©ˆÐ8Ü×)Ò)¬$Ó/ˆØ˜}×-Ð-ˆJÜ˜jŸn™n¨^Ó<¼d×CÒCÜ Ð#?À¸vÐ!FÓGÐGØ˜zÕ*Õ+×2Ñ2°:Ö>ñ .ð ()Ð(ˆØ%,§]¡]§_Ñ!ˆHØÕ$ˆEØ˜Õ% u¨W¥~°u¸XµÐGˆCØ×Ñ˜cÔ"Ü!×.Ò.¨{¸AÖ>‘��1ØÐD¤¬°!«´h¸q³kÐ(BÓ!CÑD�Ø Õ"�Ü% a¨Ó+�Ø ¨¡
Õ*�Ø× Ñ  ¨:°s¸1µv¸wÈÈAÍÐPXÐZ]Ð^_ÕZ`Ø+@À&Ø+IÈAÈdÍGÐUVÐW[ÕU\ÐK]Ø+TÐWXÐY_ÕW`ÐbcÐdjÕbkÐVlØ+5°rð	+;ó <ð =Gõ	H÷ IOÉÈtÏyÉyÔHYß‘6Ø$)¨'¥N�D˜“Mô ?ñ	 &5ð  	�‰˜ §¡¨H´c¸$¸x½.Ó6IØ&¬¨D°Õ,?Ó(@À'È=Ø3°\ðC÷ 	Dñ3 ð8 "¤3 u£:Ð/LÌcÐR_ÓN`Ø%¤s¨5£zÐ3TÔVYÐZ^ÓV_Øœv d§k¡k£mÑ9bÔcØ˜(ØÐzð	|€Fô
 ‡M�M×Ñ ¨tÐÔ4Ü
×Ñ”d—j’j °Ô2°TÕ9Ô:Ü	Œ$�*Š* v§|¡|¤~Ô`¡~™t˜q !¸ÐB_Ñ9_”d�a˜’d¡~Ò`ÐijÔ
kÔlÜ	Ð
#¤T§Z¢Z°°Õ0GÈÕ0LÐUVÔ%WÖXùòE 9ùóB as   Á8N3ÍN8Í,N8Ú__main__)Ú__doc__rr   rm   rz   rG   Úpathlibr   r.   r   r   rl   r   r   rB   rJ   r“   Ú__name__r   rK   r   Ú<module>r˜      s`   ðñó Û Û Û Ý ç  á	Ð%Ó	&€Ù	Ð.Ó	/€òZò;ò2Iò)YðX ˆzÔÙ†Fñ rK   