
    #
3j8	                     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	)

DisSession   z7
This class represents a session for object detection.
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	  
Use a pre-trained model to predict the object in the given image.

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

Returns:
    List[PILImage]: A list of predicted mask images.
N)g
ףp=
?gv/?gCl?)      ?r   r   )   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	            R/home/wildlama/miniconda3/lib/python3.13/site-packages/rembg/sessions/dis_anime.pypredictDisSession.predict   s     %%))NN3 5U

 {1aA:&VVD\VVD\	bg&zz$s
227;#F{{388U%5%5%=%=>v    c           
         U R                   " U0 UD6 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      $ )z
Download the pre-trained models.

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

Returns:
    str: The path of the downloaded model file.
z.onnxzNhttps://github.com/danielgatis/rembg/releases/download/v0.0.0/isnet-anime.onnxNz$md5:6f184e756bb3bd901c8849220a83e38eT)fnamepathprogressbar)namepoochretrievechecksum_disabled
u2net_homeosr.   join)clsr!   r"   r-   s       r(   download_modelsDisSession.download_models/   s     88T,V,-U3\ (($9&9 ;00
	
 ww||CNND;F;UCCr+   c                     g)z
Get the name of the pre-trained model.

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

Returns:
    str: The name of the pre-trained model.
zisnet-anime )r7   r!   r"   s      r(   r0   DisSession.nameJ   s     r+   r;   N)__name__
__module____qualname____firstlineno____doc__PILImager   r)   classmethodr8   r0   __static_attributes__r;   r+   r(   r   r      sH    8 h < D D4  r+   r   )r5   typingr   numpyr   r1   PILr   	PIL.ImagerB   baser   r   r;   r+   r(   <module>rJ      s(    	     ' J Jr+   