Open-Sora: Democratizing Efficient Video Production for All
Python
[fix] correct video info
zhengzangwd71ae85467ae
diff --git a/opensora/datasets/datasets.py b/opensora/datasets/datasets.pyindex 43ee214..a8e48f8 100644--- a/opensora/datasets/datasets.py+++ b/opensora/datasets/datasets.py@@ -4,13 +4,15 @@ from glob import globimport numpy as npimport torchimport torchvision+from PIL import ImageFilefrom torchvision.datasets.folder import IMG_EXTENSIONS, pil_loaderfrom opensora.registry import DATASETS-from .utils import VID_EXTENSIONS, get_transforms_image, get_transforms_video, read_file, temporal_random_cropfrom .read_video import read_video+from .utils import VID_EXTENSIONS, get_transforms_image, get_transforms_video, read_file, temporal_random_crop+ImageFile.LOAD_TRUNCATED_IMAGES = TrueIMG_FPS = 120@@ -68,8 +70,8 @@ class VideoTextDataset(torch.utils.data.Dataset):if file_type == "video":# loading- vframes, vinfo = read_video(path, backend='av')- video_fps = vinfo["video_fps"] if 'video_fps' in vinfo else 24+ vframes, vinfo = read_video(path, backend="av")+ video_fps = vinfo["video_fps"] if "video_fps" in vinfo else 24# Sampling video framesvideo = temporal_random_crop(vframes, self.num_frames, self.frame_interval)@@ -145,8 +147,8 @@ class VariableVideoTextDataset(VideoTextDataset):video_fps = 24 # default fpsif file_type == "video":# loading- vframes, vinfo = read_video(path, backend='av')- video_fps = vinfo["video_fps"] if 'video_fps' in vinfo else 24+ vframes, vinfo = read_video(path, backend="av")+ video_fps = vinfo["video_fps"] if "video_fps" in vinfo else 24# Sampling video framesvideo = temporal_random_crop(vframes, num_frames, self.frame_interval)diff --git a/tools/datasets/datautil.py b/tools/datasets/datautil.pyindex a889a35..9674f00 100644--- a/tools/datasets/datautil.py+++ b/tools/datasets/datautil.py@@ -117,8 +117,7 @@ def get_image_info(path, backend="pillow"):def get_video_info(path, backend="torchvision"):if backend == "torchvision":try:- # vframes, infos = read_video(path)- vframes, _, infos = torchvision.io.read_video(filename=path, pts_unit="sec", output_format="THWC")+ vframes, infos = read_video(path)num_frames, height, width = vframes.shape[0], vframes.shape[2], vframes.shape[3]if "video_fps" in infos:fps = infos["video_fps"]