Fix the memory error bug when loading metadata pickle file of vqvae dataset.
Former-commit-id: 97ab243bd12915cea7aa2deecfac4b99417f78a3
This commit is contained in:
@@ -6,6 +6,7 @@ import warnings
|
||||
import glob
|
||||
|
||||
import torch.utils.data as data
|
||||
import torch.distributed as dist
|
||||
import torch.nn.functional as F
|
||||
from torchvision.datasets.video_utils import VideoClips
|
||||
|
||||
@@ -41,7 +42,8 @@ class VQVAEDataset(data.Dataset):
|
||||
cache_file = osp.join(folder, f"metadata_{sequence_length}.pkl")
|
||||
if not osp.exists(cache_file):
|
||||
clips = VideoClips(files, sequence_length, num_workers=32)
|
||||
pickle.dump(clips.metadata, open(cache_file, 'wb'))
|
||||
if dist.is_initialized() and dist.get_rank() == 0:
|
||||
pickle.dump(clips.metadata, open(cache_file, 'wb'))
|
||||
else:
|
||||
metadata = pickle.load(open(cache_file, 'rb'))
|
||||
clips = VideoClips(files, sequence_length,
|
||||
|
||||
Reference in New Issue
Block a user