
    #
3j
                     b    S SK r S SKJr  S SKrS SKrS SKJr  S SKJr	  SSK
Jr   " S S\5      rg)    N)List)Image   )BaseSessionc                   P    \ rS rSrSrS\S\\   4S jr\S 5       r	\S 5       r
Srg	)
SiluetaSession   z5This is a class representing a SiluetaSession object.imgreturnc           	         U R                   R                  SU R                  USSS5      5      nUS   SS2SSS2SS24   n[        R                  " U5      n[        R
                  " U5      nXW-
  Xg-
  -  n[        R                  " U5      n[        R                  " US-  R                  S5      SS	9nUR                  UR                  [        R                  R                  5      nU/$ )
a  
Predict the mask of the input image.

This method takes an image as input, preprocesses it, and performs a prediction to generate a mask. The generated mask is then post-processed and returned as a list of PILImage objects.

Parameters:
    img (PILImage): The input image to be processed.
    *args: Variable length argument list.
    **kwargs: Arbitrary keyword arguments.

Returns:
    List[PILImage]: A list of post-processed masks.
N)g
ףp=
?gv/?gCl?)gZd;O?gy&1?g?)@  r   r      uint8L)mode)inner_sessionrun	normalizenpmaxminsqueezer   	fromarrayastyperesizesize
ResamplingLANCZOS)	selfr
   argskwargsort_outspredmamimasks	            P/home/wildlama/miniconda3/lib/python3.13/site-packages/rembg/sessions/silueta.pypredictSiluetaSession.predict   s     %%))NN*,A:
 {1aA:&VVD\VVD\	bg&zz$s
227;#F{{388U%5%5%=%=>v    c           
      
   U R                  5        S3n[        R                  " SU R                  " U0 UD6(       a  SOSUU R                  " U0 UD6SS9  [
        R                  R                  U R                  " U0 UD6U5      $ )a9  
Download the pre-trained model file.

This method downloads the pre-trained model file from a specified URL. The file is saved to the U2NET home directory.

Parameters:
    *args: Variable length argument list.
    **kwargs: Arbitrary keyword arguments.

Returns:
    str: The path to the downloaded model file.
z.onnxzJhttps://github.com/danielgatis/rembg/releases/download/v0.0.0/silueta.onnxNz$md5:55e59e0d8062d2f5d013f4725ee84782T)fnamepathprogressbar)namepoochretrievechecksum_disabled
u2net_homeosr-   join)clsr    r!   r,   s       r'   download_modelsSiluetaSession.download_models1   s~     88:,e$X (($9&9 ;00
	
 ww||CNND;F;UCCr*   c                     g)z
Return the name of the model.

This method returns the name of the Silueta model.

Parameters:
    *args: Variable length argument list.
    **kwargs: Arbitrary keyword arguments.

Returns:
    str: The name of the model.
silueta )r6   r    r!   s      r'   r/   SiluetaSession.nameN   s     r*   r;   N)__name__
__module____qualname____firstlineno____doc__PILImager   r(   classmethodr7   r/   __static_attributes__r;   r*   r'   r   r      sG    ? 8  h  D D D8  r*   r   )r4   typingr   numpyr   r0   PILr   	PIL.ImagerB   baser   r   r;   r*   r'   <module>rJ      s(    	     ' P[ Pr*   