+
    Ci                     d    ^ RI t ^ RIHt ^ RIt^ RIt^ RIHt ^ RI	Ht
 ^RIHt  ! R R]4      tR# )    N)List)Image)BaseSessionc                   t   a a ] tR t^t oRtV3R lV 3R lltV3R lR lt]R 4       t]R 4       t	Rt
VtV ;t# )	DisCustomSessionz@This is a class representing a custom session for the Dis model.c                :   < V ^8  d   QhRS[ RS[P                  /# )   
model_name	sess_opts)strortSessionOptions)format__classdict__s   "W/var/www/html/photoedit/myenv/lib/python3.14/site-packages/rembg/sessions/dis_custom.py__annotate__DisCustomSession.__annotate__   s%     A A3 A33E3E A    c                p   < VP                  R4      pVf   \        R4      h\        SV `  ! W.VO5/ VB  R# )z
Initialize a new DisCustomSession object.

Parameters:
    model_name (str): The name of the model.
    sess_opts: The session options.
    *args: Additional positional arguments.
    **kwargs: Additional keyword arguments.

model_pathNmodel_path is required)get
ValueErrorsuper__init__)selfr
   r   argskwargsr   	__class__s   &&&*, r   r   DisCustomSession.__init__   s<     ZZ-
566@@@r   c                6   < V ^8  d   QhRS[ RS[S[ ,          /# )r	   imgreturn)PILImager   )r   r   s   "r   r   r      s      8 h r   c           	        V P                   P                  RV P                  VRRR4      4      pV^ ,          R,          p\        P                  ! V4      p\        P
                  ! V4      pWW,
          Wg,
          ,          p\        P                  ! V4      p\        P                  ! V^,          P                  R4      RR7      pVP                  VP                  \        P                  P                  4      pV.# )	al  
Predicts the mask image for the input image.

This method takes a PILImage object as input and returns a list of PILImage objects as output. It performs several image processing operations to generate the mask image.

Parameters:
    img (PILImage): The input image.

Returns:
    List[PILImage]: A list of PILImage objects representing the generated mask image.
Nuint8L)mode)      ?r)   r)   )      ?r*   r*   )   r+   )NNNr   r,   r,   )inner_sessionrun	normalizenpmaxminsqueezer   	fromarrayastyperesizesize
ResamplingLANCZOS)	r   r"   r   r   ort_outspredmamimasks	   &&*,     r   predictDisCustomSession.predict   s     %%))NN3,O

 {:&VVD\VVD\	bg&zz$s
227;#F{{388U%5%5%=%=>vr   c                   VP                  R4      pVf   \        R4      h\        P                  P	                  \        P                  P                  V4      4      p\        P                  P	                  \        P                  P                  V P                  4       4      4      pVP                  V\        P                  ,           4      '       g   WE8w  d   \        RV 24      hV# )z
Download the model files.

Parameters:
    *args: Additional positional arguments.
    **kwargs: Additional keyword arguments.

Returns:
    str: The absolute path to the model files.
r   r   z0model_path must be within the models directory: )	r   r   ospathabspath
expanduser
u2net_home
startswithsep)clsr   r   r   abs_pathallowed_dirs   &*,   r   download_models DisCustomSession.download_models=   s     ZZ-
56677??277#5#5j#ABggoobgg&8&89I&JK"";#788X=TB;-P  r   c                    R# )z
Get the name of the model.

Parameters:
    *args: Additional positional arguments.
    **kwargs: Additional keyword arguments.

Returns:
    str: The name of the model.

dis_custom )rI   r   r   s   &*,r   nameDisCustomSession.nameU   s     r   rP   )__name__
__module____qualname____firstlineno____doc__r   r?   classmethodrL   rQ   __static_attributes____classdictcell____classcell__)r   r   s   @@r   r   r      sK     JA A  <  .   r   r   )rB   typingr   numpyr0   onnxruntimer   PILr   	PIL.Imager$   baser   r   rP   r   r   <module>rb      s(    	     ' U{ Ur   