
    Αi[7                    x   % S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	J
r
Jr  S SKJr  S SKJr  S SKrS SKJrJr  \
(       a
  S SKrS SK	Jr  / r\S   rS	\S
'   SrS\S'   SrS\S'   SrS\S'   \R8                  R;                  \R8                  R=                  SSSS5      5      rS\S'   S r S r!S r"S r#S r$S)S jr%S r&S r'S r(  S*       S+S  jjr)  S*       S,S! jjr*  S*           S-S" jjr+    S.           S/S# jjr,S$ r-S0S% jr.S& r/S' r0\Rb                  S1S( j5       r2g)2    )annotationsN)TYPE_CHECKINGLiteral)urlparse)	TypeAlias)	_downloadget_path_from_url)Anygithubgiteelocalr   _Source~/.cachestrDEFAULT_CACHE_DIRdependenciesVAR_DEPENDENCYz
hubconf.pyMODULE_HUBCONF~z.cachepaddlehubHUB_DIRc                    [         R                  R                  U 5      (       aR  [         R                  R                  U 5      (       a  [         R                  " U 5        g [
        R                  " U 5        g g N)ospathexistsisfileremoveshutilrmtree)r   s    O/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/hapi/hub.py_remove_if_existsr$   .   sD    	ww~~d77>>$IIdOMM$	     c                J   [         R                  R                  SU5         [        U 5      n[         R                  R                  U 5        [         R                  R                  U5        U$ ! [         a+    [         R                  R                  U5        [        S5      ef = f)Nr   zPPlease make sure config exists or repo error messages above fixed when importing)	sysr   insert
__import__modulespopImportErrorr    RuntimeError)namerepo_dir
hub_modules      r#   _import_moduler1   6   s|    HHOOAx 
%
 HHOOH  
!^
 	

s   *A- -5B"c                L    US:X  a  SU  SU SU S3$ US:X  a  SU  SU SU S3$ g )	Nr   zhttps://github.com//z	/archive/.zipr   zhttps://gitee.com/z/repository/archive/ )
repo_owner	repo_namebranchsources       r#   _git_archive_linkr:   F   sT    !*Qyk6($O	
 
7	#J<q;OPVxW[\\ 
r%   c                |    US:X  a  SOSnSU ;   a  U R                  S5      u  p2OU nUR                  S5      u  pEXEU4$ )Nr   mainmaster:r3   )split)repor9   r8   	repo_infor6   r7   s         r#   _parse_repo_inforB   O   sJ    )VxF
d{ JJsO	6	%OOC0J&((r%   c                h     SSK Jn  U" U 5      R	                  SS9  g ! [         a	    SSKJn   N(f = f)Nr   )PathT)exist_ok)pathlibrD   r,   pathlib2mkdir)dirnamerD   s     r#   
_make_dirsrJ   Y   s5    "  	M&  "!"s    11c                   [         n[        U5        [        X5      u  pVnUR                  SS5      n[        R
                  R                  USR                  XVU/5      5      n	U(       + =(       a    [        R
                  R                  U	5      n
U
(       a,  U(       a#  [        R                  R                  SU	 S35        U	$ [        R
                  R                  XHS-   5      n[        U5        [        XVXsS9n[        UUU(       + SS9n[        R                  " X5        [         R"                  " U5       nUR%                  5       S	   R&                  n[        R
                  R                  XO5      n[        U5        UR)                  U5        S S S 5        [        U5        [        U	5        [        R                  " WU	5        U	$ ! , (       d  f       N== f)
Nr3   _zUsing cache found in 
r4   r9   F)check_exist
decompressr   )r   rJ   rB   replacer   r   joinr   r'   stderrwriter$   r:   r	   r!   movezipfileZipFileinfolistfilename
extractall)r@   force_reloadverboser9   hub_dirr6   r7   r8   normalized_brr/   	use_cachecached_fileurlfpathcached_zipfileextracted_repo_nameextracted_repos                    r#   _get_cache_or_reloadrf   a   su   Gw %5T$B!J6
 NN3,M
 ww||:-@AH "!?rww~~h'?IJJ4XJbAB6 O3 ggll7F,BC+&
vM!((	
 	E'__[)^"0"9"9";A">"G"GWW\\'GNn-%%g. * 	+&(#NH-O *)s   7AG
Gc                    [        U[        5      (       d  [        S5      e[        XS5      nUb  [	        U5      (       d  [        SU S35      eU$ )zload entry from hubconfz5Invalid input: model should be a str of function nameNzCannot find callable z in hubconf)
isinstancer   
ValueErrorgetattrcallabler-   )mr.   funcs      r#   _load_entry_from_hubconfrn      sT    dC  C
 	
 1D!D|8D>>24&DEEKr%   c                <     [        U 5        g! [         a     gf = f)NTF)r)   r,   )r.   s    r#   _check_module_existsrp      s$    4 s    
c                    [        U [        S 5      nUb^  U Vs/ s H  n[        U5      (       a  M  UPM     nn[        U5      (       a)  [	        SR                  SR                  U5      5      5      eg g s  snf )NzMissing dependencies: {}z, )rj   r   rp   lenr-   formatrR   )rl   r   pkgmissing_depss       r#   _check_dependenciesrv      sz    1nd3L'
'C/CC/HC< 	 
 |*11$))L2IJ  	  
s
   A4A4c           	     <   US;  a  [        SU S35      eUS;   a  [        XSUS9n [        [        R	                  S5      S   U 5      n[        U5       Vs/ s H8  n[        [        X45      5      (       d  M  UR                  S	5      (       a  M6  UPM:     nnU$ s  snf )
a  
List all entrypoints available in `github` hubconf.

Args:
    repo_dir(str): Github or local path.

        - github path (str): A string with format "repo_owner/repo_name[:tag_name]" with an optional
          tag/branch. The default branch is `main` if not specified.
        - local path (str): Local repo path.

    source (str): `github` | `gitee` | `local`. Default is `github`.
    force_reload (bool, optional): Whether to discard the existing cache and force a fresh download. Default is `False`.

Returns:
    entrypoints: A list of available entrypoint names.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> paddle.hub.list('lyuwenyu/paddlehub_demo:main', source='github', force_reload=False)

r   Unknown source: "0". Allowed values: "github" | "gitee" | "local".r   r   TrN   .r   rL   )	ri   rf   r1   r   r?   dirrk   rj   
startswith)r/   r9   r[   r0   fentrypointss         r#   listr      s    : 11x'WX
 	
 $$'D
   4 4S 9! <hGJ Z AGJ*+ 	
45LL4E 	
    s   B7BBc                    US;  a  [        SU S35      eUS;   a  [        XSUS9n [        [        R	                  S5      S   U 5      n[        XA5      nUR                  $ )	aq  
Show help information of model

Args:
    repo_dir(str): Github or local path.

        - github path (str): A string with format "repo_owner/repo_name[:tag_name]" with an optional
          tag/branch. The default branch is `main` if not specified.
        - local path (str): Local repo path.

    model (str): Model name.
    source (str): `github` | `gitee` | `local`. Default is `github`.
    force_reload (bool, optional): Default is `False`.

Returns:
    docs

Examples:
    .. code-block:: python

        >>> import paddle

        >>> paddle.hub.help('lyuwenyu/paddlehub_demo:main', model='MM', source='github')

r   rx   ry   rz   TrN   r{   r   )ri   rf   r1   r   r?   rn   __doc__)r/   modelr9   r[   r0   entrys         r#   helpr      su    > 11x'WX
 	
 $$'D
   4 4S 9! <hGJ$Z7E==r%   c                    US;  a  [        SU S35      eUS;   a  [        XSUS9n [        [        R	                  S5      S   U 5      n[        U5        [        XQ5      nU" S	0 UD6$ )
a  
Load model

Args:
    repo_dir(str): Github or local path.

        - github path (str): A string with format "repo_owner/repo_name[:tag_name]" with an optional
          tag/branch. The default branch is `main` if not specified.
        - local path (str): Local repo path.

    model (str): Model name.
    source (str): `github` | `gitee` | `local`. Default is `github`.
    force_reload (bool, optional): Default is `False`.
    **kwargs: Parameters using for model.

Returns:
    paddle model.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.hub.load('lyuwenyu/paddlehub_demo:main', model='MM', source='github')

r   rx   ry   rz   TrN   r{   r   r5   )ri   rf   r1   r   r?   rv   rn   )r/   r   r9   r[   kwargsr0   r   s          r#   loadr     s    @ 11x'WX
 	
 $$'D
   4 4S 9! <hGJ
#$Z7E?6?r%   c                   Uc*  [        5       n[        R                  R                  US5      n [        R                  " U5        [        U 5      n[        R                  R                  UR                  5      nUb  Un[        R                  R                  X5      n	[        R                  R                  U	5      (       d=  [        R                  R                  SU  SU	 S35        Sn
U(       a  Un
[        XU
5        U(       aj  US;   d   e[        U	5      (       a  [!        XU5      $ US;   a  ["        R$                  " U	SS	9$ ['        U5         ["        R$                  " U	5      sSSS5        $ [        U	5      (       a  [!        X5      $ ["        R$                  " U	5      $ ! [
         a*  nUR                  [        R                  :X  a   SnAGNe SnAff = f! , (       d  f       g= f)
a  Download Paddle's model weights (i.e., state_dict)
from the specified URL and extract the downloaded file if necessary

Args:
    url (str): URL of the object to download.
    model_dir (Optional[str], optional): Directory in which to save the object.
    check_hash (bool, optional): If True, the filename part of the URL should follow the naming convention filename-<sha256>.ext where <sha256> is the first eight or more digits of the SHA256 hash of the contents of the file. The hash is used to ensure unique names and to verify the contents of the file. Default: False.
    file_name (Optional[str], optional): Name for the downloaded file. Filename from URL will be used if not set.
    map_location (Optional[Literal["cpu", "gpu", "xpu", "npu", "numpy", "np"]], optional): Specifies how to remap storage locations. Default: None.

Returns:
    Any: A target object that can be used in Paddle.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.hub.load_state_dict_from_url(url='https://paddle-hapi.bj.bcebos.com/models/resnet18.pdparams', model_dir="./paddle/test_load_from_url")
        >>> paddle.hub.load_state_dict_from_url(url='https://x2paddle.bj.bcebos.com/resnet18.zip', model_dir="./paddle/test_file_is_zip")
NcheckpointszDownloading: "z" to rM   )cpugpuxpunpunumpynpr   r   Treturn_numpy)get_dirr   r   rR   makedirsOSErrorerrnoEEXISTr   basenamer   r'   rS   rT   r   _is_legacy_zip_format_legacy_zip_loadr   r   device_guard)ra   	model_dir
check_hash	file_namemap_locationr]   epartsrY   r`   hash_prefixs              r#   load_state_dict_from_urlr   Q  sx   : )GGLL-8	
I SMEww

+H'',,y3K77>>+&&

>#eK=CD$K#+.JJJJ --#KLII?*;;{>>l+{{;/ ,+ !--#K;;{{;'';  77ell"	0 ,+s)   F  G 
G*GGG
G%c                    [         R                  " U 5      (       aQ  [         R                  " U 5      R                  5       n[	        U5      S:H  =(       a    US   R                  5       (       + $ g)N   r   F)rV   
is_zipfilerW   rX   rr   is_dir)rY   rX   s     r#   r   r     sQ    (##??8,5578}!>(1+*<*<*>&>>r%   c                   [         R                  " U 5       nUR                  5       n[        U5      S:w  a  [	        S5      eUR                  U5        US   R                  n[        R                  R                  X5      nS S S 5        U(       aF  US;   a  [        R                  " WSS9$ [        U5         [        R                  " W5      sS S S 5        $ [        R                  " W5      $ ! , (       d  f       Nq= f! , (       d  f       g = f)Nr   z0Only one file(not dir) is allowed in the zipfiler   r   Tr   )rV   rW   rX   rr   r-   rZ   rY   r   r   rR   r   r   r   )rY   r   r   r~   membersextracted_nameextracted_files          r#   r   r     s    		"a**,w<1B  	
Y ,,i@ 
# ?*;;~DAAl+{{>2 ,+ {{>**! 
#	" ,+s   A*C,6C=,
C:=
Dc                     [         R                  " S5      (       a  [        R                  " S5        [         R                  R                  [        5       S5      $ )N
PADDLE_HUBz<PADDLE_HUB is deprecated, please use env PADDLE_HOME insteadr   )r   getenvwarningswarnr   rR   _get_paddle_homer5   r%   r#   r   r     s;    	yyJ	
 77<<(*E22r%   c                     [         R                  R                  [         R                  " S[         R                  R	                  [         R                  " SS5      S5      5      5      n U $ )NPADDLE_HOMEXDG_CACHE_HOMEr   r   )r   r   
expanduserr   rR   )paddle_homes    r#   r   r     sK    ''$$
		GGLL#3Z@(K	
K r%   c              #  0  #    [         R                  R                  5       nU S:X  a  [         R                  " U 5        O!U S;   a  [         R                  " U  SU 35         S v   [         R                  " U5        g ! [         R                  " U5        f = f7f)Nr   )r   r   r   r>   )r   device
get_device
set_device)r   dev_idorigin_devices      r#   r   r     sr     MM,,.M&!	(	(VHAfX./)-(-(s   AB A; $B;BB)Tr   )r   F)r/   r   r9   r   r[   boolreturnzbuiltins.list[str])r/   r   r9   r   r[   r   r   r   )r/   r   r   r   r9   r   r[   r   r   r
   r   zpaddle.nn.Layer)NFNN)ra   r   r   
str | Noner   r   r   r   r   z9Literal['cpu', 'gpu', 'xpu', 'npu', 'numpy', 'np'] | Noner   r
   r   )r   r   )3
__future__r   
contextlibr   r   r!   r'   r   rV   typingr   r   urllib.parser   typing_extensionsr   r   paddle.utils.downloadr   r	   builtinsr
   __all__r   __annotations__r   r   r   r   r   rR   r   r$   r1   r:   rB   rJ   rf   rn   rp   rv   r   r   r   r   r   r   r   r   contextmanagerr   r5   r%   r#   <module>r      s   #   	  
   ) ! '  >
78 8# 3 #$ $" "ww!!"'',,sHh"NO O  ])'4n
 /// / 	/j 	-- - 	-
 	-f 	000 0 	0
 0 0j !  	@(	@(@( @( 	@( 	B@( 	@(F+(3 	) 	)r%   