CoolFace
Apppublic

blanchon/Metric3D

sourceHugging Facegpl-3.0updated 2y agoView on Hugging Face
0likes
running.cpython-39.pyc30 linesDownload Raw Back to __pycache__
1a

2�6�dY3�@s`ddlZddlZddlmZddlmZddlZddlZddlZddl	Z	ddd�Z4d	dd�ZdS)5�N)�main_processTc	Cs�t��}tj�|�r�t�r,|�d|�d��tj|dd�}|d}|j	j6||d�|durh|�7|d�|dur~|�8|d	�|dur�d9|vr�|�10|d11�~~t�r�|�d|�d��|dur�|dur�|�d|�d��nt�r�td
|�d���||||fS)zC12    Load the check point for resuming training or finetuning.13    zLoading weight '�'�cpu)�map_location�model_state_dict)�strictN�	optimizer�	scheduler�scalerzSuccessfully loaded weight: 'zResume training from: 'zNo weight found at ')�logging�	getLogger�os�path�isfiler�info�torch�load�module�load_state_dict�RuntimeError)	Z	load_path�modelrr	�strict_match�loss_scaler�loggerZ14checkpointZckpt_state_dict�r�DC:\Users\JUGG\Documents\GitHub\Metric3DPrivate\mono\utils\running.py�	load_ckpts,rc
Cst��}d|jjvr|jj}n(d|jjvr4|jj}nt|jj�d���t|j�	�|�	�d|jvrh|jjn|jj|�	�d�}	|dur�|	�15t|�	�d��tj�
|jd�}16tj|17d	d18�tj�
|19d|�}t�|20d�}t�|	|�t|�d
k�r|��t�|�d��|�d|���dS)z221    Save the model, optimizer, lr scheduler.22    ZIterBasedRunnerZEpochBasedRunnerz is not supported�	max_iters)rr�max_iterr	N)r23�ckptT)�exist_okzstep%08d.pthz24/step*.pth�rzSave model: )rr�runner�typerZ25max_epochs�	TypeError�dictr�26state_dict�updater
r�joinZwork_dir�makedirs�globr�save�len�sort�remove�popr)
�cfgrrr	Z	curr_iterZ27curr_epochrrrrZckpt_dirZ	save_nameZsaved_ckptsrrr�	save_ckpt)s02829�r1)NNTN)rNN)r
r�torch.nn�nn�mono.utils.commr�copy�inspectrr*rr1rrrr�<module>s30