Team Ai
Apppublic

dylanebert/multi-view-diffusion

sourceHugging Facemitupdated 2y agoView on Hugging Face
64likes
text_pipeline.cpython-310.pyc16 linesDownload Raw Back to __pycache__
1o

2�f�	�@s�ddlZddlZddlmZddlmZejddejdd��	d�Z3ejd	dejdd��	d�Zd4d�Zdd
�Z
dd�Ze����Ze����e���Se�d��ejdddd�Ze�d�ZWd�n1sfwYe�d��ejddd�Zejdddd�Ze�d�ZWd�n1s�wYWd�n1s�wYe���ejdd�ZWd�n1s�wYWd�n1s�wYeje
eed�ejeeeged�Wd�n1s�wYedkr�e��dSdS)�N)�DiffusionPipeline)�Imagez ashawkey/mvdream-sd2.1-diffuserszdylanebert/multi_view_diffusionT)�custom_pipeline�torch_dtype�trust_remote_code�cudaz"ashawkey/imagedream-ipmv-diffuserscCs�dd�|D�}|dj\}}t�dd|d|f�}|�|dd�|�|d|df�|�|dd|f�|�|d||f�|S)	NcSs g|]}t�|d�d���qS)���uint8)r�	fromarray�astype)�.0�img�r�)/home/dylan/mvdream_test/text_pipeline.py�5<listcomp>s z%create_image_grid.<locals>.<listcomp>r�RGB�)rr��)�sizer�new�paste)�images�width�height�grid_imgrrr�create_image_gridsrcCst|dddd�}t|�S)N��r��guidance_scale�num_inference_steps�	elevation)�
text_pipeliner)�promptrrrr�6text_to_mv&s�r%cCs(|�d�d}t||dddd�}t|�S)N�float32g�o@rrrr)r�image_pipeliner)�imager$rrrr�image_to_mv-s78�r)z9Text InputrFz.Enter a text prompt here (e.g. 'a cat statue'))�lines�10show_label�placeholderzGenerate Multi-View ImageszImage Input�numpy)�label�typez"Enter an optional text prompt herezGenerated Images)r.)�fn�inputs�outputs�__main__)�gradio�gr�torch�	diffusersr�PILr�from_pretrained�float16�tor#r'rr%r)�Blocks�demo�Row�Column�Tab�Textbox�11text_input�Button�text_btn�image_input�optional_text_input�	image_btn�output�click�__name__�launchrrrr�<module>sz����121314�������15���16���