
    h                     `    S r SSKrSSKJr  SSKrSS jrS rSS jrS r	S r
S rSS	 jrS
 rg)zk
This code file mainly comes from https://github.com/dmlc/gluon-cv/blob/master/gluoncv/utils/filesystem.py
    Nc                 t    [         R                  R                  U5      n[        R                  " USU 5      nU$ )Nmodels)ospath
expanduserospjoin)nameroot	model_dirs      V/var/www/fran/franai/venv/lib/python3.13/site-packages/insightface/utils/filesystem.pyget_model_dirr   	   s.    77d#Dx.I    c                      [         R                  " U 5        g! [         a)  nUR                  [        R                  :w  a  e  SnAgSnAff = f)zCreate directory recursively if not exists.
Similar to `makedir -p`, you can skip checking existence before this function.

Parameters
----------
path : str
    Path of the desired dir
N)r   makedirsOSErrorerrnoEEXIST)r   excs     r   r   r      s;    
D 99$ %s    
AAAc                 f     [        U 5      $ ! [         a  nU(       d  Ue[        U5      eSnAff = f)aE  Try import specified package, with custom message support.

Parameters
----------
package : str
    The name of the targeting package.
message : str, default is None
    If not None, this function will raise customized error message when import error is found.


Returns
-------
module if found, raise ImportError otherwise

N)
__import__ImportError)packagemessagees      r   
try_importr      s5     #'"" #G'""#s   
 
0+0c                      Sn [        SU 5      $ )z^Try import cv2 at runtime.

Returns
-------
cv2 module if found. Raise ImportError otherwise

zcv2 is required, you can install by package manager, e.g. 'apt-get',         or `pip install opencv-python --user` (note that this is unofficial PYPI package).cv2r   msgs    r   try_import_cv2r"   6   s    \C eS!!r   c                      Sn [        SU 5      $ )z`Try import mmcv at runtime.

Returns
-------
mmcv module if found. Raise ImportError otherwise

zmmcv is required, you can install by first `pip install Cython --user`         and then `pip install mmcv --user` (note that this is unofficial PYPI package).mmcvr   r    s    r   try_import_mmcvr%   D   s    YC fc""r   c                      Sn [        SU 5      $ )zfTry import rarfile at runtime.

Returns
-------
rarfile module if found. Raise ImportError otherwise

zrarfile is required, you can install by first `sudo apt-get install unrar`         and then `pip install rarfile --user` (note that this is unofficial PYPI package).rarfiler   r    s    r   try_import_rarfiler(   R   s    \C i%%r   c                 p    [        U 5      $ ! [         a     SSKJn  O! [         a	    SSKJn   Of = fUc  U OUnU" SSU/5         [        U 5      s $ ! [         aR    SSKnSSKnUR                  5       nXdR                  ;  a  UR                  R                  U5        [        U 5      s s $ f = ff = f)a  Try import the specified package.
If the package not installed, try use pip to install and import if success.

Parameters
----------
package : str
    The name of the package trying to import.
extern_url : str or None, optional
    The external url if package is not hosted on PyPI.
    For example, you can install a package using:
     "pip install git+http://github.com/user/repo/tarball/master/egginfo=xxx".
    In this case, you can pass the url to the extern_url.

Returns
-------
<class 'Module'>
    The imported python module.

r   )mainNinstallz--user)
r   r   pipr*   pip._internalsyssitegetusersitepackagesr   append)r   
extern_urlpipmainurlr.   r/   	user_sites          r   import_try_installr6   `   s    (''"" '	6+ 	65	6 $+gH 		'g&& 	'002I(	*g&&	''sI   
 
B5B52B52B5
AB5AB1,B50B11B5c                       [        S/ SQS9n U R                  R                  U l        U $ ! [         a     " S S5      n  U $ f = f)z'Try import NVIDIA DALI at runtime.
    znvidia.dali)pipelineopstypes)fromlistc                   (    \ rS rSr " S S5      rSrg)try_import_dali.<locals>.dali   c                       \ rS rSrS rSrg)&try_import_dali.<locals>.dali.Pipeline   c                     [        S5      e)Nz;DALI not found, please check if you installed it correctly.)NotImplementedError)selfs    r   __init__/try_import_dali.<locals>.dali.Pipeline.__init__   s    -U r    N)__name__
__module____qualname____firstlineno__rE   __static_attributes__rG   r   r   Pipeliner@      s    r   rM   rG   N)rH   rI   rJ   rK   rM   rL   rG   r   r   dalir=      s     r   rN   )r   r8   rM   r   )rN   s    r   try_import_dalirO      sN    
-2NO.. K  	 	 Ks   '+ AA)z~/.insightface)N)__doc__r   os.pathr   r   r   r   r   r   r"   r%   r(   r6   rO   rG   r   r   <module>rR      s>    
  
 #0"#&+\r   