from functools import partial import os import torch import numpy as np import gradio as gr import random import shutil print(f"Is CUDA available: {torch.cuda.is_available()}") print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}") WEBSITE = """
""" WEBSITE_bottom = """We thanks TMR for this cool space template.
""" EXAMPLES = [ "This person kicks with his right leg then jabs several times.", "A person stands for few seconds and picks up his arms and shakes them.", "A person stands, crosses left leg in front of the right, lowering themselves until they are sitting, both hands on the floor before standing and uncrossing legs.", "A person is running on a treadmill.", "A person walks with a limp, their left leg gets injured.", "A person repeatedly blocks their face with their right arm.", "The person holds his left foot with his left hand, puts his right foot up and left hand up too.", "A person walks in a clokwise circle and stops where he began.", "A man bends down and picks something up with his right hand.", "The man walked forward, spun right on one foot and walked back to his original position.", "A man is walking forward then steps over an object then continues walking forward.", "This person takes 4 steps forward staring with his right foot.", "The person did a kick spin to the left.", "A figure streches it hands and arms above its head.", "The person takes 4 steps backwards.", "A person jumps up and then lands.", "The person was pushed but did not fall.", "The person does a salsa dance." ] # Show closest text in the training # css to make videos look nice # var(--block-border-color); TODO CSS = """ .generate_video { position: relative; margin: 0; box-shadow: var(--block-shadow); border-width: var(--block-border-width); border-color: #000000; border-radius: var(--block-radius); background: var(--block-background-fill); width: 100%; line-height: var(--line-sm); } } """ DEFAULT_TEXT = "A person is " def generate( text, uid, motion_length=0, seed=10107, repeat_times=4, ): os.system(f'python gen_t2m.py --gpu_id 0 --seed {seed} --ext {uid} --repeat_times {repeat_times} --motion_length {motion_length} --text_prompt "{text}"') datas = [] file_name = [name for name in os.listdir(f"./generation/{uid}/animations/0/") if name.endswith('_ik.mp4')][0] motion_length = int(file_name.split('len')[-1].replace('_ik.mp4', '')) for n in range(repeat_times): data_unit = { "url": f"generation/{uid}/animations/0/sample0_repeat{n}_len{motion_length}_ik.mp4" } datas.append(data_unit) print(datas) return datas # HTML component def get_video_html(data, video_id, width=700, height=700): url = data["url"] # class="wrap default svelte-gjihhp hide" #