---
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


{}
region:us
TAGS
#region-us 

---
license: other
---pip install transformers torch torchvision
from transformers import T5ForConditionalGeneration, T5Tokenizer
import torch
import torchvision.transforms as transforms
from URL import write_video
model = T5ForConditionalGeneration.from_pretrained("t5-base")
tokenizer = T5Tokenizer.from_pretrained("t5-base")
device = URL("cuda" if URL.is_available() else "cpu")
model = URL(device)
def generate_video_from_text(text):
    input_ids = URL(text, return_tensors="pt").to(device)
    output = model.generate(input_ids)
    video_frames = output[0].cpu().numpy()

    # Convert frames to a video
    frames = [URL(frame, dtype=torch.uint8).permute(1, 2, 0) for frame in video_frames]
    video = URL(frames)
    video = video.permute(0, 3, 1, 2)  # (T, C, H, W)

    return video


# Convert frames to a video
    frames = [URL(frame, dtype=torch.uint8).permute(1, 2, 0) for frame in video_frames]
    video = URL(frames)
    video = video.permute(0, 3, 1, 2)  # (T, C, H, W)

    return video
TAGS
#region-us 
 # Convert frames to a video
    frames = [URL(frame, dtype=torch.uint8).permute(1, 2, 0) for frame in video_frames]
    video = URL(frames)
    video = video.permute(0, 3, 1, 2)  # (T, C, H, W)

    return video