CoolFace
Apppublic

thienphuc12339/SignLanguage

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
utils.cpython-39.pyc14 linesDownload Raw Back to __pycache__
1a

2v��fo�@s�ddlZddlZddlmZddlmZmZmZej	e3e4ej	d�dd�Zdeje
e5e6d�d	d7�Ze
ed�dd
�Zdej	e
e8e9eej	d�dd�ZdS)�N)�mimsave)�Image�	ImageDraw�	ImageFont)�image�std�mean�returncCs&|||}|d�d�}|�dd�S)N���uint8r)�astype�clip�rrr�r�iD:\OneDrive\Organizations\VuonAI\Projects\vietnamese-sign-language-translation\src\visualization\utils.py�unnormalize_imgsr�10sample.gif)�video_tensor�	save_pathrrcCsTg}|D]*}t|�ddd���||d�}|�|�qddi}t||dfi|��|S)N��rr�durationg�?ZGIF)r�permute�numpy�appendr)rrrr�framesZvideo_frameZframe_unnormalizedZkargsrrr�save_as_gif
s�r)�gif_pathr	cCs11t|d�S)N)�filename)r)rrrr�display_gif sr��r!�rrr12r!)r�text�position�color�	font_sizer	cCs>tjd|d�}t�|�}t�|�}|j||||d�t�|�S)Nzfonts/OpenSans-Regular.ttf)�font�size)�xyr#�fillr')	rZtruetyper�	fromarrayrZDrawr#�np�array)rr#r$r%r&r'Z	pil_image�drawrrr�draw_text_on_image$s�1314�r/)rNN)r r"r!)�torchrr,Zimageior�PILrrr�ndarray�tupler�Tensor�strrr�intr/rrrr�<module>s2����