+
    CiL/                     4   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHtHtHt ^ RI	H
t
 ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHtHtHtHtHtHt ^ RIHt ^ RIHt ^RIHt ^R	IH t  ^R
I!H"t" ^RI#H$t$ ^RI%H&t& ]PN                  ! RRR7      ]PP                  ! RRR])RRR7      ]PP                  ! RRR]*RRR7      ]PP                  ! RRR]*RRR7      ]PP                  ! RRR])RR R7      ]PP                  ! R!RR"RR#R$7      R% R& l4       4       4       4       4       4       t+R# )'    N)OptionalTuplecast)urlparseasyncify)DependsFastAPIFileFormHTTPExceptionQuery)CORSMiddleware)Response)__version__)remove)new_session)sessions_names)BaseSessionszfor a http server)namehelpz-pz--portiX  Tport)defaulttypeshow_defaultr   z-hz--host0.0.0.0hostz-lz--log_levelinfoz	log levelz-tz	--threadsznumber of worker threadsz--no-uiFz.disable the Gradio UI (reduces idle CPU usage))is_flagr   r   r   c                X    V ^8  d   QhR\         R\        R\        R\         R\        RR/# )   r   r   	log_levelthreadsno_uireturnN)intstrbool)formats   "V/var/www/html/photoedit/myenv/lib/python3.14/site-packages/rembg/commands/s_command.py__annotate__r,   D   s?     r rC rs rs rS r rRV r    c                  a aaaaaaa / oRRRRRRRRR//.p\        R	R
\        RRRRRR/RRRR/VRR7      pVP                  \        RR.R.R.R7        ! R R4      o ! R R4      oV3R lV3R lloVP	                  R4      V V3R l4       pR R loR  V3R! lloVP                  R"R.R#R$R%7      \        R&R'R(7      \        4       3V3R) lVV3R* lll4       pVP                  R"R.R+R,R%7      \        R&R-R(7      \        4       3V3R. lV3R/ lll4       p	V3R0 lp
\        R1VR28X  d   R3MT R4S  R24       V'       g   \        R5VR28X  d   R3MT R4S  24       \        P                  ! V'       d   TMV
! V4      VS VR67       R7# )8z
Command-line interface for running the FastAPI web server.

This function starts the FastAPI web server with the specified port and log level.
If the number of worker threads is specified, it sets the thread limiter accordingly.
r   zBackground RemovaldescriptionzGEndpoints that perform background removal with different image sources.externalDocszGitHub Sourceurlz$https://github.com/danielgatis/rembgRembgz8Rembg is a tool to remove images background. That is it.zDaniel Gatiszhttps://github.com/danielgatisemailzdanielgatis@gmail.comzMIT Licensez:https://github.com/danielgatis/rembg/blob/main/LICENSE.txtz/api)titler/   versioncontactlicense_infoopenapi_tagsdocs_urlF*)allow_credentialsallow_originsallow_methodsallow_headersc                     a  ] tR t^ot o ]! RRRP                  ]4      ,           R,           RR7      ]! RRR	7      ]! ^^ ^R
R7      ]! ^
^ ^RR7      ]! ^
^ RR7      ]! RRR	7      ]! RRR	7      ]! RRR	7      ]! RRR	7      3	V 3R lR lltRtV t	R# )$s_command.<locals>.CommonQueryParams"Model to use when processing image(|)u2netr/   regexr   FEnable Alpha Mattingr   r/   $Alpha Matting (Foreground Threshold)r   geler/   $Alpha Matting (Background Threshold)$Alpha Matting (Erode Structure Size)r   rL   r/   	Only MaskPost Process MaskNBackground ColorExtra parameters as JSONc                p   < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[RS[S[ ,          R	S[S[ ,          /	# 
r"   modelaafabaeomppmbgcextrasr(   r)   r'   r   )r*   __classdict__s   "r+   r,   1s_command.<locals>.CommonQueryParams.__annotate__p   m     *	 *	*	 *	 *	 *	( )*	. /*	0 1*	2 #3*	4 SM5*	r-   c
                4   Wn         W n        W0n        W@n        WPn        W`n        Wpn        Wn        V'       dY   \        \        \        \        \        \        3,          \        \        \        VP                  R 4      4      4      4      V n        R# RV n        R# ,NrW   rX   rY   rZ   r[   r\   r]   r_   r   r   r'   tuplemapsplitr^   
selfrW   rX   rY   rZ   r[   r\   r]   r^   r_   s
   &&&&&&&&&&r+   __init__-s_command.<locals>.CommonQueryParams.__init__p   r    < JFGGGGH K  U3S#-.c#syy~6N0OP H  Hr-   	rX   rZ   r[   rY   r^   r_   rW   r\   r]   )
__name__
__module____qualname____firstlineno__r   joinr   rm   __static_attributes____classdictcell__ra   s   @r+   CommonQueryParamsr@   o   s      @SXXn55;
 E7MNB	 B	 q.T UDe9LM!&tAS!T$)*D%5*	 *	 *	r-   ry   c                     a  ] tR t^t o ]! RRRP                  ]4      ,           R,           RR7      ]! RRR	7      ]! ^^ ^R
R7      ]! ^
^ ^RR7      ]! ^
^ RR7      ]! RRR	7      ]! RRR	7      ]! RRR	7      ]! RRR	7      3	V 3R lR lltRt	V t
R# )(s_command.<locals>.CommonQueryPostParamsrA   rB   rC   rD   rE   rF   FrH   rI   rJ   rK   rN   rO   rP   rQ   rR   NrS   rT   c                p   < V ^8  d   QhRS[ RS[RS[RS[RS[RS[RS[RS[S[ ,          R	S[S[ ,          /	# rV   r`   )r*   ra   s   "r+   r,   5s_command.<locals>.CommonQueryPostParams.__annotate__   rc   r-   c
                4   Wn         W n        W0n        W@n        WPn        W`n        Wpn        Wn        V'       dY   \        \        \        \        \        \        3,          \        \        \        VP                  R 4      4      4      4      V n        R# RV n        R# re   rg   rk   s
   &&&&&&&&&&r+   rm   1s_command.<locals>.CommonQueryPostParams.__init__   ro   r-   rp   )rq   rr   rs   rt   r   ru   r   r   rm   rv   rw   rx   s   @r+   CommonQueryPostParamsr{      s      @SXXn55;
 56LMB	 B	 q.T E{CU8KL!&tAS!T$)*D%5*	 *	 *	r-   r   c                6   < V ^8  d   QhR\         RSR\        /# )r"   contentcommonsr&   )bytesr   )r*   ry   s   "r+   r,   s_command.<locals>.__annotate__   s#     
 
u 
/@ 
X 
r-   c                   < / pVP                   '       d1    VP                  \        P                  ! VP                   4      4       SP                  VP                  4      pVf&   \        VP                  3/ VB pVSVP                  &   \        \        V 3RVRVP                  RVP                  RVP                  RVP                  RVP                  RVP                  RVP                   /VB R	R
7      #   \         d     Li ; i)Nsessionalpha_matting"alpha_matting_foreground_threshold"alpha_matting_background_thresholdalpha_matting_erode_size	only_maskpost_process_maskbgcolorz	image/png)
media_type)r_   updatejsonloads	ExceptiongetrW   r   r   r   rX   rY   rZ   r[   r\   r]   r^   )r   r   kwargsr   sessionss   &&  r+   im_without_bg s_command.<locals>.im_without_bg   s   >>>djj89 ,,w}}-?!'--:6:G&-HW]]# &ii 4;::	
 4;:: *1 "** #*++    #
 	
  s   /C7 7DDstartupc                     <  \         P                  ! R S 24       Se,   ^ RIHp  ^ RIHp V! R4      P                  V ! S4      4       R# R#   \         d     L>i ; i)zhttp://localhost:N)CapacityLimiter)RunVar_default_thread_limiter)
webbrowseropenr   anyior   anyio.lowlevelr   set)r   r   r   r$   s     r+   r   s_command.<locals>.startup   s\    	OO/v67 --,-11/'2JK	   		s   A AAc                0    V ^8  d   QhR\         R\        /# )r"   r   r&   )r(   r)   )r*   s   "r+   r,   r      s      S T r-   c                 N    \         P                  ! V R 4      pV Ft  pV^,          ^ ,          p\        P                  ! V4      pVP                  '       g9   VP
                  '       g'   VP                  '       g   VP                  '       g   Ks   R# 	  R#   \         d     R# i ; i)NTF)	socketgetaddrinfo	ipaddress
ip_address
is_privateis_loopbackis_link_localis_reservedr   )r   resolveditemaddrips   &    r+   _is_private_ip!s_command.<locals>._is_private_ip   s    	))$5H Awqz))$/MMM~~~'''~~~ !   		s*   A%B (B :B B B B$#B$c                (    V ^8  d   QhR\         RR/# )r"   r1   r&   Nr(   )r*   s   "r+   r,   r     s     X X3 X4 Xr-   c                    < \        V 4      pVP                  R9  d   \        R4      hVP                  '       g   \        R4      hS! VP                  4      '       d   \        R4      hR# )httpz%Only http and https URLs are allowed.zInvalid URL: missing hostname.z7Requests to private/internal addresses are not allowed.N)r   https)r   scheme
ValueErrorhostname)r1   parsedr   s   & r+   _validate_url s_command.<locals>._validate_url  sZ    #== 11DEE=>>&//**VWW +r-   z/api/removezRemove from URLzCRemoves the background from an image obtained by retrieving an URL.)pathtagssummaryr/   .z*URL of the image that has to be processed.rI   c                *   < V ^8  d   QhR\         RS/# )r"   r1   r   r   )r*   ry   s   "r+   r,   r     s#     D DD #	Dr-   c           
      Z  <"    S! V 4       \        P                  ! 4       ;_uu_4       GRj  xL
 pTP                  T 4      ;_uu_4       GRj  xL
 pTP                  4       G Rj  xL
 p\        S4      ! YQ4      G Rj  xL
 uuRRR4      GRj  xL
  uuRRR4      GRj  xL
  #   \          d   p\        R \        T4      R7      hRp?ii ; i L L Ln LW LH L8  + GRj  xL 
 '       g   i     M; iRRR4      GRj  xL 
  R#   + GRj  xL 
 '       g   i     R# ; i5i)i  )status_codedetailN)r   r   r(   aiohttpClientSessionr   readr   )r1   r   er   responsefiler   r   s   &&    r+   	get_indexs_command.<locals>.get_index  s     	@# ((***g{{3'''8%]]_,%m4TCC ('' +**  	@CA??	@ +',C ( +'''' +*****s   D+B* !D+CD+DCDC	(C)C	CC	DC
DD+$C%D+*C5CCD+DC	C	DD+C8%C(&
C81C83D;D+D	D+D(	D
D(	 D(	"	D+zRemove from StreamzDRemoves the background from an image sent within the request itself.z2Image file (byte stream) that has to be processed.c                *   < V ^8  d   QhR\         RS/# )r"   r   r   )r   )r*   r   s   "r+   r,   r   *  s     < <<
 '<r-   c                 B   <"   \        S4      ! W4      G R j  xL
 #  L5i)Nr   )r   r   r   s   &&r+   
post_indexs_command.<locals>.post_index$  s      m,T;;;;s   c                   < V3R  lp\         P                  ! V\         P                  P                  RRR7      \         P                  P	                  \
        RRR7      \         P                  P                  RRR7      \         P                  P                  ^^ ^R	R
7      \         P                  P                  ^
^ ^RR
7      \         P                  P                  ^(^ ^RR
7      \         P                  P                  RRR7      \         P                  P                  RRR7      \         P                  P                  RR7      .	\         P                  P                  RRR7      ^RR7      p\         P                  ! WRR7      p V # )c                 8  < R pVw  rErgrp
RVRVRVRVRVRV	/pV
'       d&   VP                  \        P                  ! V
4      4       SP                  V4      pVf   \	        V3/ VB pVSV&   WR&   \        V R	4      ;_uu_ 4       p\        VR
4      ;_uu_ 4       pVP                  4       p\        V3/ VB pVP                  V4       RRR4       RRR4       \        P                  P                  V4      #   + '       g   i     L7; i  + '       g   i     LB; i)z
output.pngr   r   r   r   r   r   Nr   rbwb)r   r   r   r   r   r   r   r   writeosr   ru   )
input_pathrW   argsoutput_pathrX   rY   rZ   r[   r\   r]   cmd_argsr   r   ioinputoutputr   s   &&*              r+   	inference,s_command.<locals>.gr_app.<locals>.inference4  s    &K/3,A22H  4b4b*BR#SF djj23ll5)G%e6v6") '9j$''1+t,,FFHE#E4V4FGGFO - (
 77<<,,	 -, ('s$   D	.C6	D	6DD		D	filepathInput)r   labelrE   Models)valuer   TzAlpha mattingzForeground threshold)r   minimummaximumr   zBackground thresholdzErosion sizeFz	Only maskzPost process mask	Arguments)r   Output)concurrency_limitanalytics_enabled/)r   )
gr	Interface
componentsImageDropdownr   CheckboxSliderTextboxmount_gradio_app)appr   	interfacer   s   &  r+   gr_apps_command.<locals>.gr_app3  sK   	-: LL##7#C&&~WH&U&&T&I$$q#=S %  $$a<R %  $$aN %  &&U+&F&&T9L&M%%K%8" MMZx@#+
	0 !!#s;
r-   z.To access the API documentation, go to http://r   	localhost:zTo access the UI, go to http://)r   r   r#   N)r
   r   add_middlewarer   on_eventr   r   r	   postr   printuvicornrun)r   r   r#   r$   r%   tags_metadatar   r   r   r   r   ry   r   r   r   r   r   s   f&&f&      @@@@@@r+   	s_commandr     s   d (*H (d=	
	M NN3,
 MO
 #C" eee  + +Z+ +Z
 
< 	\\)
L 
L"X X 	WW"#!Y	   %Q
 &-Y	D DD  	XX"#$Z	   L
 *1< <<7r 

8PYHY_c8ddefjekkop -TY=NkTX-YYZ[_Z`a	
 KK&+Dtyr-   ),r   r   r   r   r   typingr   r   r   urllib.parser   r   clickgradior   r  asyncerr   fastapir	   r
   r   r   r   r   fastapi.middleware.corsr   starlette.responsesr    r   bgr   session_factoryr   r   r   sessions.baser   commandoptionr'   r(   r   r-   r+   <module>r     s#     	   ( ( !      F F 2 (   ) % ' 		 		 		 		 		# 	9r	Vrr-   