§
    “©ºj$  ã                   ó’   — d dl mZmZmZ d dlmZ d dlZd dlm	Z	 d dl
mZ  G d„ de	¦  «        Zdd	d
eeeeef         f         fd„ZdS )é    )ÚAnyÚOptionalÚUnion)ÚoverrideN)ÚCallback)Úrank_zero_warnc                   óF  — e Zd ZdZdd„Zed d„¦   «         Zedefd„¦   «         Zedefd„¦   «         Z	edefd	„¦   «         Z
edefd
„¦   «         Zedefd„¦   «         Zedeeef         fd„¦   «         Zedeeef         fd„¦   «         Zedeeef         fd„¦   «         Zedeeef         fd„¦   «         Zedeeef         fd„¦   «         Zdedefd„Zdd„Zdd„Zdd„Zdededdfd„Zedddddeddfd„¦   «         Zdddddeeeeeeeeef         f         f         fd„ZdS )!ÚProgressBarað  The base class for progress bars in Lightning. It is a :class:`~pytorch_lightning.callbacks.Callback` that keeps
    track of the batch progress in the :class:`~pytorch_lightning.trainer.trainer.Trainer`. You should implement your
    highly custom progress bars with this as the base class.

    Example::

        class LitProgressBar(ProgressBar):

            def __init__(self):
                super().__init__()  # don't forget this :)
                self.enable = True

            def disable(self):
                self.enable = False

            def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx):
                super().on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx)  # don't forget this :)
                percent = (batch_idx / self.total_train_batches) * 100
                sys.stdout.flush()
                sys.stdout.write(f'{percent:.01f} percent complete \r')

        bar = LitProgressBar()
        trainer = Trainer(callbacks=[bar])

    ÚreturnNc                 ó"   — d | _         d | _        d S ©N)Ú_trainerÚ_current_eval_dataloader_idx©Úselfs    ú�/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/pytorch_lightning/callbacks/progress/progress_bar.pyÚ__init__zProgressBar.__init__2   s   € Ø.2ˆŒØ;?ˆÔ)Ð)Ð)ó    ú
pl.Trainerc                 óX   — | j         €t          d| j        j        › d�¦  «        ‚| j         S )NzThe `z*._trainer` reference has not been set yet.)r   Ú	TypeErrorÚ	__class__Ú__name__r   s    r   ÚtrainerzProgressBar.trainer6   s1   € àŒ=Ð ÝÐg D¤NÔ$;ÐgÐgÐgÑhÔhÐhØŒ}Ðr   c                 ó   — dS )NzSanity Checking© r   s    r   Úsanity_check_descriptionz$ProgressBar.sanity_check_description<   s   € à Ð r   c                 ó   — dS )NÚTrainingr   r   s    r   Útrain_descriptionzProgressBar.train_description@   s   € àˆzr   c                 ó   — dS )NÚ
Validationr   r   s    r   Úvalidation_descriptionz"ProgressBar.validation_descriptionD   ó   € àˆ|r   c                 ó   — dS )NÚTestingr   r   s    r   Útest_descriptionzProgressBar.test_descriptionH   s   € àˆyr   c                 ó   — dS )NÚ
Predictingr   r   s    r   Úpredict_descriptionzProgressBar.predict_descriptionL   r$   r   c                 óØ   — | j         j        dk    rO| j         j        �C| j         j        dk    r3| j         j        | j         j        z
  }t	          | j         j        |¦  «        S | j         j        S )zíThe total number of training batches, which may change from epoch to epoch.

        Use this to set the total number of iterations in the progress bar. Can return ``inf`` if the training
        dataloader is of infinite size.

        éÿÿÿÿNr   )r   Ú
max_epochsÚ	max_stepsÚglobal_stepÚminÚnum_training_batches)r   Úremaining_stepss     r   Útotal_train_batcheszProgressBar.total_train_batchesP   sd   € ð Œ<Ô" bÒ(Ð(¨T¬\Ô-CÐ-OÐTXÔT`ÔTjÐmnÒTnÐTnØ"œlÔ4°t´|Ô7OÑOˆOÝ�t”|Ô8¸/ÑJÔJÐJØŒ|Ô0Ð0r   c                 ó¤   — | j         j        r| j         j        n| j         j        }t	          |t
          ¦  «        r| j        €J ‚|| j                 S |S )a  The total number of validation batches, which may change from epoch to epoch for current dataloader.

        Use this to set the total number of iterations in the progress bar. Can return ``inf`` if the validation
        dataloader is of infinite size.

        )r   Úsanity_checkingÚnum_sanity_val_batchesÚnum_val_batchesÚ
isinstanceÚlistr   ©r   Úbatchess     r   Ú$total_val_batches_current_dataloaderz0ProgressBar.total_val_batches_current_dataloader]   sX   € ð :>¼Ô9UÐw�$”,Ô5Ð5Ð[_Ô[gÔ[wˆÝ�g�tÑ$Ô$ð 	>ØÔ4Ð@Ð@Ð@Ø˜4Ô<Ô=Ð=Øˆr   c                 ót   — | j         j        }t          |t          ¦  «        r| j        €J ‚|| j                 S |S )zÿThe total number of testing batches, which may change from epoch to epoch for current dataloader.

        Use this to set the total number of iterations in the progress bar. Can return ``inf`` if the test dataloader is
        of infinite size.

        )r   Únum_test_batchesr8   r9   r   r:   s     r   Ú%total_test_batches_current_dataloaderz1ProgressBar.total_test_batches_current_dataloaderk   sB   € ð ”,Ô/ˆÝ�g�tÑ$Ô$ð 	>ØÔ4Ð@Ð@Ð@Ø˜4Ô<Ô=Ð=Øˆr   c                 óB   — | j         €J ‚| j        j        | j                  S )a  The total number of prediction batches, which may change from epoch to epoch for current dataloader.

        Use this to set the total number of iterations in the progress bar. Can return ``inf`` if the predict dataloader
        is of infinite size.

        )r   r   Únum_predict_batchesr   s    r   Ú(total_predict_batches_current_dataloaderz4ProgressBar.total_predict_batches_current_dataloadery   s&   € ð Ô0Ð<Ð<Ð<ØŒ|Ô/°Ô0QÔRÐRr   c                 óÔ   — | j         j        j                             ¦   «         sdS t	          | j         j        t          ¦  «        rt          | j         j        ¦  «        n| j         j        S )a  The total number of validation batches, which may change from epoch to epoch for all val dataloaders.

        Use this to set the total number of iterations in the progress bar. Can return ``inf`` if the predict dataloader
        is of infinite size.

        r   )r   Úfit_loopÚ
epoch_loopÚ_should_check_val_epochr8   r7   r9   Úsumr   s    r   Útotal_val_batcheszProgressBar.total_val_batches„   s]   € ð Œ|Ô$Ô/×GÒGÑIÔIð 	Ø�1õ ˜$œ,Ô6½Ñ=Ô=ð.�C�”Ô,Ñ-Ô-Ð-à”Ô-ð	
r   Údataloader_idxc                 ó*   — | j         }|| _         ||k    S r   ©r   )r   rI   Úold_dataloader_idxs      r   Úhas_dataloader_changedz"ProgressBar.has_dataloader_changed”   s   € Ø!Ô>ÐØ,:ˆÔ)Ø! ^Ò3Ð3r   c                 ó   — d | _         d S r   rK   r   s    r   Úreset_dataloader_idx_trackerz(ProgressBar.reset_dataloader_idx_tracker™   s   € Ø,0ˆÔ)Ð)Ð)r   c                 ó   — t           ‚)z5You should provide a way to disable the progress bar.©ÚNotImplementedErrorr   s    r   ÚdisablezProgressBar.disableœ   s   € å!Ð!r   c                 ó   — t           ‚)aO  You should provide a way to enable the progress bar.

        The :class:`~pytorch_lightning.trainer.trainer.Trainer` will call this in e.g. pre-training
        routines like the :ref:`learning rate finder <advanced/training_tricks:Learning Rate Finder>`.
        to temporarily enable and disable the training progress bar.

        rQ   r   s    r   ÚenablezProgressBar.enable    s
   € õ "Ð!r   ÚargsÚkwargsc                 ó   — t          |i |¤Ž dS )zDYou should provide a way to print without breaking the progress bar.N)Úprint)r   rV   rW   s      r   rY   zProgressBar.printª   s   € åˆtÐ�vÐÐÐÐÐr   r   Ú	pl_modulezpl.LightningModuleÚstagec                 óN   — || _         |j        s|                      ¦   «          d S d S r   )r   Úis_global_zerorS   )r   r   rZ   r[   s       r   ÚsetupzProgressBar.setup®   s/   € àˆŒØÔ%ð 	Ø�LŠL‰NŒNˆNˆNˆNð	ð 	r   c                 ó  — t          |¦  «        }|j        }t          |                     ¦   «         |                     ¦   «         z  ¦  «        }|r/t	          dd                     |¦  «        › d|d         › d�¦  «         i |¥|¥S )a^  Combines progress bar metrics collected from the trainer with standard metrics from get_standard_metrics.
        Implement this to override the items displayed in the progress bar.

        Here is an example of how to override the defaults:

        .. code-block:: python

            def get_metrics(self, trainer, model):
                # don't show the version number
                items = super().get_metrics(trainer, model)
                items.pop("v_num", None)
                return items

        Return:
            Dictionary with the items to be displayed in the progress bar.

        z;The progress bar already tracks a metric with the name(s) 'z, z' and `self.log('r   z“', ..., prog_bar=True)` will overwrite this value.  If this is undesired, change the name or override `get_metrics()` in the progress bar callback.)Úget_standard_metricsÚprogress_bar_metricsr9   Úkeysr   Újoin)r   r   rZ   Ústandard_metricsÚpbar_metricsÚ
duplicatess         r   Úget_metricszProgressBar.get_metrics´   s¬   € õ( 0°Ñ8Ô8ÐØÔ3ˆÝÐ*×/Ò/Ñ1Ô1°L×4EÒ4EÑ4GÔ4GÑGÑHÔHˆ
Øð 	ÝðsÈdÏiÊiÐXbÑNcÔNcð sð sØ)¨!œ}ðsð sð sñô ð ð 4Ð"Ð3 lÐ3Ð3r   )r   N)r   r   ) r   Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   Ústrr   r    r#   r'   r*   r   ÚintÚfloatr3   r<   r?   rB   rH   ÚboolrM   rO   rS   rU   r   rY   r   r^   Údictrg   r   r   r   r
   r
      s!  € € € € € ðð ð4@ð @ð @ð @ð ðð ð ñ „Xðð
 ð!¨#ð !ð !ð !ñ „Xð!ð ð 3ð ð ð ñ „Xðð ð¨ð ð ð ñ „Xðð ð #ð ð ð ñ „Xðð ð Sð ð ð ñ „Xðð ð
1 U¨3°¨:Ô%6ð 
1ð 
1ð 
1ñ „Xð
1ð ð°e¸CÀ¸JÔ6Gð ð ð ñ „Xðð ð°u¸SÀ%¸ZÔ7Hð ð ð ñ „Xðð ðS¸%ÀÀUÀ
Ô:Kð Sð Sð Sñ „XðSð ð
 5¨¨e¨Ô#4ð 
ð 
ð 
ñ „Xð
ð4°Sð 4¸Tð 4ð 4ð 4ð 4ð
1ð 1ð 1ð 1ð"ð "ð "ð "ð"ð "ð "ð "ð˜3ð ¨#ð °$ð ð ð ð ð ð˜\ð Ð6Jð ÐSVð Ð[_ð ð ð ñ „Xðð
4Ø#ð4Ø0Dð4à	ˆc�5˜˜c 5¨$¨s°E¨zÔ*:Ð:Ô;Ð;Ô	<ð4ð 4ð 4ð 4ð 4ð 4r   r
   r   r   r   c                 ó”   — i }| j         r>ddlm}  || j         ¦  «        x}dvr$t          |t          ¦  «        r
|dd…         }||d<   |S )uX  Returns the standard metrics displayed in the progress bar. Currently, it only includes the version of the
    experiment when using a logger.

    .. code-block::

        Epoch 1:   4%|â–Ž         | 40/1095 [00:03<01:37, 10.84it/s, v_num=10]

    Return:
        Dictionary with the standard metrics to be displayed in the progress bar.

    r   )Ú_version)Ú NéüÿÿÿNÚv_num)ÚloggersÚ#pytorch_lightning.loggers.utilitiesrr   r8   rl   )r   Ú
items_dictrr   Úversions       r   r`   r`   Õ   sp   € ð .0€JØ„ð *Ø@Ð@Ð@Ð@Ð@Ð@à�x ¤Ñ0Ô0Ð0ˆG¸ÐCÐCÝ˜'¥3Ñ'Ô'ð 'à! " # #œ,�Ø")ˆJ�wÑàÐr   )Útypingr   r   r   Útyping_extensionsr   Úpytorch_lightningÚplÚpytorch_lightning.callbacksr   Ú%pytorch_lightning.utilities.rank_zeror   r
   rp   rl   rm   r`   r   r   r   ú<module>r€      sØ   ðð (Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'à &Ð &Ð &Ð &Ð &Ð &à Ð Ð Ð Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø @Ð @Ð @Ð @Ð @Ð @ð{4ð {4ð {4ð {4ð {4�(ñ {4ô {4ð {4ð| ,ð °4¸¸UÀ3ÈÀ8¼_Ð8LÔ3Mð ð ð ð ð ð r   