mirror of
https://github.com/storytold/FineTrainers-Conditioning.git
synced 2026-10-17 00:23:35 +00:00
updates
This commit is contained in:
+12
-17
@@ -22,8 +22,8 @@ decord.bridge.set_bridge("torch")
|
|||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
HEIGHT_BUCKETS = [256, 320, 384, 480, 512, 576, 720, 768, 960, 1024, 1280, 1536]
|
HEIGHT_BUCKETS = [256, 320, 384, 480, 512, 576, 720, 768, 960, 1024, 1280, 1536]
|
||||||
WIDTH_BUCKETS = [256, 320, 384, 480, 512, 576, 720, 768, 848, 960, 1024, 1280, 1536]
|
WIDTH_BUCKETS = [256, 320, 384, 480, 512, 576, 720, 768, 960, 1024, 1280, 1536]
|
||||||
FRAME_BUCKETS = [16, 24, 32, 48, 64, 80, 84]
|
FRAME_BUCKETS = [16, 24, 32, 48, 64, 80]
|
||||||
|
|
||||||
|
|
||||||
class VideoDataset(Dataset):
|
class VideoDataset(Dataset):
|
||||||
@@ -144,17 +144,16 @@ class VideoDataset(Dataset):
|
|||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
image, video, _ = self._preprocess_video(self.video_paths[index])
|
image, video, _ = self._preprocess_video(self.video_paths[index])
|
||||||
if video is not None:
|
return {
|
||||||
return {
|
"prompt": self.id_token + self.prompts[index],
|
||||||
"prompt": self.id_token + self.prompts[index],
|
"image": image,
|
||||||
"image": image,
|
"video": video,
|
||||||
"video": video,
|
"video_metadata": {
|
||||||
"video_metadata": {
|
"num_frames": video.shape[0],
|
||||||
"num_frames": video.shape[0],
|
"height": video.shape[2],
|
||||||
"height": video.shape[2],
|
"width": video.shape[3],
|
||||||
"width": video.shape[3],
|
},
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
def _load_dataset_from_local_path(self) -> Tuple[List[str], List[str]]:
|
def _load_dataset_from_local_path(self) -> Tuple[List[str], List[str]]:
|
||||||
if not self.data_root.exists():
|
if not self.data_root.exists():
|
||||||
@@ -276,13 +275,9 @@ class VideoDatasetWithResizing(VideoDataset):
|
|||||||
else:
|
else:
|
||||||
video_reader = decord.VideoReader(uri=path.as_posix())
|
video_reader = decord.VideoReader(uri=path.as_posix())
|
||||||
video_num_frames = len(video_reader)
|
video_num_frames = len(video_reader)
|
||||||
|
|
||||||
nearest_frame_bucket = min(
|
nearest_frame_bucket = min(
|
||||||
self.frame_buckets, key=lambda x: abs(x - min(video_num_frames, self.max_num_frames))
|
self.frame_buckets, key=lambda x: abs(x - min(video_num_frames, self.max_num_frames))
|
||||||
)
|
)
|
||||||
if video_num_frames < nearest_frame_bucket:
|
|
||||||
# TODO: we could handle this by padding zero frames or duplicating the existing frames?
|
|
||||||
return None, None, None
|
|
||||||
|
|
||||||
frame_indices = list(range(0, video_num_frames, video_num_frames // nearest_frame_bucket))
|
frame_indices = list(range(0, video_num_frames, video_num_frames // nearest_frame_bucket))
|
||||||
frames = video_reader.get_batch(frame_indices)
|
frames = video_reader.get_batch(frame_indices)
|
||||||
|
|||||||
Reference in New Issue
Block a user