
    9i~                     b    S SK Jr  S SKrS SKJrJr  SSKJrJ	r	J
r
Jr  SSKJr   " S S\5      rg)	    )DictN)ModelTensor   )content_lossguided_filter
style_losstotal_variation_loss)unet_generatorc                      ^  \ rS rSrU 4S jr  SS\\\4   S\\\4   S\\\4   S\\\4   4S jjrS\\\4   S\\\4   4S	 jr	S
r
U =r$ )CartoonModel   c                 :   > [         TU ]  " U/UQ70 UD6  Xl        g )N)super__init__	model_dir)selfr   argskwargs	__class__s       e/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/models/cv/cartoon/model_tf.pyr   CartoonModel.__init__   s    4T4V4"    input_photoinput_cartooninput_superpixelreturnc                     Uc  [        U5      n[        XSS9nSU0$ [        U5      n[        XSS9n[        U R                  UXS5      n[	        X%5      u  px[        U5      n	SU-  SU-  -   SU	-  -   n
UnUU
US.$ )a  return the result by the model

Args:
    input_photo: the preprocessed input photo image
    input_cartoon: the preprocessed input cartoon image
    input_superpixel: the computed input superpixel image

Returns:
    output_dict: output dict of target ids
r   )routput_cartoong?g      i@g     @)r    g_lossd_loss)r   r   r   r   r	   r
   )r   r   r   r   outputr    con_loss
sty_g_loss
sty_d_losstv_lossr!   r"   s               r   __call__CartoonModel.__call__   s      #K0F*;!DN$n55#K0F*;!DN#DNNK$2FH%/%N"J*>:GJ&x7#-GFF #1   r   inputc                     g)z
Run the forward pass for a model.

Args:
    input (Dict[str, Tensor]): the dict of the model inputs for the forward method

Returns:
    Dict[str, Tensor]: output from the model forward pass
N )r   r*   s     r   forwardCartoonModel.forward7   s    r   )r   )NN)__name__
__module____qualname____firstlineno__r   r   strr   r(   r-   __static_attributes____classcell__)r   s   @r   r   r      s    # 0426	#c6k*#  V,# #3;/	# <@V;L	#J	T#v+. 	4V3D 	 	r   r   )typingr   
tensorflowtfmodelscope.models.baser   r   lossr   r   r	   r
   networkr   r   r,   r   r   <module>r<      s%      0 O O #45 4r   