mirror of
https://github.com/storytold/FineTrainers-Conditioning.git
synced 2026-10-26 08:37:09 +00:00
updates
This commit is contained in:
+11
-12
@@ -144,7 +144,7 @@ class VideoDataset(Dataset):
|
|||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
image, video, _ = self._preprocess_video(self.video_paths[index])
|
image, video, _ = self._preprocess_video(self.video_paths[index])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"prompt": self.id_token + self.prompts[index],
|
"prompt": self.id_token + self.prompts[index],
|
||||||
"image": image,
|
"image": image,
|
||||||
@@ -281,7 +281,7 @@ class VideoDatasetWithResizing(VideoDataset):
|
|||||||
)
|
)
|
||||||
|
|
||||||
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)
|
||||||
frames = frames[:nearest_frame_bucket].float()
|
frames = frames[:nearest_frame_bucket].float()
|
||||||
frames = frames.permute(0, 3, 1, 2).contiguous()
|
frames = frames.permute(0, 3, 1, 2).contiguous()
|
||||||
@@ -404,17 +404,16 @@ class BucketSampler(Sampler):
|
|||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for index, data in enumerate(self.data_source):
|
for index, data in enumerate(self.data_source):
|
||||||
if data is not None:
|
video_metadata = data["video_metadata"]
|
||||||
video_metadata = data["video_metadata"]
|
f, h, w = video_metadata["num_frames"], video_metadata["height"], video_metadata["width"]
|
||||||
f, h, w = video_metadata["num_frames"], video_metadata["height"], video_metadata["width"]
|
|
||||||
|
|
||||||
self.buckets[(f, h, w)].append(data)
|
self.buckets[(f, h, w)].append(data)
|
||||||
if len(self.buckets[(f, h, w)]) == self.batch_size:
|
if len(self.buckets[(f, h, w)]) == self.batch_size:
|
||||||
if self.shuffle:
|
if self.shuffle:
|
||||||
random.shuffle(self.buckets[(f, h, w)])
|
random.shuffle(self.buckets[(f, h, w)])
|
||||||
yield self.buckets[(f, h, w)]
|
yield self.buckets[(f, h, w)]
|
||||||
del self.buckets[(f, h, w)]
|
del self.buckets[(f, h, w)]
|
||||||
self.buckets[(f, h, w)] = []
|
self.buckets[(f, h, w)] = []
|
||||||
|
|
||||||
if self.drop_last:
|
if self.drop_last:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user