Ë
    Fêñiì  ã                   óæ   — d dl mZmZmZ 	 erJ ‚ed   du sJ ‚d dlZd dlmZ  eed«      sJ ‚	 dde	ddfd	„Z
de	d
e	ddfd„Zdd„Zdd„Zdd„Zdd„Zdd„Zer	eeeeedœZyi Zy# eef$ r dZY Œ@w xY w)é    )ÚLOGGERÚSETTINGSÚTESTS_RUNNINGÚclearmlTN)ÚTaskÚ__version__ÚtitleÚreturnc                 óŠ  — ddl }t        j                  «       x}r©| D ]£  }|j                  «       sŒ|j	                  d|j
                  «      }|rt        |j                  «       d   «      nd}|j                  «       j                  ||j
                  j                  |j                  «       d«      t        |«      |¬«       Œ¥ yy)zÝLog files (images) as debug samples in the ClearML task.

    Args:
        files (list[Path]): A list of file paths in PosixPath format.
        title (str): A title that groups together images with the same values.
    r   Nz_batch(\d+)Ú )r	   ÚseriesÚ
local_pathÚ	iteration)Úrer   Úcurrent_taskÚexistsÚsearchÚnameÚintÚgroupsÚ
get_loggerÚreport_imageÚreplaceÚgroupÚstr)Úfilesr	   r   ÚtaskÚfÚitr   s          úe/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/ultralytics/utils/callbacks/clearml.pyÚ_log_debug_samplesr!      s¤   € ó ä× Ñ Ó"Ð"€tÐ"Øò 	ˆAØ�x‰x�zØ—Y‘Y˜~¨q¯v©vÓ6�Ù35œC §	¡	£¨A¡Ô/¸1�	Ø—‘Ó!×.Ñ.Ø¨¯©¯©°r·x±x³zÀ2Ó(FÔSVÐWXÓSYÐenð /õ ñ		ð #ó    Ú	plot_pathc                 ó  — ddl m} ddlm} |j	                  |«      }|j                  «       }|j                  g d¢ddg g ¬«      }|j                  |«       t        j                  «       j                  «       j                  | d|d¬«       y)	z´Log an image as a plot in the plot section of ClearML.

    Args:
        title (str): The title of the plot.
        plot_path (str | Path): The path to the saved image file.
    r   N)r   r   é   r%   FÚauto)ÚframeonÚaspectÚxticksÚyticksr   )r	   r   ÚfigureÚreport_interactive)Úmatplotlib.imageÚimageÚmatplotlib.pyplotÚpyplotÚimreadr+   Úadd_axesÚimshowr   r   r   Úreport_matplotlib_figure)r	   r#   ÚmpimgÚpltÚimgÚfigÚaxs          r    Ú	_log_plotr:   $   su   € õ %Ý#à
�,‰,�yÓ
!€CØ
�*‰*‹,€CØ	�‰’l¨E¸&ÈÐTVˆÓ	W€BØ‡I�Iˆc„Nä×ÑÓ×"Ñ"Ó$×=Ñ=Ø˜B s¸uð >õ r"   c           
      óú  — 	 t        j                  «       x}r/ddlm} ddlm} |j                  d«       |j                  d«       n`t        j                  | j                  j                  xs d| j                  j                  dgdddddœ¬	«      }t        j                  d
«       |j                  t        | j                  «      dd¬«       y# t        $ r"}t        j                  d|› �«       Y d}~yd}~ww xY w)zHInitialize and connect ClearML task at the start of pretraining routine.r   )ÚPatchPyTorchModelIO)ÚPatchedMatplotlibNÚUltralyticsTF)ÚpytorchÚ
matplotlib)Úproject_nameÚ	task_nameÚtagsÚ
output_uriÚreuse_last_task_idÚauto_connect_frameworksz‰ClearML Initialized a new task. If you want to run remotely, please add clearml-init and connect your arguments before initializing YOLO.ÚGeneral)r   Úignore_remote_overrideszGClearML installed but not initialized correctly, not logging this run. )r   r   Ú'clearml.binding.frameworks.pytorch_bindr<   Úclearml.binding.matplotlib_bindr=   Úupdate_current_taskÚinitÚargsÚprojectr   r   ÚwarningÚconnectÚvarsÚ	Exception)Útrainerr   r<   r=   Úes        r    Úon_pretrain_routine_startrU   8   sÞ   € ðfÜ×$Ñ$Ó&Ð&ˆ4Ð&õ TÝIà×3Ñ3°DÔ9Ø×1Ñ1°$Õ7ä—9‘9Ø$Ÿ\™\×1Ñ1ÒB°]Ø!Ÿ,™,×+Ñ+Ø#�_ØØ#(Ø49ÈÑ(OôˆDô �N‰Nð_ôð 	�‰”T˜'Ÿ,™,Ó'¨iÐQUˆÕVøÜò fÜ�‰Ð`ÐabÐ`cÐd×eÑeûðfús   ‚CC Ã	C:ÃC5Ã5C:c                 ó
  — t        j                  «       x}rí| j                  dk(  r.t        t	        | j
                  j                  d«      «      d«       | j                  | j                  d¬«      j                  «       D ]2  \  }}|j                  «       j                  d||| j                  ¬«       Œ4 | j                  j                  «       D ]2  \  }}|j                  «       j                  d||| j                  ¬«       Œ4 yy)	zKLog debug samples for the first epoch and report current training progress.r%   ztrain_batch*.jpgÚMosaicÚtrain)Úprefix©r   ÚlrN)r   r   Úepochr!   ÚsortedÚsave_dirÚglobÚlabel_loss_itemsÚtlossÚitemsr   Úreport_scalarr[   )rS   r   ÚkÚvs       r    Úon_train_epoch_endrf   U   sá   € ä× Ñ Ó"Ð"€tÐ"à�=‰=˜AÒÜœv g×&6Ñ&6×&;Ñ&;Ð<NÓ&OÓPÐRZÔ[à×,Ñ,¨W¯]©]À7Ð,ÓK×QÑQÓSò 	T‰DˆAˆqØ�O‰OÓ×+Ñ+¨G°Q¸ÀWÇ]Á]Ð+ÕSð	Tà—J‘J×$Ñ$Ó&ò 	Q‰DˆAˆqØ�O‰OÓ×+Ñ+¨D°!°QÀ'Ç-Á-Ð+ÕPñ	Qð #r"   c                 ó  — t        j                  «       x}rï|j                  «       j                  dd| j                  | j
                  ¬«       | j                  j                  «       D ]F  \  }}|j                  d«      d   }|j                  «       j                  |||| j
                  ¬«       ŒH | j
                  dk(  rEddl	m
}  || «      j                  «       D ]%  \  }}|j                  «       j                  ||«       Œ' yyy)zFReport model information and metrics to logger at the end of an epoch.z
Epoch Time)r	   r   Úvaluer   ú/r   rZ   )Úmodel_info_for_loggersN)r   r   r   rc   Ú
epoch_timer\   Úmetricsrb   ÚsplitÚultralytics.utils.torch_utilsrj   Úreport_single_value)rS   r   rd   re   r	   rj   s         r    Úon_fit_epoch_endrp   b   sð   € ä× Ñ Ó"Ð"€tÐ"à�‰Ó×'Ñ'Ø |¸7×;MÑ;MÐY`×YfÑYfð 	(ô 	
ð —O‘O×)Ñ)Ó+ò 	R‰DˆAˆqØ—G‘G˜C“L ‘OˆEØ�O‰OÓ×+Ñ+¨E°1°aÀ7Ç=Á=Ð+ÕQð	Rð �=‰=˜AÒÝLá.¨wÓ7×=Ñ=Ó?ò <‘��1Ø—‘Ó!×5Ñ5°a¸Õ;ñ<ð ð #r"   c                 óŠ   — t        j                  «       r/t        t        | j                  j                  d«      «      d«       yy)z8Log validation results including labels and predictions.zval*.jpgÚ
ValidationN)r   r   r!   r]   r^   r_   )Ú	validators    r    Ú
on_val_endrt   s   s3   € ä×ÑÔäœ6 )×"4Ñ"4×"9Ñ"9¸*Ó"EÓFÈÕUð r"   c                 ó*  — t        j                  «       x}rýg | j                  j                  «       ¢| j                  j                  j                  «       ¢D ](  }d|j
                  vsŒt        |j                  |¬«       Œ* | j                  j                  j                  j                  «       D ]%  \  }}|j                  «       j                  ||«       Œ' |j                  t        | j                  «      | j                   j
                  d¬«       yy)z<Log final model and training results on training completion.Úbatch)r	   r#   F)Ú
model_pathÚ
model_nameÚauto_delete_fileN)r   r   ÚplotsÚkeysrs   r   r:   Ústemrl   Úresults_dictrb   r   ro   Úupdate_output_modelr   ÚbestrM   )rS   r   r   rd   re   s        r    Úon_train_endr€   z   sâ   € ä× Ñ Ó"Ð"€tÐ"àI�7—=‘=×%Ñ%Ó'ÐI¨'×*;Ñ*;×*AÑ*A×*FÑ*FÓ*HÐIò 	5ˆAØ˜aŸf™fÒ$Ü §¡°!Ö4ð	5ð ×%Ñ%×-Ñ-×:Ñ:×@Ñ@ÓBò 	8‰DˆAˆqØ�O‰OÓ×1Ñ1°!°QÕ7ð	8ð 	× Ñ ¬C°·±Ó,=È'Ï,É,×J[ÑJ[ÐnsÐ Õtð #r"   )rU   rf   rp   rt   r€   )zDebug Samples)r
   N)Úultralytics.utilsr   r   r   r   r   ÚhasattrÚImportErrorÚAssertionErrorr   r!   r:   rU   rf   rp   rt   r€   Ú	callbacks© r"   r    ú<module>r‡      sÔ   ð÷ >Ñ =ð	ÙÐÐØ�IÑ $Ñ&Ð&Ð&ÛÝá�7˜MÔ*Ð*Ñ*ñ Sð ¸tó ð&�Sð  Sð ¨Tó ó(fó:
Qó<ó"Vóuñ, ð &?Ø0Ø,Ø Ø$ññ 
ð 
ñ 
øðw 	�^Ð$ò Ø‚Gðús   Œ"A$ Á$	A0Á/A0