
    Ng!              
          d dl mZmZmZmZmZmZmZ d dlZd dl	Z	d dl
Z
d dlZd dlmZ  e
j        e          Zej        dk     rd dlZnd dlmZ ej                            d          duZ	  ej        d          Ze                    de d           n# ej        $ r dZY nw xY wej                            d	          duZ	  ej        d	          Ze                    d
e d           n# ej        $ r dZY nw xY wej                            d          duZ	  ej        d          Z e                    de  d           n# ej        $ r dZY nw xY wej                            d          duZ!	  ej        d          Z"e                    de" d           n# ej        $ r dZ"Y nw xY wej                            d          duZ#	  ej        d          Z$e                    de$ d           n# ej        $ r dZ#Y nw xY w	 ej                            d          duZ%	  ej        d          Z&e                    de& d           n# ej        $ r dZ%Y nw xY wn# e'$ r dZ%Y nw xY wd Z(d Z)d Z*d Z+d Z,d Z-d Z.dZ/dZ0dZ1d Z2d!Z3d"Z4 e5de(e/ffd	e*e0ffde+e1ffde,e2ffde-e3ffde.e4ffg          Z6d# Z7 G d$ d%e          Z8dS )&    )AnyBinaryIODictListOptionalTupleUnionN)
ModuleType)      torchzPyTorch version z available.F
detectron2zDetectron2 version z
 availablepaddlepaddlepaddlezPaddle version effdetzEffdet version pytesseractzPytesseract version zgoogle.cloud.visionzgoogle-cloud-visionz"Google Cloud Vision Utils version c                      t           S N)_torch_available     S/var/www/html/ai-engine/env/lib/python3.11/site-packages/layoutparser/file_utils.pyis_torch_availabler   \   s    r   c                  \    t                      rdd l} | j                                        S dS )Nr   F)r   r   cudais_available)r   s    r   is_torch_cuda_availabler   `   s2     z&&(((ur   c                      t           S r   )_detectron2_availabler   r   r   is_detectron2_availabler    i   s      r   c                      t           S r   )_paddle_availabler   r   r   is_paddle_availabler#   m       r   c                      t           S r   )_effdet_availabler   r   r   is_effdet_availabler'   q   r$   r   c                      t           S r   )_pytesseract_availabler   r   r   is_pytesseract_availabler*   u   s    !!r   c                      t           S r   )_gcv_availabler   r   r   is_gcv_availabler-   y   s    r   z
{0} requires the PyTorch library but it was not found in your environment. Checkout the instructions on the
installation page: https://pytorch.org/get-started/locally/ and follow the ones that match your environment.
a  
{0} requires the detectron2 library but it was not found in your environment. Checkout the instructions on the
installation page: https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md and follow the ones
that match your environment. Typically the following would work for MacOS or Linux CPU machines:
    pip install 'git+https://github.com/facebookresearch/detectron2.git@v0.4#egg=detectron2' 
z
{0} requires the PaddlePaddle library but it was not found in your environment. Checkout the instructions on the
installation page: https://github.com/PaddlePaddle/Paddle and follow the ones that match your environment.
z}
{0} requires the effdet library but it was not found in your environment. You can install it with pip:
`pip install effdet`
z
{0} requires the PyTesseract library but it was not found in your environment. You can install it with pip:
`pip install pytesseract`
z
{0} requires the Google Cloud Vision Python utils but it was not found in your environment. You can install it with pip:
`pip install google-cloud-vision==1`
c                    t          |t          t          f          s|g}t          | d          r| j        n| j        j        t          d |D                       s.t          d                    fd|D                                 d S )N__name__c              3   J   K   | ]}t          |         d                      V  dS )r   N)BACKENDS_MAPPING).0backends     r   	<genexpr>z$requires_backends.<locals>.<genexpr>   s3      FF'(+--FFFFFFr    c                 \    g | ](}t           |         d                                        )S )   )r1   format)r2   r3   names     r   
<listcomp>z%requires_backends.<locals>.<listcomp>   s2    WWW7%g.q188>>WWWr   )	
isinstancelisttuplehasattrr/   	__class__allImportErrorjoin)objbackendsr9   s     @r   requires_backendsrE      s    hu.. :"3
33O3<<9ODFFXFFFFF 
GGWWWWhWWWXX
 
 	

 
r   c                   R     e Zd ZdZ	 d fd	Z fdZdedefdZdefd	Z	d
 Z
 xZS )_LazyModulezu
    Module class that surfaces all objects but only performs associated imports when the objects are requested.
    Nc                 8   t                                          |           t          |                                          | _        i | _        |                                D ]\  }}|D ]}|| j        |<   t          |                                          t          |	                                g           z   | _
        || _        || _        t          j                            |          g| _        |i n|| _        || _        || _        | j        | _        d S r   )super__init__setkeys_modules_class_to_moduleitemsr<   sumvalues__all____file____spec__ospathdirname__path___objects_name_import_structurer/   __package__)
selfr9   module_fileimport_structuremodule_specextra_objectskeyrQ   valuer?   s
            r   rJ   z_LazyModule.__init__   s    	,113344 "+1133 	3 	3KC 3 3/2%e,,3 ,113344s##%%r8
 8
 
 $#556+3
!1
  =r   c                 T    t                                                      | j        z   S r   )rI   __dir__rR   )r]   r?   s    r   re   z_LazyModule.__dir__   s    ww  4<//r   r9   returnc                 ^   || j         v r| j         |         S || j        v r|                     |          }nf|| j                                        v r1|                     | j        |                   }t          ||          }nt          d| j         d|           t          | ||           |S )Nzmodule z has no attribute )	rY   rM   _get_modulerN   rL   getattrAttributeErrorr/   setattr)r]   r9   rc   modules       r   __getattr__z_LazyModule.__getattr__   s    4=  =&&4=  $$T**EET*//1111%%d&;D&ABBFFD))EE !R4=!R!RD!R!RSSSdE"""r   module_namec                 <    t          j        d|z   | j                  S )N.)	importlibimport_moduler/   )r]   rn   s     r   rh   z_LazyModule._get_module   s    &s['8$-HHHr   c                 8    | j         | j        | j        | j        ffS r   )r?   rZ   rS   r[   )r]   s    r   
__reduce__z_LazyModule.__reduce__   s    T]D<R STTr   )NN)r/   
__module____qualname____doc__rJ   re   strr   rm   rh   rt   __classcell__)r?   s   @r   rG   rG      s          TX) ) ) ) ) )40 0 0 0 0     Is I I I IU U U U U U Ur   rG   )9typingr   r   r   r   r   r   r	   sysrU   loggingimportlib.utilrq   typesr
   	getLoggerr/   loggerversion_infoimportlib_metadataimportlib.metadatametadatautil	find_specr   version_torch_versiondebugPackageNotFoundErrorr   _detectron2_versionr"   _paddle_versionr&   _effdet_versionr)   _pytesseract_versionr,   _gcv_versionModuleNotFoundErrorr   r   r    r#   r'   r*   r-   PYTORCH_IMPORT_ERRORDETECTRON2_IMPORT_ERRORPADDLE_IMPORT_ERROREFFDET_IMPORT_ERRORPYTESSERACT_IMPORT_ERRORGCV_IMPORT_ERRORdictr1   rE   rG   r   r   r   <module>r      sB  $ E D D D D D D D D D D D D D D D D D 



 				           		8	$	$ f333333 >++G44D@ /'/88N
LL?N???@@@@.    "00>>dJ "4,4\BB
LLF':FFFGGGG. " " "!" N,,X66dB  1(0@@O
LL?????@@@@.    N,,X66dB 0(0::O
LL?????@@@@.   OOO #11-@@L #5-5mDD
LLI(<IIIJJJJ. # # #"#
^--.CDDDPN1)1!
 
 	S,SSSTTTT2      NNN    ! ! !    " " "   
  
 
 
 
 4	%';<=	/1HIJ	')<=>	')<=>	13KLM	!13C DE	 	 
 
 
7U 7U 7U 7U 7U* 7U 7U 7U 7U 7Us   ,)B B%$B%)C/ /C>=C>)E EE7)F! !F0/F0)G: :H	H	I' *)I I' I# I' "I##I' 'I10I1