CoolFace
Apppublic

hololens/stable-diffusion-webui-depthmap-script

sourceHugging Faceupdated 2y agoView on Hugging Face
1likes
net_tools.cpython-310.pyc14 linesDownload Raw Back to __pycache__
1o

2��f��@s@ddlZddlZddlZddlmZdd�Zdd�Zdd�ZdS)	�N)�OrderedDictcCs~|dkrdSz+|�d�}t|�dkrt�|dWSdd�|dd��}t�|�}t||d�WSty>td|��w)	z�Helper to return a function object by name. func_name must identify a3    function in this module or the path to a function relative to the base4    'modeling' module.5    �N�.�rzlib.�����zFailed to f1ind function: %s)	�split�len�globals�join�	importlib�
import_module�getattr�	Exception�print)�	func_name�parts�module_name�module�r�EF:\3dpicmaker\stable-diffusion-webui-depthmap-script\lib\net_tools.py�get_funcs678�rcCs�tj�|j�rHtd|j�t�|j�}|dur$|jt|dd�dd�|dur4|jt|dd�dd�|jt|dd�dd�~tj	�9�dSdS)	z10    Load checkpoint.11    zloading checkpoint %sN�shift_modelzmodule.T)�strict�focal_model�depth_model)�os�path�isfile�	load_ckptr�torch�load�load_state_dict�strip_prefix_if_present�cuda�empty_cache)�argsrrr�12checkpointrrrrs"����rcsRt|���}t�fdd�|D��s|St�}|��D]\}}|||��d�<q|S)Nc3s�|]}|���VqdS)N)�13startswith)�.0�key��prefixrr�	<genexpr>0s�z*strip_prefix_if_present.<locals>.<genexpr>r)�sorted�keys�allr�items�replace)�14state_dictr+r.Zstripped_state_dictr)�valuerr*rr".sr")rrr�collectionsrrrr"rrrr�<module>s