
    Hh                         d dl mZmZ d dlmZ d dlZd dlmZ d dlm	Z	m
Z
mZmZ d dlmZ ddlmZ ddlmZ e G d	 d
                      Z G d dej        e          ZdS )    )ABCabstractmethod)	dataclassN)ndarray)DictUnionListfinal   )Asset)Augmentc                       e Zd ZU dZeedf         ed<   dZeedf         ed<   dZ	eedf         ed<   dZ
eedf         ed<   dZeedf         ed<   dZeedf         ed<   dZeedf         ed<   dZeedf         ed	<   dS )

ModelInputNtokenspadverticesnormalsjointstailsassetaugments)__name__
__module____qualname__r   r   r   __annotations__r   intr   r   r   r   r   r   r   r        ?/data/cameron/tmprepos/clean_dreammesh/UniRig/src/model/spec.pyr   r      s          "&FE'4- %%% CsDy	 $(HeGTM"''' #'GU7D=!&&& "&FE'4- %%% !%E5$$$$ #E5""" $(HeGTM"'''''r   r   c                        e Zd Ze fd            Zedee         dee         fd            Z	edee         defd            Z
 xZS )	ModelSpecc                 H    t                                                       d S )N)super__init__)self	__class__s    r   r$   zModelSpec.__init__'   s    r   batchreturnc                 6   |                      |          }g d}d}d}d}|D ]W}|j        t          ||j        j                  }t          ||j        j                  }t          ||j        j                  }Xg | _        g | _        t          |          D ]\  }}|D ]}	|	||         vsJ d|	 d            |j        j
        ||         d<   |j        j        ||         d<   |j        j        ||         d<   |j        j        Qt          j        |j        j        d||j        j        z
  fd	fd
d          ||         d<   |j        j        ||         d<   |j        j        <t          j        |j        j        d||j        j        z
  fd	fd
d          ||         d<   |j        j        U|j        j                                        }
d|
d<   t          j        |
d||j        j        z
  fd
d          }
|
||         d<   |j        j        i|j        j        }t          j        |j        j        d||z
  fd	d	fd
d          }d||dddf<   d||dddf<   d||dddf<   d||dddf<   |||         d<   |j        j        i|j        j        }t          j        |j        j        d||z
  fd	d	fd
d          }d||dddf<   d||dddf<   d||dddf<   d||dddf<   |||         d<   |j        ||         d<   |j        ||         d<   |j        j        ||         d<   t          j        |j        j        d||j        j        z
  fd	f          ||         d<   t          j        |j        j        d||j        j        z
  fd	f          ||         d<   |j        j        ||         d<   t          j        |j        j        d||j        j        z
  fd	f          ||         d<   t          j        |j        j        d||j        j        z
  fd	f          ||         d <   |S )!a  
        Returns
            cls: List[str]

            path: List[str]
            
            data_name: List[str]
            
            joints: shape (B, J, 3), J==max_bones
            
            tails: shape (B, J, 3)
            
            parents: shape (B, J), -1 represents no parent(should always appear at 0-th position)
            
            num_bones: shape (B), the true number of bones
            
            skin: shape (B, J), padding value==0.
            
            vertices: (B, N, 3)
            
            normals: (B, N, 3)
            
            matrix_local: (B, J, 4, 4), current matrix_local
            
            pose_matrix: (B, J, 4, 4), for motion loss calculation
        )clspath	data_namer   r   parents	num_bonesr   r   matrix_localpose_matrix
num_pointsorigin_verticesorigin_vertex_normalsorigin_face_normals	num_facesfacesr   Nzcannot override `z` in process_fnr*   r+   r,   )r   r   constantg        )modeconstant_valuesr   r.   r   )r9   r-   g      ?   r      r/   r0   r   r   r1   r2   r3   r5   origin_facesr4   )
process_fnr   maxr   JFN	_augments_assets	enumerater*   r+   r,   npr   r   r-   copyr/   r0   r   r   vertex_normalsr6   face_normals)r%   r'   n_batchBAN	max_bones
max_points	max_facesbidbanr-   r@   r/   r0   s                 r   _process_fnzModelSpec._process_fn+   s   8 //%((U U U 	
	 	4 	4Ax#	17955	Iqwy11IZ33JJ '' (	r (	rGR X X'"+---/W3/W/W/W----!"GBK"#',GBK'(w'8GBK$w~)(*qw~IagiDW@XZ`?ahr  EG  )H  )H  )HH%+,79K(w}(')vagmq)AGIBU>VX^=_fp  CE  (F  (F  (FG$w*'/..00
&1i	.A*BJ`bccc)0I&w#/GI!vag&:a1=MvW]<^`j|~)+QRRAX&)+QRRAX&)+QRRAX&)+QRRAX&.:N+w".GI fQW%8Ay{;KVU[:\^hz|}}}(*ABB1H%(*ABB1H%(*ABB1H%(*ABB1H%-8M*&'jGBK
#%&YGBK	"()	GBK%-/VAG4D:VWV]V_K_G`bhFi-j-jGBK)*356!':PTUWabcbibkWkSlntRu3v3vGBK/0'(wyGBK$*,&!YqwyEXAY[a@b*c*cGBK'138LPQS\]^]d]fSfOgioNp1q1qGBK-..r   c                     dS )zM
        Fetch data from dataloader and turn it into Tensor objects.
        Nr   )r%   r'   s     r   r>   zModelSpec.process_fn   s	    
 	r   )r   r   r   r   r$   r
   r	   r   r   rR   r>   __classcell__)r&   s   @r   r!   r!   %   s            ^ Sj!1 Sd4j S S S USj Z 0 T    ^    r   r!   )abcr   r   dataclassesr   numpyrF   r   typingr   r   r	   r
   lightning.pytorchpytorchpl
data.assetr   data.augmentr   r   LightningModuler!   r   r   r   <module>r_      s   # # # # # # # # ! ! ! ! ! !           + + + + + + + + + + + +             " " " " " "
( ( ( ( ( ( ( (2a a a a a"C a a a a ar   