Files
aigc-apps-EasyAnimate/easyanimate/vae/ldm/data/base.py
T
Bubbliiiingandzouxinyi0625 fb0916f4da Update EasyAnimateV2 (#5)
* update EasyAnimateV2

* update datasets loader

* update datasets loader

* update fast api

* complete data preprocess pipeline.

* update lots of readme

* update readme bans

* fix bug in validation while training

* provide example for video cut

* update text box

* add arxiv

* delete IDDPM

* update gallery

* update arxiv

* update readme

* update readme

* link fix

* update vae readme

---------

Co-authored-by: zouxinyi0625 <zouxinyi.zxy@alibaba-inc.com>
2024-05-31 10:33:14 +08:00

25 lines
726 B
Python

from abc import abstractmethod
from torch.utils.data import (ChainDataset, ConcatDataset, Dataset,
IterableDataset)
class Txt2ImgIterableBaseDataset(IterableDataset):
'''
Define an interface to make the IterableDatasets for text2img data chainable
'''
def __init__(self, num_records=0, valid_ids=None, size=256):
super().__init__()
self.num_records = num_records
self.valid_ids = valid_ids
self.sample_ids = valid_ids
self.size = size
print(f'{self.__class__.__name__} dataset contains {self.__len__()} examples.')
def __len__(self):
return self.num_records
@abstractmethod
def __iter__(self):
pass