a
    Ad                     @   s4   d dl Z d dlZd dlmZ d dlmZ dd ZdS )    N)shared)cmd_optsc                     sf  t jtjdd ddlm} m} |jt_| 	|j|j
t_|j
t_
t jtjr^tjtj ddlm   fdddD \ _ _ _ _ _tjrtjntj _tjstjrtjntj _ jt_tjrd	nd
t_ddlm} |  t_!ddlm"} |#tj$t_%ddlm&} |'dt_(ddlm)} |* t_+ddlm,}m  |-d jtjt_.tj./  d	S )zInitializes fields inside the shared module in a controlled manner.

    Should be called early because some other modules you can import mingt need these fields to be already set.
    T)exist_okr   )optionsshared_optionsdevicesc                 3   s2   | ]*}t d d |dfD r" jn  V  qdS )c                 s   s   | ]}|t jv V  qd S )N)r   use_cpu).0y r   ;/var/www/html/stable-diffusion-webui/modules/shared_init.py	<genexpr>       z'initialize.<locals>.<genexpr>.<genexpr>allN)anycpuZget_optimal_device)r
   xr   r   r   r      r   zinitialize.<locals>.<genexpr>)sdinterrogateZgfpganZesrganZ
codeformerNr   )shared_state)styles)r   r   )shared_total_tqdm)memmonr   ZMemMon)0osmakedirsr   hypernetwork_dirmodulesr   r   Zoptions_templatesr   OptionsZrestricted_optsoptspathexistsconfig_filenameloadr   deviceZdevice_interrogateZdevice_gfpganZdevice_esrganZdevice_codeformerno_halftorchfloat32float16dtypeno_half_vaeZ	dtype_vaelowramZweight_load_locationr   Statestater   ZStyleDatabaseZstyles_filenameZprompt_stylesr   ZInterrogateModelsZinterrogatorr   Z	TotalTQDMZ
total_tqdmr   ZMemUsageMonitorZmem_monstart)r   r   r   r   r   r   r   r   r   r   
initialize	   s2    

r/   )r   r&   r   r   Zmodules.sharedr   r/   r   r   r   r   <module>   s   