o
    yqi6  ã                   @   s@   d dl Z d dlmZ ddlmZ ddlmZ G dd„ deƒZdS )	é    N)ÚPathé   )ÚBaseTraineré   )ÚMODELSc                   @   s8   e Zd ZdZeZdefdd„Zdd„ Zde	fdd	„Z
d
S )ÚVideoDetTrainerz"Image Classification Model TrainerÚsrc_label_dict_pathc                 C   s"   t | jjƒ d¡}t ||¡ dS )zzdump label dict config

        Args:
            src_label_dict_path (str): path to label dict file to be saved.
        úlabel_map.txtN)r   Úglobal_configÚoutputÚjoinpathÚshutilÚcopyfile)Úselfr   Zdst_label_dict_path© r   ún/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/paddlex/modules/video_detection/trainer.pyÚdump_label_dict   s   zVideoDetTrainer.dump_label_dictc                 C   s0  | j jr| j | j j¡ | j jr| j | j j¡ | j jr$| j | j j¡ | j jdur2| j 	| j j¡ | j 
| jjd¡ | j jdkrI| j | j j¡ t| jjƒ d¡}| ¡ r\| j |¡ | j jdurj| j | j j¡ | j jdurx| j | j j¡ | j jdur†| j | j j¡ | jjdur–| j | jj¡ dS dS )zupdate training configNZVideoDetDatasetÚ r	   )Útrain_configZlog_intervalZ
pdx_configZupdate_log_intervalZeval_intervalZupdate_eval_intervalZsave_intervalZupdate_save_intervalZnum_classesZupdate_num_classesZupdate_datasetr
   Zdataset_dirZpretrain_weight_pathZupdate_pretrained_weightsr   r   ÚexistsZupdate_label_listZ
batch_sizeZupdate_batch_sizeZlearning_rateZupdate_learning_rateZepochs_itersZ_update_epochsr   Z_update_output_dir)r   Zlabel_dict_pathr   r   r   Úupdate_config$   s6   ÿÿÿzVideoDetTrainer.update_configÚreturnc                 C   sX   d|   ¡ i}| jjdur| jjdkr| jj|d< | j dd¡|d< | j dd¡|d< |S )	zƒget key-value arguments of model training function

        Returns:
            dict: the arguments of training function.
        ZdeviceNr   Úresume_pathZdy2stFÚampZOFF)Z
get_devicer   r   Úget)r   Z
train_argsr   r   r   Úget_train_kwargsC   s   z VideoDetTrainer.get_train_kwargsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚentitiesÚstrr   r   Údictr   r   r   r   r   r      s    	r   )r   Úpathlibr   Úbaser   Z
model_listr   r   r   r   r   r   Ú<module>   s
   