+
    „°ñjf}  ã                  óJ  € R t ^ RIHt ^ RIt^ RIHt ^ RIt^ RIHt	 ^ RI
t^ RIt^ RIHt ^ RIHt ^ RIHtHtHt ^ RIHt ]P2                  ! R4      t]P2                  ! R	4      t]P2                  ! R
4      tR R ltR R ltR R ltR R lt R R lt!R R lt"R R lt# ! R R]PH                  4      t%R)R R llt& ! R R]PH                  4      t' ! R R ]PH                  4      t( ! R! R"]PH                  4      t) ! R# R$]PH                  4      t* ! R% R&]4      t+R' R( lt,R# )*ap  ComfyUI nodes for Depth Anything 3.
Model capability matrix:

Variant               head_type  has_sky  has_conf  cam_dec
DA3-Small             dualdpt    False    True      yes
DA3-Base              dualdpt    False    True      yes
DA3-Mono-Large        dpt        True     False     no
DA3-Metric-Large      dpt        True     False     no  (raw output is metres)
)ÚannotationsN)Úoverride)Úturbo)Ú
preprocess)ÚComfyExtensionÚTypesÚio)Útriangulate_grid_meshÚ	DA3_MODELÚDA3_GEOMETRYÚDA3_POINT_CLOUDc               ó$   € V ^8„  d   QhRRRRRR/# )é   Údepthútorch.TensorÚKÚreturn© )Úformats   "ÚGC:\Ai_Coding\apps\studio\ComfyUI\comfy_extras\nodes_depth_anything_3.pyÚ__annotate__r   1   s!   € ÷ &ñ &˜,ð &¨<ð &¸Lñ &ó    c                ó<  € V P                   w  r#\        P                  ! V\        P                  V P                  R7      p\        P                  ! V\        P                  V P                  R7      p\        P
                  ! WERR7      w  rE\        P                  ! WE\        P                  ! V4      .RR7      p\        P                  ! R\        P                  P                  VP                  V P                  4      4      V4      pWpP                  R4      ,          # )uS   Pixel-space Kâ�»Â¹ unprojection: (H,W) depth â†’ (H,W,3) point map in OpenCV space.)ÚdtypeÚdeviceÚxy)Úindexing©Údimzij,hwj->hwiéÿÿÿÿ)ÚshapeÚtorchÚarangeÚfloat32r   ÚmeshgridÚstackÚ	ones_likeÚeinsumÚlinalgÚinvÚtoÚ	unsqueeze)r   r   ÚHÚWÚuÚvÚpixÚrayss   &&      r   Ú_da3_unprojectr2   1   s±   € à�;‰;�D€AÜ�Š�QœeŸm™m°E·L±LÔA€AÜ�Š�QœeŸm™m°E·L±LÔA€AÜ�>Š>˜!¨Ô.�D€AÜ
�+Š+�qœUŸ_š_¨QÓ/Ð0°bÔ
9€CÜ�<Š<˜¤u§|¡|×'7Ñ'7¸¿¹¸U¿\¹\Ó8JÓ'KÈSÓQ€DØ—/‘/ "Ó%Õ%Ð%r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r,   Úintr-   r   r   r   )r   s   "r   r   r   <   s&   € ÷ @ñ @�cð @˜cð @ lñ @r   c                óÀ   € \        V4      R,          ;r#\        P                  ! VRV^,
          R,          .RW0^,
          R,          .. RO.\        P                  R7      # )uK   Fallback ~60Â° FOV pinhole K for mono-mode DA3 (no intrinsics in geometry).gffffffæ?ç        g       @©r   )r6   r6   ç      ð?)Úfloatr!   Útensorr#   )r,   r-   ÚfxÚfys   &&  r   Ú_da3_default_Kr=   <   sU   € ä�A‹h˜�nÐ€BÜ�<Š<˜"˜c A¨¥E¨S¥=Ð1Ø˜r¨¥E¨S¥=Ð1Ú(ð*ä16·±ô@ð @r   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   ÚgeometryÚdictÚbr4   r,   r-   r   r   r   )r   s   "r   r   r   D   s/   € ÷ 	 ñ 	 ˜ð 	  #ð 	 ¨#ð 	 °#ð 	 ¸,ñ 	 r   c                ó°   € RV 9   d!   V R,          ^ V3,          P                  4       # \        P                  ! R4      P                  R4       \	        W#4      # )zMReturn pixel-space K for batch element b, falling back to a default estimate.Ú
intrinsicsÚcomfyus   DA3_GEOMETRY has no intrinsics (mono-mode model). Using a ~60Â° FOV estimate; 3-D reconstruction may be inaccurate.)r9   ÚloggingÚ	getLoggerÚwarningr=   )r?   rA   r,   r-   s   &&&&r   Ú
_da3_get_KrH   D   sS   € à�xÔà˜Õ% a¨ dÕ+×1Ñ1Ó3Ð3Ü×Ò�gÓ×&Ñ&ð	Lôô ˜!ÓÐr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r?   r@   rA   r4   r   útorch.Tensor | Noner   )r   s   "r   r   r   P   s"   € ÷ 0ñ 0 ð 0¨#ð 0Ð2Eñ 0r   c                óT   € RV 9  d   R# V R,          ^ V3,          P                  4       # )zêReturn the world-to-camera extrinsic for batch element b, or None in mono mode.

The model outputs (1, S, 3, 4) [R|t] matrices; the fallback identity is (4, 4).
_da3_apply_extrinsic handles both shapes via [:3, :3] / [:3, 3] slicing.
Ú
extrinsicsN)r9   )r?   rA   s   &&r   Ú_da3_get_extrinsicrM   P   s,   € ð ˜8Ô#ÙØ�LÕ! ! Q $Õ'×-Ñ-Ó/Ð/r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Ú
points_camr   ÚEr   r   )r   s   "r   r   r   [   s!   € ÷ &ñ & \ð &°lð &À|ñ &r   c                óÜ  € VP                  V P                  4      P                  4       p\        P                  ! V4      P                  4       '       g(   \        P                  ! R4      P                  R4       V # V P                  w  r#pVR,          pVR,          pVP                  pWv,          ) pV P                  R^4      p	W—P                  ,          V,           p
V
P                  W#^4      # )z<Transform (H,W,3) OpenCV camera-space points to world space.rD   z|DA3 extrinsic matrix contains non-finite values (pose estimation may have failed). Falling back to camera-space coordinates.)ºNé   NrR   )rR   rS   r   )r*   r   r9   r!   ÚisfiniteÚallrE   rF   rG   r    ÚTÚreshape)rO   rP   r,   r-   Ú_ÚRÚtÚR_invÚt_invÚptsÚ	pts_worlds   &&         r   Ú_da3_apply_extrinsicr_   [   sÅ   € à	�‰ˆZ×ÑÓ×%Ñ%Ó'€AÜ�>Š>˜!Ó× Ñ ×"Ò"Ü×Ò˜'Ó"×*Ñ*ð8ô	
ð ÐØ×Ñ�G€Aˆ!Ø	ˆ&�	€AØ	ˆ%�€AØ�C‰C€EØ�iˆL€EØ
×
Ñ
˜R Ó
#€CØ—g‘g• Õ%€IØ×Ñ˜Q 1Ó%Ð%r   c               ó    € V ^8„  d   QhRRRR/# )r   Úconfr   r   r   )r   s   "r   r   r   n   s   € ÷ #ñ # ð #°ñ #r   c                óN  € V P                   ^ ,          p. p\        V4       Fj  pW,          pVP                  4       VP                  4       reTP	                  We8”  d   WE,
          We,
          ,          M\
        P                  ! V4      4       Kl  	  \
        P                  ! V^ R7      # )z'Map raw confidence to [0, 1] per image.r   )r    ÚrangeÚminÚmaxÚappendr!   r&   r%   )ra   ÚBÚoutÚiÚcÚc_minÚc_maxs   &      r   Ú_normalize_confidencerm   n   st   € à�
‰
�1�€AØ
€CÜ�1ŽXˆØ�GˆØ—u‘u“w §¡£ˆuØ�
‰
°E´M�A•I %¥-Ö0ÄuÇÂÐWXÓGYÖZñ ô �;Š;�s Ô"Ð"r   c               ó4   € V ^8„  d   QhRRRRRRRRRRR	R
RR/# )r   r?   r@   rA   r4   r,   r-   Úconfidence_thresholdr9   Úuse_sky_maskÚboolr   r   r   )r   s   "r   r   r   y   s@   € ÷ ñ ˜dð  sð ¨sð °sð ÐRWð Ðgkð Ðp|ñ r   c                ó  € \         P                  ! W#\         P                  R7      pV'       d!   RV 9   d   W`R,          V,          R8  ,          pRV 9   d5   VR8”  d.   \        V R,          W^,            4      ^ ,          pWgV8¬  ,          pV# )z?Build (H,W) bool keep-mask from sky probability and confidence.r7   Úskyg      à?Ú
confidencer6   )r!   Úonesrq   rm   )r?   rA   r,   r-   ro   rp   ÚmaskÚ	conf_norms   &&&&&&  r   Ú_da3_build_maskrx   y   sv   € ä�:Š:�a¤%§*¡*Ô-€Dß˜ Ô)Ø • qÕ)¨CÑ/Õ0ˆØ�xÔÐ$8¸3Ô$>Ü)¨(°<Õ*@ÀÀqÅ5Ð*IÓJÈ1ÕMˆ	ØÐ$8Ñ8Õ9ˆØ€Kr   c                  ó<   € ] tR t^„t]R 4       t]R R l4       tRtR# )ÚLoadDA3Modelc                	ó  € \         P                  ! R RR\         P                  P                  R\        P
                  ! R4      R7      \         P                  P                  R. R
ORR7      .\        P                  4       .R	7      # )rz   zLoad Depth Anything 3zmodel/loadersÚ
model_nameÚgeometry_estimation)ÚoptionsÚweight_dtypeÚdefault)r~   r€   )Únode_idÚdisplay_nameÚcategoryÚinputsÚoutputs)r€   Úfp16Úbf16Úfp32)r   ÚSchemaÚComboÚInputÚfolder_pathsÚget_filename_listÚDA3ModelTypeÚOutput©Úclss   &r   Údefine_schemaÚLoadDA3Model.define_schema…   sy   € ä�yŠyØ"Ø0Ø$ä—‘—‘Ø Ü(×:Ò:Ð;PÓQð ó ô —‘—‘Ø"Ú?Ø%ð ó ð
ô "×(Ñ(Ó*Ð+ô
ð 	
r   c               ó   € V ^8„  d   QhRR/# ©r   r   zio.NodeOutputr   )r   s   "r   r   ÚLoadDA3Model.__annotate__š   s   € ÷ $ñ $°-ñ $r   c                	ó@  € / pVR 8X  d   \         P                  VR&   M5VR8X  d   \         P                  VR&   MVR8X  d   \         P                  VR&   \        P
                  ! RV4      p\        P                  P                  WCR7      p\        P                  ! V4      # )r†   r   r‡   rˆ   r}   )Úmodel_options)r!   Úfloat16Úbfloat16r#   rŒ   Úget_full_path_or_raiserD   ÚsdÚload_diffusion_modelr   Ú
NodeOutput)r‘   r|   r   r˜   ÚpathÚmodels   &&&   r   ÚexecuteÚLoadDA3Model.execute™   s‚   € àˆØ˜6Ô!Ü%*§]¡]ˆM˜'Ò"Ø˜VÔ#Ü%*§^¡^ˆM˜'Ò"Ø˜VÔ#Ü%*§]¡]ˆM˜'Ñ"ä×2Ò2Ð3HÈ*ÓUˆÜ—‘×-Ñ-¨dÐ-ÓPˆÜ�}Š}˜UÓ#Ð#r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Úclassmethodr’   r¡   Ú__static_attributes__r   r   r   rz   rz   „   s(   † Øñ
ó ð
ð& ô$ó ô$r   rz   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úimager   Úprocess_resr4   ÚmethodÚstrr   )r   s   "r   r   r   ¨   s!   € ÷ )"ñ )" <ð )"¸cð )"È3ñ )"r   c                ó¨  € VP                   ^8X  d   VP                  R,          ^8X  g   Q R\        VP                  4       24       hVP                  w  rErg\        P                  ! V 4       V P
                  P                  p\        P                  ! 4       p	VP                  e   VP                  M\        P                  p
. . . rÜp\        V4       EF	  pWV^,            P                  V	4      p\        P                  ! WòVR7      pVP                  V
R7      p\        P                  ! 4       ;_uu_ 4        V! V4      pRRR4       XR,          p\        P                   P"                  P%                  VP'                  ^4      P)                  4       WV3RRR7      P+                  ^4      P-                  4       pVP/                  V4       R	V9   d�   \        P                   P"                  P%                  VR	,          P'                  ^4      P)                  4       WV3RRR7      P+                  ^4      P-                  4       pVP/                  V4       R
V9   g   EK‰  \        P                   P"                  P%                  VR
,          P'                  ^4      P)                  4       WV3RRR7      P+                  ^4      P-                  4       pVP/                  V4       EK  	  \        P0                  ! V^ R7      pV'       d   \        P0                  ! V^ R7      MRpV'       d   \        P0                  ! V^ R7      MRpVVV3#   + '       g   i     EL
; i)zNRun DA3 on (B,H,W,3), returns depth/conf/sky at original resolution (or None).úexpected (B,H,W,3) IMAGE; got N©r«   r¬   r7   r   ÚbilinearF©ÚsizeÚmodeÚalign_cornersÚ
depth_confrs   r   r   )Úndimr    ÚtupleÚmmÚload_model_gpur    Údiffusion_modelÚget_torch_devicer   r!   r#   rc   r*   Úda3_preprocessÚpreprocess_imageÚno_gradÚnnÚ
functionalÚinterpolater+   r9   ÚsqueezeÚcpurf   Úcat)Úmodel_patcherrª   r«   r¬   rg   r,   r-   rX   Ú	diffusionr   r   ÚdepthsÚconfsÚskiesri   ÚsingleÚxrh   Údepth_lrÚ
depth_fullÚ	conf_fullÚsky_fullr   rt   rs   s   &&&&                     r   Ú_run_da3rÑ   ¨   s“  € à�:‰:˜Œ?˜uŸ{™{¨2�°!Ô3ÐjÐ7UÔV[Ð\a×\gÑ\gÓVhÐUiÐ5jÓjÐ3à—‘�J€Aˆ!Ü×Ò�mÔ$Ø×#Ñ#×3Ñ3€IÜ× Ò Ó"€FØ(Ÿ™Ò:ˆI�OŠOÄÇÁ€Eà˜r 2�5€FÜ�1�XˆØ˜˜Q��×"Ñ" 6Ó*ˆÜ×+Ò+¨FÐTZÔ[ˆØ�D‰D�uˆDÓˆÜ�]Š]�_�_Ù˜A“,ˆC÷ ð �w•<ˆÜ—X‘X×(Ñ(×4Ñ4Ø×Ñ˜qÓ!×'Ñ'Ó)°°Ø¨5ð 5ó 
÷ ‰'�!‹*—S‘S“Uð 	ð 	�‰�jÔ!à˜3ÔÜŸ™×+Ñ+×7Ñ7Ø�LÕ!×+Ñ+¨AÓ.×4Ñ4Ó6¸a¸VØ¨uð 8ó ÷ ‰g�a‹jŸ™›ð ð �L‰L˜Ô#Ø�C�<Ü—x‘x×*Ñ*×6Ñ6Ø�E•
×$Ñ$ QÓ'×-Ñ-Ó/°q°fØ¨uð 7ó ÷ ‰g�a‹jŸ™›ð ð �L‰L˜×"ñ3 ô6 �IŠI�f !Ô$€Eß,1”—’˜5 aÕ(°t€Jß%*Œ%�)Š)�E˜qÕ
!°€CØ�*˜cÐ!Ð!÷5 �_ˆ_ús   Ä6	M Í Mc                  óh   € ] tR t^Ôt]R 4       t]R R l4       t]R R l4       t]R R l4       tRt	R	# )
ÚDA3Inferencec                	ó®  € \         P                  ! R . R ORRR\        P                  R4      \         P                  P                  R4      \         P
                  P                  RR^ŒR^R	R
7      \         P                  P                  RRR.RRR7      \         P                  P                  RR\         P                  P                  R. 4      \         P                  P                  R\         P                  P                  R. R!ORRR7      \         P                  P                  RRR.RRR7      .4      .R7      .\        P                  RRR7      .R7      # )"rÓ   zRun Depth Anything 3úimage/geometry estimationzpRun Depth Anything 3 on an image. In multi-view mode each image is treated as a separate view of the same scene.Ú	da3_modelrª   Ú
resolutioniø  iØ	  z�Resolution the model runs at (longest side, multiple of 14).
Lower = faster / less VRAM.
Higher = more detail.
Output is upsampled back to the original size.©r€   rd   re   ÚstepÚtooltipÚresize_methodÚupper_bound_resizeÚlower_bound_resizezÍupper_bound_resize: scale so the longest side = resolution (caps memory, default).
lower_bound_resize: scale so the shortest side = resolution (preserves more detail on tall/wide images, uses more memory).©r~   r€   rÚ   r´   z¦mono: single view image (works with any model variant).
multiview: all images processed together for geometric consistency + camera pose (for Small/Base models only).ÚmonoÚ	multiviewÚref_view_strategyÚsaddle_balancedzëWhich view acts as the geometric anchor.
- saddle_balanced: the view most 'average' across all others (best general choice).
- saddle_sim_range: the view most visually distinct from the others.
- first / middle: fixed positional picks.Úpose_methodÚcam_decÚray_posea  How the camera field-of-view is estimated (for Small/Base models only).
- cam_dec: learned from image features.
- ray_pose: derived geometrically from the model's 3D ray output.
Affects perspective correctness of the 3D output. Try both if results look distorted.©rÚ   r~   Úda3_geometryz»Dictionary of non-normalized tensors.
Always has the keys: depth, image, mode.
Optional keys: sky (for Mono/Metric), confidence (for Small/Base), extrinsics + intrinsics (for multi-view).)rÚ   ©r�   Úsearch_aliasesr‚   rƒ   Údescriptionr„   r…   )
r   r?   Úda3údepth anythingÚ	monocularÚpointmaprs   Ú3dzmetric depthÚ	disparity)râ   Úsaddle_sim_rangeÚfirstÚmiddle)r   r‰   rŽ   r‹   ÚImageÚIntrŠ   ÚDynamicComboÚOptionÚDA3Geometryr�   r�   s   &r   r’   ÚDA3Inference.define_schemaÕ   sl  € ä�yŠyØ"ò MØ/Ø0ð Kä×"Ñ" ;Ó/Ü—‘—‘˜wÓ'Ü—‘—‘˜\°3¸CÀTÐPRðIð ó Jô
 —‘—‘˜Ð9MÐOcÐ8dð  oCðUð ó Vô —‘×%Ñ% fð 7Eô Ÿ™×.Ñ.¨v°rÓ:ÜŸ™×.Ñ.¨{ÜŸ™Ÿ™Ð':ÒD~ð  IZð%Lð 'ó Mô
 Ÿ™Ÿ™ }¸yÈ*Ð>UÐ_hð%xð 'ó yð=ó ðð &ó ðô< ×"Ñ" >ð <CÐ"ó DðôG(
ð (	
r   c               ó   € V ^8„  d   QhRR/# r•   r   )r   s   "r   r   ÚDA3Inference.__annotate__  s   € ÷ &
ñ &
È=ñ &
r   c                	óè  € VR ,          pVR8X  d   V P                  WW44      # VP                  P                  pVR,          pVR,          p	VP                  RJp
VP                  R8H  pV
'       g"   V'       g   \        RVP                   R24      hVR8X  d"   V
'       g   \        R	VP                   R
24      hVR8X  d"   V'       g   \        RVP                   R24      hV P                  WW4W˜4      # )r´   rß   rã   rá   NÚdualdptzKmulti-view mode requires Small or Base model. The loaded model (head_type='z…') does not support cross-view attention or camera pose estimation. Switch mode to 'mono', or load Small or Base model for mult-view.rä   zRpose_method='cam_dec' requires a camera decoder, but the loaded model (head_type='z9') does not have one. Use pose_method='ray_pose' instead.rå   zLpose_method='ray_pose' requires a DualDPT head, but the loaded model has a 'z*' head. Use pose_method='cam_dec' instead.)Ú_execute_monor    r»   rä   Ú	head_typeÚ
ValueErrorÚ_execute_multiview)r‘   rÖ   rª   r×   rÛ   r´   Úmode_valrÇ   rã   rá   Úhas_cam_decÚhas_dualdpts   &&&&&&      r   r¡   ÚDA3Inference.execute  s  € à˜•<ˆà�vÔØ×$Ñ$ Y°zÓQÐQð —O‘O×3Ñ3ˆ	Ø˜=Õ)ˆØ Ð!4Õ5Ðà×'Ñ'¨tÐ3ˆØ×)Ñ)¨YÑ6ˆç§;ÜðØ(×2Ñ2Ð3ð 4:ð:óð ð ˜)Ô#¯KÜð%Ø%.×%8Ñ%8Ð$9ð :6ð6óð ð
 ˜*Ô$¯[Üð Ø )× 3Ñ 3Ð4ð 55ð5óð ð ×%Ñ%Ø˜jØó
ð 	
r   c               ó   € V ^8„  d   QhRR/# r•   r   )r   s   "r   r   rû   +  s   € ÷ 'ñ 'À}ñ 'r   c                	ó   € \        WW4R 7      w  rVpRVP                  4       RVR,          P                  4       RR/pVe   VP                  4       VR&   Ve   VP                  4       VR&   \        P                  ! V4      # ))r¬   r   rª   r´   rß   rs   rt   ©.rR   )rÑ   Ú
contiguousrÄ   r   rž   )	r‘   r    rª   r×   rÛ   r   rt   rs   r?   s	   &&&&&    r   rþ   ÚDA3Inference._execute_mono*  s€   € ä!)¨%¸
Ô!YÑˆ˜3ð �U×%Ñ%Ó'Ø�U˜7•^×'Ñ'Ó)Ø�Fð
ˆð
 Š?Ø!Ÿn™nÓ.ˆH�U‰OØÒ!Ø%/×%:Ñ%:Ó%<ˆH�\Ñ"Ü�}Š}˜XÓ&Ð&r   c               ó   € V ^8„  d   QhRR/# r•   r   )r   s   "r   r   rû   :  s   € ÷ 5'ñ 5'Ðlyñ 5'r   c                	ó  € VP                   ^8X  d   VP                  R,          ^8X  g   Q R\        VP                  4       24       hVP                  w  rxrš\        P                  ! V4       VP
                  P                  p\        P                  ! 4       pVP                  e   VP                  M\        P                  pVP                  V4      p\        P                  ! WãVR7      pVP                  VR7      P                  ^ 4      pVR8H  p\        P                  ! 4       ;_uu_ 4        V! WïVR7      pRRR4       \        P                   P"                  P%                  XR,          P'                  4       P                  ^4      W‰3RR	R
7      P)                  ^4      P+                  4       pRpRV9   dp   \        P                   P"                  P%                  VR,          P                  ^4      P'                  4       W‰3RR	R
7      P)                  ^4      P+                  4       pRV9   dS   RV9   dL   VR,          P'                  4       P+                  4       pVR,          P'                  4       P+                  4       pMz\        P,                  ! ^4      R,          P/                  ^V^^4      P1                  4       p\        P,                  ! ^4      R,          P/                  ^V^^4      P1                  4       pRVP3                  4       RVR,          P+                  4       RRRVP3                  4       RVP3                  4       /pVe   VP3                  4       VR&   RV9   dƒ   \        P                   P"                  P%                  VR,          P                  ^4      P'                  4       W‰3RR	R
7      P)                  ^4      P+                  4       pVP3                  4       VR&   \4        P6                  ! V4      #   + '       g   i     ELÌ; i)é   r¯   Nr°   r7   rå   )Úuse_ray_poserá   r   r±   Fr²   rs   rL   rC   rª   r´   rà   r¶   rt   r   )NNr  )r·   r    r¸   r¹   rº   r    r»   r¼   r   r!   r#   r*   r½   r¾   r+   r¿   rÀ   rÁ   rÂ   r9   rÃ   rÄ   ÚeyeÚexpandÚcloner	  r   rž   )r‘   r    rª   r×   rÛ   rá   rã   ÚSr,   r-   rX   rÇ   r   r   rÌ   r  rh   r   rs   rL   rC   r?   ra   s   &&&&&&&                r   r  ÚDA3Inference._execute_multiview9  s@  € à�z‰z˜QŒ 5§;¡;¨r¥?°aÔ#7ð 	BØ,¬U°5·;±;Ó-?Ð,@ÐAó	BÐ7à—[‘[‰
ˆˆaä
×Ò˜%Ô Ø—K‘K×/Ñ/ˆ	Ü×$Ò$Ó&ˆØ#,§?¡?Ò#>�	—’ÄEÇMÁMˆð �H‰H�VÓˆÜ×+Ò+¨AÈmÔ\ˆØ�D‰D�uˆDÓ×'Ñ'¨Ó*ˆà# zÑ1ˆÜ�]Š]�_�_Ù˜AÐL]Ô^ˆC÷ ô —‘×#Ñ#×/Ñ/Ø��L×ÑÓ ×*Ñ*¨1Ó-°Q°FØ¨5ð 0ó 
÷ ‰'�!‹*—S‘S“Uð 	ð
 ˆØ�CŒ<Ü—(‘(×%Ñ%×1Ñ1Ø�E•
×$Ñ$ QÓ'×-Ñ-Ó/°q°fØ¨uð 2ó ÷ ‰g�a‹jŸ™›ð ð
 ˜3Ô <°3Ô#6Ø˜\Õ*×0Ñ0Ó2×6Ñ6Ó8ˆJØ˜\Õ*×0Ñ0Ó2×6Ñ6Ó8‰JäŸš 1› jÕ1×8Ñ8¸¸A¸qÀ!ÓD×JÑJÓLˆJÜŸš 1› jÕ1×8Ñ8¸¸A¸qÀ!ÓD×JÑJÓLˆJð �U×%Ñ%Ó'Ø�U˜7•^×'Ñ'Ó)Ø�KØ˜*×/Ñ/Ó1Ø˜*×/Ñ/Ó1ð
ˆð Š?Ø!Ÿn™nÓ.ˆH�U‰OØ˜3ÔÜ—8‘8×&Ñ&×2Ñ2Ø�LÕ!×+Ñ+¨AÓ.×4Ñ4Ó6¸a¸VØ¨uð 3ó ÷ ‰g�a‹jŸ™›ð ð &*§_¡_Ó%6ˆH�\Ñ"Ü�}Š}˜XÓ&Ð&÷K �_ˆ_ús   Ä-O;Ï;P	r   N)
r£   r¤   r¥   r¦   r§   r’   r¡   rþ   r  r¨   r   r   r   rÓ   rÓ   Ô   sR   † Øñ)
ó ð)
ðV ô&
ó ð&
ðP ô'ó ð'ð ô5'ó ô5'r   rÓ   c                  óÔ   € ] tR tRtRt]P                  P                  R. RORRR7      ]P                  P                  RRR	R
7      .t	]
R 4       t]
R R l4       t]R R l4       tRtR# )Ú	DA3Renderir  z2Render a visualization from a DA3_GEOMETRY packet.ÚnormalizationÚv2_stylezÔ- v2_style: mean/std normalisation for perceptually balanced results (default).
- min_max: stretches the full depth range to [0, 1] for maximum contrast.
- raw: no scaling,preserves metric units for Metric model.rÞ   Úapply_sky_clipFz¢Clip sky-region depth to the 99th percentile of foreground depth before normalisation. Requires a sky key in the da3_geometry input (for Mono/Metric models only).©r€   rÚ   c                	ó‚  € \         P                  ! R RRR\        P                  R4      \         P                  P                  RR\         P                  P                  RV P                  4      \         P                  P                  RV P                  4      \         P                  P                  R	\         P                  P                  R
RRR7      .4      \         P                  P                  R\         P                  P                  R
RRR7      .4      .R7      .\         P                  P                  4       .R7      # )r  zRender Depth Anything 3rÕ   zTRender a depth map, confidence map, or sky mask from Depth Anything 3 geometry data.rç   Úoutputzñ- depth: normalised greyscale depth image.
- depth_colored: depth mapped through the Turbo colormap.
- sky_mask: sky probability in [0, 1] (for Mono/Metric models only).
- confidence: normalised depth confidence (for Small/Base models only).r   Údepth_coloredÚsky_maskÚcoloredFz)Apply the Turbo colormap to the sky mask.r  rt   z/Apply the Turbo colormap to the confidence map.ræ   )r�   r‚   rƒ   rê   r„   r…   )
r   r‰   rø   r‹   rö   r÷   Ú_DEPTH_RENDER_INPUTSÚBooleanrô   r�   r�   s   &r   r’   ÚDA3Render.define_schema�  s  € ä�yŠyØØ2Ø0Ønä×!Ñ! .Ó1Ü—‘×%Ñ% hðbô
 —O‘O×*Ñ*¨7°C×4LÑ4LÓMÜ—O‘O×*Ñ*¨?¸C×<TÑ<TÓUÜ—O‘O×*Ñ*¨:ÜŸ
™
×(Ñ(¨¸EÐKvÐ(Ówð8ó ô —O‘O×*Ñ*¨<ÜŸ
™
×(Ñ(¨¸EÐK|Ð(Ó}ð:ó ð	ð &ó ðô$ —X‘X—_‘_Ó&Ð'ô/
ð 	
r   c               ó   € V ^8„  d   QhRR/# r•   r   )r   s   "r   r   ÚDA3Render.__annotate__ž  s   € ÷ *-ñ *-¨mñ *-r   c           
     	óR  € VR ,          pVR9   då   VR,          pVR,          pV'       d   RV9  d   \        R4      hVR,          pVP                  R4      pV'       dh   Ved   \        P                  ! \	        VP
                  ^ ,          4       Uu. uF&  p\        P                  ! Wh,          Wx,          4      NK(  	  up^ R7      pV P                  WgV4      p	VR8X  d   \        V	R,          4      MT	p
EMVR8X  dt   RV9  d   \        R	4      hVR,          pVR
,          '       d   \        V4      p
MÎVP                  R4      P                  ! . VP
                  O^N5!  P                  4       p
M‘VR8X  d}   RV9  d   \        R4      h\        VR,          4      pVR
,          '       d   \        V4      p
MKVP                  R4      P                  ! . VP
                  O^N5!  P                  4       p
M\        RV 24      h\        P                  ! V
P!                  4       4      # u upi )r  r   r  r  r  rs   z’apply_sky_clip=True requires a sky tensor in the da3_geometry input, but none is present. Run with Mono/Metric models or set apply_sky_clip=False.r   r  z8geometry has no sky output; run with Mono/Metric models.r  rt   zBda3_geometry has no confidence output; run with Small/Base models.zUnknown output mode: )r   r  ).é    r   )r   Úgetr!   r%   rc   r    r½   Úapply_sky_aware_clipÚ_depth_to_imageÚ_turbor+   r  r	  rm   r   rž   r9   )r‘   rç   r  Ú
output_valr  r  r   rs   ri   ÚgreyÚresultra   s   &&&         r   r¡   ÚDA3Render.execute�  sæ  € à˜HÕ%ˆ
àÐ3Ô3Ø" ?Õ3ˆMØ#Ð$4Õ5ˆNß %¨|Ô";Ü ðOóð ð ! Õ)ˆEØ×"Ñ" 5Ó)ˆCß #¢/ÜŸšä" 5§;¡;¨q¥>Ô2ó%á2˜ô #×7Ò7¸½À#Å&ÖIÙ2ñ%ð ô�ð ×&Ñ& u°=ÓAˆDØ-7¸?Ô-J”V˜D �LÔ)ÐPTŠFà˜:Ô%Ø˜LÔ(Ü Ð![Ó\Ð\Ø˜uÕ%ˆCØ�i× Ô Ü ›‘àŸ™ rÓ*×1Ò1Ð@°3·9±9Ð@¸aÓ@×KÑKÓM‘à˜<Ô'Ø <Ô/Ü Ð!eÓfÐfÜ(¨°lÕ)CÓDˆDØ�i× Ô Ü ›‘àŸ™¨Ó+×2Ò2ÐB°D·J±JÐBÀÓB×MÑMÓO‘ô Ð4°Z°LÐAÓBÐBä�}Š}˜VŸ\™\›^Ó,Ð,ùò9%s   Â,H$c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r   r   Úsky_for_normrJ   r  r­   r   r   )r   s   "r   r   r#  Ë  s+   € ÷  ñ  ˜|ð  Ð;Nð  Ð_bð  Ðgsñ  r   c           
     óÊ  € V P                   ^ ,          pVR8X  dZ   \        P                  ! \        V4       Uu. uF,  p\        P
                  ! W,          Ve	   W,          MR4      NK.  	  up^ R7      pM VR8X  d   \        P                  ! V 4      pMT pVP                  R4      P                  ^^^^4      pVR8w  d   VP                  RR4      pVP                  4       # u upi )	z6Normalise depth and pack as an (B,H,W,3) image tensor.r  Nr   Úmin_maxÚrawr6   r8   r   )r    r!   r%   rc   r½   Únormalize_depth_v2_styleÚnormalize_depth_min_maxr+   ÚrepeatÚclampr	  )r   r/  r  ÚNri   Únormrh   s   &&&    r   r(  ÚDA3Render._depth_to_imageÊ  sÓ   € ð �K‰K˜�NˆØ˜JÔ&Ü—;’;ô ˜qœó ñ "�Aô ×7Ò7Ø•H°Ò1I˜lžoÈtöUá!ñ ð ô	‰Dð
 ˜iÔ'Ü!×9Ò9¸%Ó@‰DàˆDà�n‰n˜RÓ ×'Ñ'¨¨1¨a°Ó3ˆØ˜EÔ!Ø—)‘)˜C Ó%ˆCØ�~‰~ÓÐùò s   ¸2C r   N)r  r1  r2  )r£   r¤   r¥   r¦   Ú__doc__r   rŠ   r‹   r   r  r§   r’   r¡   Ústaticmethodr(  r¨   r   r   r   r  r  r  s•   † Ù<ð 	�‰�‰�Ú2ØðMð 	ó 	Nð 	�
‰
×ÑÐ)°5ð^ð 	ó 	_ð
Ðð ñ
ó ð
ð6 ô*-ó ð*-ðX ô ó ô r   r  c                  ó@   € ] tR tRtRt]R 4       t]R R l4       tRtR# )ÚDA3GeometryToMeshià  zXConvert a DA3_GEOMETRY packet into a Types.MESH by unprojecting depth and triangulating.c                	óB  € \         P                  ! R . RORRR\        P                  R4      \         P                  P                  R^ ^ RRR7      \         P                  P                  R	^^^R
R7      \         P
                  P                  RRRRRRR7      \         P
                  P                  RRRRRRR7      \         P                  P                  RRRR7      \         P                  P                  RRRR7      .\         P                  P                  4       .R7      # )r=  zConvert DA3 Geometry to MeshrÕ   z0Convert a depth map into a triangulated 3D mesh.rç   Úbatch_indexé   z_Which image of a batch to convert. Per-image vertex counts differ so batches cannot be stacked.©r€   rd   re   rÚ   Ú
decimationz2Vertex stride. 1 = full resolution, 2 = half, etc.Údiscontinuity_thresholdg{®Gáz¤?r6   r8   ç{®Gáz„?zCDrop triangles whose 3x3 depth span exceeds this fraction. 0 = off.rØ   ro   çš™™™™™¹?zÈExclude pixels whose per-image normalised confidence is below this value (0 = keep all, 1 = keep only the single most confident pixel). Used when the geometry has a confidence map (Small/Base models).rp   TzuExclude sky-probability pixels (sky >= 0.5) from the mesh. Used when the geometry has a sky map (Mono/Metric models).r  Útexturez-Use the source image as a base color texture.rè   )rë   rì   Úmeshr?   rï   Útriangulate)	r   r‰   rø   r‹   rõ   ÚFloatr   ÚMeshr�   r�   s   &r   r’   ÚDA3GeometryToMesh.define_schemaã  s  € ä�yŠyØ'Ú]Ø7Ø0ØJä×!Ñ! .Ó1Ü—‘—‘˜]°A¸1À$ð  Qr�ó  sÜ—‘—‘˜\°1¸!Àð  MA�ó  BÜ—‘—‘Ð8À$ÈCÐUXÐ_cð  ns�ó  tÜ—‘—‘Ð5¸sÈÐQTÐ[_ð[ð ó \ô —
‘
× Ñ  ¸ð  HÐ ó  @Ü—
‘
× Ñ  °DÐBqÐ Órð
ô —W‘W—^‘^Ó%Ð&ô#
ð 	
r   c               ó   € V ^8„  d   QhRR/# r•   r   )r   s   "r   r   ÚDA3GeometryToMesh.__annotate__ú  s   € ÷ A#ñ A#ð  FSñ A#r   c                	óà  € VR ,          pVP                   ^ ,          p	W)8¼  d   \        RV RV	 R24      hW‚,          p
V
P                   w  r¼V
P                  4       p
\        P                  ! V
4      ( P                  4       P                  4       pV'       dE   \        P                  ! R4      P                  RV RV R^dV,          W¼,          ,          R R	24       R
V
\        P                  ! V
4      ( &   \        P                  ! R4      P                  RV RV
P                  4       R RV
P                  4       R RV
P                  4       R 24       \        WW¼4      p\        W®4      p\!        W4      pVe   \#        VV4      p\%        WW¼WV4      pVW‚,          ^ 8„  ,          \        P                  ! W‚,          4      ,          pVP                  4       p\'        R4      VV( &   \)        VVVV
R7      w  pppVP                   ^ ,          ^ 8X  g   VP                   ^ ,          ^ 8X  d   \        R4      hV\        P*                  ! . ROVP,                  R7      ,          pVR. RO3,          P/                  4       pV'       d   VR,          W"^,            MRp\0        P2                  ! VP5                  ^ 4      VP5                  ^ 4      VP5                  ^ 4      VR7      p\6        P8                  ! V4      # )r   úbatch_index ú. is out of range; DA3_GEOMETRY has batch size Ú.rD   zDA3GeometryToMesh: depth[z] has z non-finite pixels (z.1fz%) - zeroed before unproject.r6   z	] range [z.4gz, z], mean=NÚinf)rB  rC  r   zˆDA3GeometryToMesh produced an empty mesh. Try raising discontinuity_threshold, lowering confidence_threshold, or disabling use_sky_mask.r7   ºNNNrª   )ÚverticesÚfacesÚuvsrF  )r8   ç      ð¿rW  )r%  r   é   )r    r   r  r!   rT   ÚsumÚitemrE   rF   rG   Údebugrd   re   ÚmeanrH   r2   rM   r_   rx   r9   r	   r:   r   r	  r   ÚMESHr+   r   rž   )r‘   rç   r?  rB  rC  ro   rp   rF  Ú	depth_allrg   r   r,   r-   Ún_badr   ÚpointsrP   rv   ÚvertsrU  rV  ÚtexrG  s   &&&&&&&&               r   r¡   ÚDA3GeometryToMesh.executeù  sž  € à  Õ)ˆ	Ø�O‰O˜AÕˆØÔÜ˜|¨K¨=Ð8fÐghÐfiÐijÐkÓlÐlàÕ&ˆØ�{‰{‰ˆð
 —‘“ˆÜ—.’. Ó'Ð'×,Ñ,Ó.×3Ñ3Ó5ˆßÜ×Ò˜gÓ&×.Ñ.Ø+¨K¨=¸¸u¸gð FØ˜•I˜q�s•O CÐ(Ð(EðGôð ),ˆŒu�~Š~˜eÓ$Ð$Ñ%Ü×Ò˜'Ó"×(Ñ(Ø'¨ }ð 5Ø—	‘	“˜CÐ   5§9¡9£;¨sÐ"3°8¸E¿J¹J»LÈÐ;MðOô	
ô
 �|°!Ó7ˆÜ Ó)ˆô ˜|Ó9ˆØŠ=Ü)¨&°!Ó4ˆFô ˜|¸!Ð@TÓcˆà�yÕ-°Ñ1Õ2´U·^²^ÀIÕDZÓ5[Õ[ˆØ—‘“ˆÜ˜e›ˆ�ˆu‰ä1ØØ!Ø$;Øô	
Ñˆˆu�cð �;‰;�q�>˜QÔ %§+¡+¨a¥.°AÔ"5Üð-óð ð œŸšÒ%6¸e¿k¹kÔJÕJˆØ�aš�lÕ#×.Ñ.Ó0ˆçDKˆl˜7Õ# K¸aµÑ@ÐQUˆÜ�zŠzØ—_‘_ QÓ'Ø—/‘/ !Ó$Ø—‘˜aÓ Øô	
ˆô �}Š}˜TÓ"Ð"r   r   N©	r£   r¤   r¥   r¦   r:  r§   r’   r¡   r¨   r   r   r   r=  r=  à  s-   † Ùbàñ
ó ð
ð* ôA#ó ôA#r   r=  c                  ó@   € ] tR tRtRt]R 4       t]R R l4       tRtR# )ÚDA3GeometryToPointCloudi>  zCUnproject a DA3_GEOMETRY depth map into a filtered DA3_POINT_CLOUD.c                	ó¨  € \         P                  ! R . RORRR\        P                  R4      \         P                  P                  R^ ^ RRR7      \         P
                  P                  R	R
RRRRR7      \         P                  P                  RRRR7      \         P                  P                  R^^^RR7      .\        P                  RR7      .R7      # )rf  z#Convert DA3 Geometry to Point CloudrÕ   z*Convert a depth map into a 3D point cloud.rç   r?  r@  z"Which image of a batch to convert.rA  ro   rE  r6   r8   rD  z™Exclude pixels whose per-image normalised confidence is below this value (0 = keep all). Used when the geometry has a confidence map (Small/Base models).rØ   rp   TzgExclude sky-probability pixels (sky >= 0.5). Used when the geometry has a sky map (Mono/Metric models).r  Ú
downsamplezbTake every Nth pixel (1 = full resolution). Higher values give fewer points and faster processing.Úpoint_cloud)r‚   rè   )rë   rì   zpoint cloudÚ
pointcloudrï   r?   )	r   r‰   rø   r‹   rõ   rI  r   ÚDA3PointCloudr�   r�   s   &r   r’   Ú%DA3GeometryToPointCloud.define_schemaA  sÕ   € ä�yŠyØ-ÚcØ>Ø0ØDä×!Ñ! .Ó1Ü—‘—‘˜]°A¸1À$ÐPt�ÓuÜ—‘—‘Ð5¸sÈÐQTÐ[_ð xð ó yä—
‘
× Ñ  ¸ð Fð !ó Gä—‘—‘˜\°1¸!Àð Að ó Bð	ô #×)Ñ)°}Ð)ÓEÐFô#
ð 	
r   c               ó   € V ^8„  d   QhRR/# r•   r   )r   s   "r   r   Ú$DA3GeometryToPointCloud.__annotate__X  s   € ÷ Añ AÐcpñ Ar   c                	óL  € VR ,          pVP                   ^ ,          pW'8¼  d   \        RV RV R24      hWb,          P                  4       pRV\        P                  ! V4      ( &   VP                   w  rš\        WWš4      pV^8”  dZ   VRRV1RRV13,          P                  4       pVP                  4       pVR;;,          V,          uu&   VR;;,          V,          uu&   VP                   w  rÍ\        W‹4      p\        W4      pVe   \        Wï4      p\        WWšW44      pV^8”  d   VRRV1RRV13,          pV\        P                  ! V4      ,          pVP                  4       pVR;;,          R,          uu&   VR;;,          R,          uu&   VP                  R^4      VP                  R4      ,          pRpRV9   dQ   VR,          V,          pV^8”  d   VRRV1RRV13,          pVP                  R^4      VP                  R4      ,          pRpRV9   dP   VR,          V,          pV^8”  d   VRRV1RRV13,          pVP                  R4      VP                  R4      ,          pVP                   ^ ,          ^ 8X  d   \        R4      h\        P                  ! R	VR
VRV/4      # )r   rO  rP  rQ  r6   Nrª   rt   zzDA3GeometryToPointCloud produced zero points after filtering. Try lowering confidence_threshold or disabling use_sky_mask.r`  Úcolors)r%  rS  )rX  rS  ).rX  rW  ).r   r   )r    r   r  r!   rT   rH   r	  r2   rM   r_   rx   rW   r   rž   )r‘   rç   r?  ro   rp   rh  r^  rg   r   r,   r-   r   ÚH_dsÚW_dsr`  rP   rv   Úpoints_gltfÚpts_flatÚcolors_flatÚimgÚ	conf_flatra   s   &&&&&&                 r   r¡   ÚDA3GeometryToPointCloud.executeW  s‚  € à  Õ)ˆ	Ø�O‰O˜AÕˆØÔÜ˜|¨K¨=Ð8fÐghÐfiÐijÐkÓlÐlàÕ&×,Ñ,Ó.ˆØ(+ˆŒu�~Š~˜eÓ$Ð$Ñ%Ø�{‰{‰ˆä�|°!Ó7ˆà˜Œ>Ø™,˜J˜,©¨*¨Ð4Õ5×@Ñ@ÓBˆEà—‘“	ˆAØˆd�G�zÕ!‹GØˆd�G�zÕ!‹Gà—[‘[‰
ˆÜ Ó)ˆô ˜|Ó9ˆØŠ=Ü)¨&Ó4ˆFô ˜|¸!Ð@TÓcˆØ˜Œ>Ø™˜*˜¡l¨
 lÐ2Õ3ˆDà”e—n’n UÓ+Õ+ˆð —l‘l“nˆØ�F×˜tÕ#ÓØ�F×˜tÕ#Óà×&Ñ& r¨1Ó-¨d¯l©l¸2Ó.>Õ?ˆàˆØ�lÔ"Ø˜wÕ'¨Õ4ˆCØ˜AŒ~Ø™,˜J˜,©¨*¨Ð4Õ5�ØŸ+™+ b¨!Ó,¨T¯\©\¸"Ó-=Õ>ˆKàˆ	Ø˜<Ô'Ø Õ-¨kÕ:ˆDØ˜AŒ~Ø™L˜j˜L©,¨J¨,Ð6Õ7�ØŸ™ RÓ(¨¯©°bÓ)9Õ:ˆIà�>‰>˜!Õ Ô!ÜðOóð ô
 �}Š}Ø�hØ�kØ˜)ð
ó ð 	r   r   Nrd  r   r   r   rf  rf  >  s-   † ÙMàñ
ó ð
ð* ôAó ôAr   rf  c                  ó,   € ] tR tRt]R R l4       tRtR# )ÚDA3Extensioniœ  c               ó   € V ^8„  d   QhRR/# )r   r   zlist[type[io.ComfyNode]]r   )r   s   "r   r   ÚDA3Extension.__annotate__ž  s   € ÷ 
ñ 
Ð%=ñ 
r   c              ƒ  	ó6   "  € \         \        \        \        .# 5i©N)rz   rÓ   r  r=  )Úselfs   &r   Úget_node_listÚDA3Extension.get_node_list�  s   é € ô ÜÜÜð	
ð 	
ùs   ‚r   N)r£   r¤   r¥   r¦   r   r€  r¨   r   r   r   rz  rz  œ  s   † Øô
ó ô
r   rz  c               ó   € V ^8„  d   QhRR/# )r   r   rz  r   )r   s   "r   r   r   ¨  s   € ÷ ñ  ñ r   c               ƒ  ó   "  € \        4       # 5ir~  )rz  r   r   r   Úcomfy_entrypointr„  ¨  s   é € Ü‹>Ðùs   ‚)rÜ   )-r:  Ú
__future__r   rE   Útyping_extensionsr   r!   Úcomfy.model_managementÚmodel_managementr¹   Úcomfy.sdrD   rŒ   Úcomfy.ldm.colormapr   r)  Úcomfy.ldm.depth_anything_3r   r½   Úcomfy_api.latestr   r   r   Úcomfy.ldm.moge.geometryr	   ÚCustomrŽ   rø   rk  r2   r=   rH   rM   r_   rm   rx   Ú	ComfyNoderz   rÑ   rÓ   r  r=  rf  rz  r„  r   r   r   Ú<module>r�     só   ðñõ #ã Ý &ã å #Û Û Ý .Ý Cß 6Ñ 6Ý 9à�yŠy˜Ó%€Ø�iŠi˜Ó'€Ø—	’	Ð+Ó,€õ*&õ@õ	 õ0õ&õ&#õô!$�2—<‘<ô !$÷H)"ôX['�2—<‘<ô ['ô|k �—‘ô k ô\[#˜Ÿ™ô [#ô|[˜bŸl™lô [ô|	
�>ô 	
÷r   