o
    ߥiJ                     @   s>   d dl Z d dlmZ ddlmZmZ g dZG dd dZdS )    N)rotation_conversions   )JOINTSTYPE_ROOTSMPL)a2ma2mplsmplvibeverticesc                   @   s(   e Zd Zd	ddZ				d
ddZdS )Rotation2xyzamassc                 C   s$   || _ || _t| || _d S )N)devicedatasetr   evalto
smpl_model)selfr   smpl_data_pathr    r   o/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/models/cv/motion_generation/modules/rotation2xyz.py__init__   s   zRotation2xyz.__init__Nr   Fc                 K   s  |dkr|S |d u rt j|jd |jd ft|jd}|s%|
d u r%td|tvr-td|rE|d d dd df }|d d d df }n|}|dddd	}|j\}}}}|d
krbt	
|| }n+|dkrq|| d|dd}n|dkr}t	|| }n|dkrt	|| }ntd|st j|
|jd}t	
|dddd}|t|ddd}n|d d df }|d d dd f }|d u rt j|jd | jjg|j|jd}|	|d d df< | j|||d}|| }t j|||jd d|j|jd}d|| < |||< |dd	dd }|dkr%t| }||d d |gd d d d f  }|rI|rI||d d d d dgf  }||d d d d d d d f  }|rQ|||fS |S )Nxyzr   )dtyper   z1You must specify global rotation if glob is Falsez#This jointstype is not implemented.   r      rotvecrotmatrotquatrot6dzNo geometry for this one.)r   )	body_poseglobal_orientbetas)r   r   r
   )torchonesshapeboolr   	TypeErrorJOINTSTYPESNotImplementedErrorpermutegeometryaxis_angle_to_matrixviewquaternion_to_matrixrotation_6d_to_matrixtensorrepeatlenzerosr   	num_betasr   empty
contiguousr   )r   xmaskpose_reptranslationglob
jointstype
vertstransr"   betaglob_rotget_rotations_backkwargsx_translationsx_rotationsnsamplestimenjointsfeats	rotationsr!   outjointsx_xyz	rootindexr   r   r   __call__   s|   


" 
zRotation2xyz.__call__)r   )Nr   NF)__name__
__module____qualname__r   rM   r   r   r   r   r      s    
r   )	r#    modelscope.utils.cv.motion_utilsr   r+   r   r   r   r(   r   r   r   r   r   <module>   s
   