YAML Metadata
Warning:
empty or missing yaml metadata in repo card
(https://huggingface.co/docs/hub/model-cards#model-card-metadata)
license: other ---pip install transformers torch torchvision from transformers import T5ForConditionalGeneration, T5Tokenizer import torch import torchvision.transforms as transforms from torchvision.io import write_video model = T5ForConditionalGeneration.from_pretrained("t5-base") tokenizer = T5Tokenizer.from_pretrained("t5-base") device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model = model.to(device) def generate_video_from_text(text): input_ids = tokenizer.encode(text, return_tensors="pt").to(device) output = model.generate(input_ids) video_frames = output[0].cpu().numpy()
# Convert frames to a video
frames = [torch.tensor(frame, dtype=torch.uint8).permute(1, 2, 0) for frame in video_frames]
video = torch.stack(frames)
video = video.permute(0, 3, 1, 2) # (T, C, H, W)
return video