
    %j<                         d Z ddlZddlZddlZddlZddlZddlmZ ddlm	Z	m
Z
mZmZmZmZmZmZ ddlZddlmZ ddlZddlmZ ddlmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z% dZ& G d d	          Z'dS )
zMagika (the Python library).

This module provides the `Magika` class, the main entry point for using Magika
to identify file content types.
    N)Path)BinaryIODictListOptionalSequenceSetTupleUnion)
get_logger)ContentTypeInfoContentTypeLabelMagikaErrorMagikaPredictionMagikaResultModelConfigModelFeaturesModelOutputOverwriteReasonPredictionModeSeekableStatusstandard_v3_3c                      e Zd ZdZdej        ddddfdee         dedededed	ed
dfdZ	d
e
fdZd
e
fdZd
e
fdZd
e
fdZdee
ej        f         d
efdZdeee
ej        f                  d
ee         fdZded
efdZded
efdZd
ee         fdZd
ee         fdZed
e
fd            Zeded
e ee!f         fd            Z"eded
e#fd            Z$d
e%j&        fdZ'd ed
e!fd!Z(dee         d
ee         fd"Z)ded
efd#Z*d$e+d
efd%Z,ed$e+d&e-d'e-d(e-d)e-d*e-d+ed
e.fd,            Z/ed-ed&e-d)e-d
ee-         fd.            Z0ed/ed(e-d)e-d
ee-         fd0            Z1d1ee2ee.f                  d
ee2ee3f                  fd2Z4d1ee2ee.f                  d
e e
ef         fd3Z5d4ed5e6d
e2ee7f         fd6Z8e7j9        fded4ed7ed5e6d8e7d
efd9Z:ded
e2ee         ee.         f         fd:Z; ed;          fd$e+ded
e2ee         ee.         f         fd<Z< ed;          fdeded
efd=Z=ded
efd>Z>d?ee2ee.f                  d
e?j@        fd@ZAdS )AMagikazMain Magika class for content type identification.

    This class provides methods to identify the content type of files, bytes,
    and streams.
    NF	model_dirprediction_modeno_dereferenceverbosedebug
use_colorsreturnc                    t          |          | _        |r$| j                            t          j                   |r$| j                            t          j                   ||| _        n6t          t                    j	        dz  | 
                                z  | _        | j        dz  | _        | j        dz  | _        | j                                        s$t          dt          | j                             | j                                        s$t          dt          | j                             | j                                        s$t          dt          | j                             t"                              | j                  | _        t)          j        t-          t/          t          | j        j                                      | _        || _        || _        t          t                    j	        d	z  d
z  }t"                              |          | _        |                                 | _        dS )ai  Initializes the Magika instance.

        Args:
            model_dir: Path to the directory containing the model and its
                configuration. If None, the default model is used.
            prediction_mode: The prediction mode to use.  Defaults to
                PredictionMode.HIGH_CONFIDENCE.
            no_dereference: If True, do not follow symlinks.  Defaults to False.
            verbose: If True, enable verbose logging. Defaults to False.
            debug: If True, enable debug logging. Defaults to False.
            use_colors: If True, use colors in the logger.  Defaults to False.
        )r!   Nmodelsz
model.onnxzconfig.min.jsonzmodel dir not found at zmodel not found at zmodel config not found at configzcontent_types_kb.min.json) r   _logsetLevelloggingINFODEBUG
_model_dirr   __file__parent_get_default_model_name_model_path_model_config_pathis_dirr   stris_filer   _load_model_config_model_confignparraylistmaptarget_labels_space_target_labels_space_np_prediction_mode_no_dereference_load_content_types_kb
_cts_infos_init_onnx_session_onnx_session)selfr   r   r   r   r    r!   content_types_kb_paths           U/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/magika/magika.py__init__zMagika.__init__;   s   * *555	 	-Iw|,,, 	.Iw}--- 'DOO X%043O3O3Q3QQ O  ?\9"&/4E"E%%'' 	PNDO8L8LNNOOO'')) 	MKC8H4I4IKKLLL&..00 	KS1H-I-IKK   +1*C*C#+
 +
 (*xS$,@AABB(
 (
$ !0- NN!H,/JJ 	 !778MNN!4466    c                      t          |           S N)r2   rB   s    rD   __repr__zMagika.__repr__   s    4yyrF   c                 \    d|                                   d|                                  dS )NzMagika(module_version="z", model_name="z"))get_module_versionget_model_namerI   s    rD   __str__zMagika.__str__   s4    l)@)@)B)BllSWSfSfShShllllrF   c                 N    t          t          | j                  j                  S )z-Gets the version of the Magika Python module.)r2   
__import__
__module____version__rI   s    rD   rL   zMagika.get_module_version   s    :do..:;;;rF   c                     | j         j        S )z"Gets the name of the loaded model.)r+   namerI   s    rD   rM   zMagika.get_model_name   s    ##rF   pathc                     t          |t                    st          |t          j                  rt	          |          }nt          d| d          |                     |          S )z3Identify the content type of a file given its path.zPath 'D' is invalid: input path should be of type `Union[str, os.PathLike]`)
isinstancer2   osPathLiker   	TypeError_get_result_from_pathrB   rU   s     rD   identify_pathzMagika.identify_path   sj    dC   	JtR[$A$A 	::DDcccc   ))$///rF   pathsc                 J   t          |t                    st          d          g }|D ]f}t          |t                    st          |t          j                  r#|                    t          |                     Tt          d| d          |                     |          S )z?Identify the content type of a list of files given their paths.z,Input paths should be of type Sequence[Path]zInput 'rW   )	rX   r   r[   r2   rY   rZ   appendr   _get_results_from_paths)rB   r_   paths_rU   s       rD   identify_pathszMagika.identify_paths   s     %** 	LJKKK 	 	D$$$ 
4(E(E d4jj))))hdhhh   ++F333rF   contentc                     t          |t                    s t          dt          |           d          |                     t          t          j        |                              S )z'Identify the content type of raw bytes.z-Input content should be of type 'bytes', not .)rX   bytesr[   type_get_result_from_seekabler   ioBytesIO)rB   re   s     rD   identify_byteszMagika.identify_bytes   sb    '5)) 	PWPPP   --hrz'7J7J.K.KLLLrF   streamc                 p   t          |t          j                  r|                                st	          d          t          |t          j                  rt	          d          t          |t          j                  st	          d          t          |d          r t          |d          rt          |d          st	          d          	 |                                }| 	                    t          |                    }|                    |           n# |                    |           w xY w|S )aR  Identify the content type of a BinaryIO stream.

        Identifies the content type from an already-open binary file-like object
        (e.g., the output of `open(file_path, 'rb')`). Note: 1) Magika will
        `seek()` around the stream; 2) the stream _is not closed_ (closing it is
        the responsibility of the caller).
        z0Input stream must be a readable BinaryIO object.z<Input stream must be opened in bytes mode, not in text mode.seekreadtellz4Input stream must have seek, read, and tell methods.)rX   rk   IOBasereadabler[   
TextIOBaseBufferedIOBasehasattrrr   rj   r   rp   )rB   rn   current_positionresults       rD   identify_streamzMagika.identify_stream   s>    &"),, 	PFOO4E4E 	PNOOO fbm,, 	N   &""344 	PNOOO ''	T66**	T 66**	T
 RSSS	*%{{}}33HV4D4DEEF KK())))FKK())))s   6D D3c                 "   | j         j        }| j         j        }t          j        t          j        t          j        t          j        t          j        h}|D ]-}|	                    ||          }|
                    |           .t          |          S )a  This method returns the list of all possible output content types.

        I.e., all possible values for `MagikaResult.prediction.output.label`.
        This considers the list of possible outputs from the model itself, but
        also keeps into account additional configuration such as `override_map`
        and special content types such as `empty` or `symlink`.

        Consult the documentation for more details.
        )r5   r:   overwrite_mapr   	DIRECTORYEMPTYSYMLINKTXTUNKNOWNgetaddsorted)rB   r:   r|   output_content_typesct	output_cts         rD   get_output_content_typeszMagika.get_output_content_types   s     #0D*8 &"$ $7
 & 	0 	0B &))"b11I $$Y////*+++rF   c                 x    t           j        h}|                    | j        j                   t          |          S )aD  This method returns the list of all possible output of the model.

        I.e., all possible values for `MagikaResult.prediction.dl.label`. Note
        that, in general, the list of "model outputs" is different than the
        "tool outputs" as in some cases the model is not even used, or the
        model's output is overwritten due to a low-confidence score, or other
        reasons. This API is useful mostly for debugging purposes; the vast
        majority of client should use `get_output_content_types()`.

        Consult the documentation for more details.
        )r   	UNDEFINEDupdater5   r:   r   )rB   model_content_typess     rD   get_model_content_typeszMagika.get_model_content_types   s=     &6
 	""4#5#IJJJ)***rF   c                      t           S )zReturns the default model name.

        This method is static so that it can be used by external clients/tests
        without the need to instantiate a Magika object.
        )_DEFAULT_MODEL_NAME rF   rD   r.   zMagika._get_default_model_name  s
     #"rF   content_types_kb_json_pathc           	         d}d}d}i }t          j        |                                                                           D ]\  }}|d         }|r|}n|}|d         |n|d         }	|d         |n|d         }
|d         |n|d         }|d         }t	          t          |          |	|
|||	          |t          |          <   |S )
Nz
text/plainzapplication/octet-streamunknownis_text	mime_typegroupdescription
extensions)labelr   r   r   r   r   )jsonloads	read_textitemsr   r   )r   TXT_MIME_TYPEUNKNOWN_MIME_TYPEUNKNOWN_GROUPoutct_namect_infor   default_mime_typer   r   r   r   s                rD   r>   zMagika._load_content_types_kb  s    %6! $
&0022!
 !

%''	 	GW i(G 6$1!!$5! ;'/ "![) 
 &-W%5%=MM77CSE"=19w}?U  !.J-<&w//#'%. . .C ))** 
rF   model_config_pathc                    t          j        |                                           }t          |d         |d         |d         |d         |d         |d         |d         |d         d	 |d
         D             d |d                                         D             d |d                                         D                       S )Nbeg_sizemid_sizeend_sizeuse_inputs_at_offsetsmedium_confidence_thresholdmin_file_size_for_dlpadding_token
block_sizec                 ,    g | ]}t          |          S r   r   ).0ct_strs     rD   
<listcomp>z-Magika._load_model_config.<locals>.<listcomp>@  s.     ! ! !-3 ((! ! !rF   r:   c                 4    i | ]\  }}t          |          |S r   r   r   kvs      rD   
<dictcomp>z-Magika._load_model_config.<locals>.<dictcomp>C  s4       +/1a ##Q  rF   
thresholdsc                 N    i | ]"\  }}t          |          t          |          #S r   r   r   s      rD   r   z-Magika._load_model_config.<locals>.<dictcomp>F  s?       Aq !##%5a%8%8  rF   r|   )r   r   r   r   r   r   r   r   r:   r   r|   )r   r   r   r   r   )r   r%   s     rD   r4   zMagika._load_model_config3  s    -7799::J'J'J'"()@"A(./L(M!'(>!? 1l+! !7=>S7T! ! ! 39,3G3M3M3O3O   "?399;;  
 
 
 	
rF   c                 
   t          j                     }t          j                     t          j        | j        dg          }dt          j                     |z
  z  }| j                            d| j         d|dd           |S )NCPUExecutionProvider)	providers  zONNX DL model "z" loaded in .03f ms)timertdisable_telemetry_eventsInferenceSessionr/   r&   r    )rB   
start_timeonnx_sessionelapsed_times       rD   r@   zMagika._init_onnx_sessionL  s    Y[[

#%%%*-.
 
 
 ty{{Z78	Rd.RRLRRRR	
 	
 	
 rF   content_typec                     | j         |         S rH   )r?   )rB   r   s     rD   _get_ct_infozMagika._get_ct_infoZ  s    |,,rF   c                 V   i }g }| j                             dt          |           d           t          j                    }|D ]J}|                     |          \  }}|||t          |          <   /|J |                    ||f           Kdt          j                    |z
  z  }| j                             d|dd           |                     |                                          D ]
\  }	}
|
||	<   g }|D ]*}|                    |t          |                              +|S )ao  Get results for a list of paths.

        Given a list of paths, returns a list of MagikaResult objects, which
        contain relevant information, such as: file path, the output of the DL
        model, the confidence score, the output of the tool, and associated
        metadata. The order of the predictions matches the order of the input
        paths.
        z3Processing input files and extracting features for z samplesNr   z%First pass and features extracted in r   r   )	r&   r    lenr   !_get_result_or_features_from_pathr2   ra   _get_results_from_featuresr   )rB   r_   all_outputsall_featuresr   rU   outputfeaturesr   path_strry   sorted_outputss               rD   rb   zMagika._get_results_from_paths]  sd    02 :<	V#e**VVV	
 	
 	
 Y[[
 	6 	6D#EEdKKFH!)/CII&&+++##T8$45555ty{{Z78	VVVVVWWW !% ? ? M M S S U U 	+ 	+Hf$*K!!  	: 	:D!!+c$ii"89999rF   c                 :    |                      |g          d         S )Nr   )rb   r]   s     rD   r\   zMagika._get_result_from_path  s    ++TF33A66rF   seekablec                     |                      |          \  }}||S |J |                     t          d          |fg          d         S )N-)%_get_result_or_features_from_seekabler   r   )rB   r   ry   r   s       rD   rj   z Magika._get_result_from_seekable  sX    EEhOOM###..cH0E/FGGLLrF   r   r   r   r   r   r   c           	         ||k     sJ |dk    sJ ||k     sJ |rJ t          || j                  }|dk    rG|                     d|          }|                                }t                              |||          }	ng }	|dk    rO|                     | j        |z
  |          }
|
                                }
t                              |
||          }ng }t          |	g |g g g g           S )a  Extract features from an input seekable.

        This implements features extraction v2 from a seekable, which is an
        abstraction about anything that has a size and that can be "read_at" a
        specific offset, such as a file or a buffer. This is implemented so that
        we do not need to load the entire file in memory or scan the entire
        buffer.

        High-level overview on what we do:
        - We read (at most) `block_size` bytes from the beginning and from the
        end.
        - We normalize these bytes by stripping whitespaces.
        - We consider `beg_size` and `end_size` bytes as `beg` and `end`
        features. If we don't have enough bytes, we use `padding_token` as
        padding.

        See comments below for the specifics and handling of corner cases.

        NOTE: This implementation does not support extraction of `mid` features
        and `use_inputs_at_offsets`.
        r   )begmidendoffset_0x8000_0x8007offset_0x8800_0x8807offset_0x9000_0x9007offset_0x9800_0x9807)	minsizeread_atlstripr   _get_beg_ints_with_paddingrstrip_get_end_ints_with_paddingr   )r   r   r   r   r   r   r   bytes_num_to_readbeg_contentbeg_intsend_contentend_intss               rD   _extract_features_from_seekablez&Magika._extract_features_from_seekable  s<   > *$$$$1}}}}*$$$$((((  
HM::a<<
 #**1.?@@K%,,..K88X} HH Ha<< #** 113D K &,,..K88X} HH H!#!#!#!#
 
 
 	
rF   r   c                    |t          |           k     r
| d|         } t          t          t          |                     }t          |          |k     r||g|t          |          z
  z  z   }t          |          |k    sJ |S )a  Take an (already-stripped) buffer as input and extract beg ints.

        This returns a list of integers whose length is exactly beg_size. If
        the buffer is bigger than required, take only the initial portion. If
        the buffer is shorter, add padding at the end.
        r   r   r8   r9   int)r   r   r   r   s       rD   r   z!Magika._get_beg_ints_with_padding  s     c+&&&&%aj1KC--..x==8##M?hX6N#OPH8}}((((rF   r   c                 @   |t          |           k     r'| t          |           |z
  t          |                    } t          t          t          |                     }t          |          |k     r|g|t          |          z
  z  |z   }t          |          |k    sJ |S )a  Take an (already-stripped) buffer as input and extract end ints.

        This returns a list of integers whose length is exactly end_size. If the
        buffer is bigger than required, take only the last portion. If the
        buffer is shorter, add padding at the beginning.
        r   )r   r   r   r   s       rD   r   z!Magika._get_end_ints_with_padding  s     c+&&&&%c+&6&6&ACDTDT&TUKC--..x==8##&8c(mm+CDPH8}}((((rF   r   c                     |                      |          }t          j        |d          }| j        |         }t          j        |d          }d t          |||          D             S )N   )axisc           	      v    g | ]6\  \  }}}}|t          t          |          t          |                     f7S ))r   score)r   r   float)r   rU   _r   r   s        rD   r   z;Magika._get_model_outputs_from_features.<locals>.<listcomp>  sS     
 
 
'	q5% ;%5e%<%<E%LLQQQR
 
 
rF   )_get_raw_predictionsr6   argmaxr;   maxzip)rB   r   	raw_predstop_preds_idxspreds_content_types_labelsscoress         rD    _get_model_outputs_from_featuresz'Magika._get_model_outputs_from_features  s     --l;;	91555%)%A.%Q"	***
 
+.8&, ,
 
 
 	
rF   c                    t          |          dk    ri S i }|                     |          D ]\\  }}|                     |j        |j                  \  }}|                     ||j        ||j        |          |t          |          <   ]|S )Nr   )rU   dl_labeloutput_labelr   overwrite_reason)r   r  )_get_output_label_from_dl_label_and_scorer   r   !_get_result_from_labels_and_scorer2   )rB   r   resultsrU   model_outputr  r  s          rD   r   z!Magika._get_results_from_features"  s    
 |!!I+-"&"G"G"U"U 	 	D, >> &(:  +L* "&!G!G%+)"(!1 "H " "GCII rF   r  r   c                 (   t           j        }| j        j                            ||          }||k    rt           j        }| j        t          j        k    rn| j        t          j	        k    r/|| j        j
                            || j        j                  k    rnw| j        t          j        k    r|| j        j        k    rnQt           j        }|                     |          j        rt           j        }nt           j        }||k    rt           j        }||fS rH   )r   NONEr5   r|   r   OVERWRITE_MAPr<   r   
BEST_GUESSHIGH_CONFIDENCEr   r   MEDIUM_CONFIDENCELOW_CONFIDENCEr   r   r   r   r   )rB   r  r   r  r  s        rD   r  z0Magika._get_output_label_from_dl_label_and_scoreD  s    +/ )7;;HhOO8##.<  N$=== !^%CCC!,00$,H   !^%EEE+GGG
   /=  ..6 8/3/7<''
 $3#7 ---rF   r  r  c           	          t          |t          |                     |          |                     |          ||                    S )N)dlr   r   r  )rU   
prediction)r   r   r   )rB   rU   r  r  r   r  s         rD   r  z(Magika._get_result_from_labels_and_score~  sX     '$$X..((66!1	  
 
 
 	
rF   c                 >   | j         rE|                                r1|                     |t          j        t          j        d          }|dfS |                                st          |t          j	                  dfS |
                                rt          j        |t          j                  st          |t          j                  dfS t          |d          5 }|                     t#          |          |          cddd           S # 1 swxY w Y   nv|                                r1|                     |t          j        t          j        d          }|dfS |                     |t          j        t          j        d          }|dfS t+          d          )a  Given a path, we return either a MagikaOutput or a MagikaFeatures.

        There are some files and corner cases for which we do not need to use
        deep learning to get the output; in these cases, we already return a
        MagikaOutput object.

        For some other files, we do need to use deep learning, in which case we
        return a MagikaFeatures object. Note that for now we just collect the
        features instead of already performing inference because we want to use
        batching.
              ?rU   r  r  r   N)rU   statusrbunreachable)r=   
is_symlinkr  r   r   r   existsr   r   FILE_NOT_FOUND_ERRORr3   rY   accessR_OKPERMISSION_ERRORopenr   r   r1   r}   r   	Exception)rB   rU   ry   rn   s       rD   r   z(Magika._get_result_or_features_from_path  s     	 DOO$5$5 	 ;;)3-5	 <  F 4<{{}} 	UT&2MNNNPTTT<<>> 	 9T27++ 	#f6MNNNPTTT
 $%% EE (($                 
 [[]] 	 ;;)3-7	 <  F 4< ;;)3-5	 <  F 4<&&&s   #DDDr   c           	         |j         dk    r1|                     |t          j        t          j        d          }|dfS |j         | j        j        k     r6|                    d|j                   }|                     ||          }|dfS t          
                    || j        j        | j        j        | j        j        | j        j        | j        j        | j        j                  }|j        | j        j        dz
           | j        j        k    rPt%          |j         | j        j                  }|                    d|          }|                     ||          }|dfS d|fS )ag  Get result or features from a seekable object.

        Given a Seekable object (which is a wrapper of BinaryIO), we return
        either a MagikaOutput or a MagikaFeatures.

        There are some corner cases for which we do not need to use deep
        learning to get the output; in these cases, we return directly a
        MagikaOutput object.

        For all other cases, we do need to use deep learning, in which case we
        return a MagikaFeatures object. Note that for now we just collect the
        features instead of already performing inference because we want to use
        batching.
        r   r  r  N)rU   r   )r   r  r   r   r~   r5   r   r   _get_result_from_few_bytesr   r   r   r   r   r   r   r   r   r   r"  )rB   r   rU   ry   re   file_featuresbytes_to_reads          rD   r   z,Magika._get_result_or_features_from_seekable  sm   " =A;;)3-3	 <  F 4<]T/DDD&&q(-88G44W44HHF4< #BB"+"+"+"0"-"8 M !$"4"IA"MN%34 4 !$HM43E3P Q Q"**1m<<88t8LLt|#
 ]**rF   c                     t          |          d| j        j        z  k    sJ |                     |          }|                     |t
          j        |d          S )N   r  r  )r   r5   r   _get_label_from_few_bytesr  r   r   )rB   re   rU   r   s       rD   r$  z!Magika._get_result_from_few_bytes  se     7||q4#5#@@@@@@..w7755%/	 6 
 
 	
rF   c                     	 t           j        }|                    d          }n# t          $ r t           j        }Y nw xY w|S )Nzutf-8)r   r   decodeUnicodeDecodeErrorr   )rB   re   r   r   s       rD   r)  z Magika._get_label_from_few_bytes  sN    	-$(Ew''AA! 	- 	- 	-$,EEE	-s   !$ ==r   c           	         t          j                     }g }|D ]\  }}g }| j        j        dk    r,|                    |j        d| j        j                            | j        j        dk    r,|                    |j        d| j        j                            | j        j        dk    r-|                    |j        | j        j         d                    |	                    |           t          j        |t          j                  }dt          j                     |z
  z  }| j                            d|dd           g }	|j        d         }
d}|
|z  }|
|z  dk    r|dz  }t!          |          D ]}| j                            d	|dz    d
|            ||z  }t#          |dz   |z  |
          }t          j                     }| j                            dgd|||ddf         i          d         }dt          j                     |z
  z  }| j                            d|dd           |		                    |           t          j        |	          S )zGet raw predictions from features.

        Given a list of (path, features), return a (files_num, features_size)
        matrix encoding the predictions.
        r   N)dtyper   zDL input prepared in r   r   r   z-Getting raw predictions for (internal) batch /target_labelrh   zDL raw prediction in )r   r5   r   extendr   r   r   r   r   ra   r6   r7   int32r&   r    shaperanger   rA   runconcatenate)rB   r   r   X_bytesr   fssample_bytesXr   raw_predictions_listsamples_nummax_internal_batch_sizebatches_num	batch_idx	start_idxend_idxbatch_raw_predictionss                    rD   r   zMagika._get_raw_predictions  s    Y[[
 	) 	)EArL!*Q..##BF+HT-?-H+H$IJJJ!*Q..##BF+HT-?-H+H$IJJJ!*Q..##BFD,>,G+G+I+I$JKKKNN<((((HWBH---ty{{Z78	FFFFFGGG!gaj"&!%<<00A551K{++ 	? 	?IIOO[	![[k[[   "$;;I9q=,CC[QQGJ$($6$:$: 7Ai.?.B,C"D% %%!  49;;#;<LIOOJLJJJJKKK ''(=>>>>~2333rF   )B__name__rQ   __qualname____doc__r   r  r   r   boolrE   r2   rJ   rN   rL   rM   r   rY   rZ   r   r^   r   r   rd   rh   rm   r   rz   r   r   r   staticmethodr.   r   r   r>   r   r4   r   r   r@   r   rb   r\   r   rj   r   r   r   r   r   r
   r   r  r   r   r   r  r  r  r   r   r$  r)  nptNDArrayr   r   rF   rD   r   r   4   s         %)*8*H$ B7 B7D>B7 (B7 	B7
 B7 B7 B7 
B7 B7 B7 B7H#    m m m m m<C < < < <$ $ $ $ $	0%R[(8"9 	0l 	0 	0 	0 	04eC$4564	l	4 4 4 4$Me M M M M M"h "< " " " "H,$/?*@ , , , ,8+.>)? + + + +$ #S # # # \# "$("	/	0" " " \"H 
d 
{ 
 
 
 \
0B$7    -)9 -o - - - -,T$Z ,D<N , , , ,\7$ 7< 7 7 7 7M( M| M M M M K
K
K
 K
 	K

 K
 K
  $K
 
K
 K
 K
 \K
Z &):=	c   \. &):=	c   \.
 t]':!;<
	eD+%&	'
 
 
 
  t]':!;< 	c<	        D8.(8.168.	0	18. 8. 8. 8.@ -<,@
 

 #
 '	

 
 *
 

 
 
 
$8'8'	x%x'>>	?8' 8' 8' 8'v 04tCyy<' <' <'(,<'	x%x'>>	?<' <' <' <'~ ,0499

 



$(

	

 

 

 

 ;K    .4U4#678.4	.4 .4 .4 .4 .4 .4rF   r   )(rE  rk   r   r(   rY   r   pathlibr   typingr   r   r   r   r   r	   r
   r   numpyr6   numpy.typingrH  onnxruntimer   magika.loggerr   magika.typesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rF   rD   <module>rQ     s    
			   				        N N N N N N N N N N N N N N N N N N N N               $ $ $ $ $ $                            & V4 V4 V4 V4 V4 V4 V4 V4 V4 V4rF   