a
    d(                     @   s:   d dl Z d dlmZ d dlmZ ddlmZ d
dd	ZdS )    N)deepcopy)load_file_from_url   )
RetinaFaceFcudac           
      C   s   | dkrt d||d}d}n*| dkr8t d||d}d}nt|  dt|d	d
d |d}tj|dd d}t| D ],\}}	|drv|	||dd  < || qv|j	|d
d |
  ||}|S )NZretinaface_resnet50Zresnet50)Znetwork_namehalfdevicezYhttps://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pthzretinaface_mobile0.25z
mobile0.25z^https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_mobilenet0.25_Final.pthz is not implemented.zfacexlib/weightsT)urlZ	model_dirprogress	file_namesave_dirc                 S   s   | S )N )Zstoragelocr   r   d/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/facexlib/detection/__init__.py<lambda>       z&init_detection_model.<locals>.<lambda>)Zmap_locationzmodule.   )strict)r   NotImplementedErrorr   torchloadr   items
startswithpopZload_state_dictevalto)
Z
model_namer   r   Zmodel_rootpathmodelZ	model_urlZ
model_pathZload_netkvr   r   r   init_detection_model   s&    


r   )Fr   N)r   copyr   Zfacexlib.utilsr   Z
retinafacer   r   r   r   r   r   <module>   s   