From d1136102c218e9d478c764a32f9672c28f56077d Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 8 Jan 2023 22:00:17 +0100 Subject: No cache after all --- data/csv.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/data/csv.py b/data/csv.py index 58c833e..2f0a392 100644 --- a/data/csv.py +++ b/data/csv.py @@ -300,22 +300,6 @@ class VlpnDataset(IterableDataset): self.cache = {} self.length_ = (self.bucket_assignments.bincount() / self.batch_size).ceil().long().sum().item() - def get_static_example(self, item: VlpnDataItem, item_index: int): - if item_index in self.cache: - return copy.copy(self.cache[item_index]) - - example = {} - - example["prompt_ids"] = self.prompt_processor.get_input_ids(keywords_to_prompt(item.prompt)) - example["nprompt_ids"] = self.prompt_processor.get_input_ids(item.nprompt) - - if self.num_class_images != 0: - example["class_prompt_ids"] = self.prompt_processor.get_input_ids(item.cprompt) - - self.cache[item_index] = example - - return example - def __len__(self): return self.length_ @@ -374,12 +358,18 @@ class VlpnDataset(IterableDataset): item = self.items[item_index] mask[self.bucket_item_range[bucket_mask][0]] = False - example = self.get_static_example(item, item_index) + example = {} + + example["prompt_ids"] = self.prompt_processor.get_input_ids(keywords_to_prompt(item.prompt)) + example["nprompt_ids"] = self.prompt_processor.get_input_ids(item.nprompt) + example["instance_prompt_ids"] = self.prompt_processor.get_input_ids( keywords_to_prompt(item.prompt, self.dropout, True) ) example["instance_images"] = image_transforms(get_image(item.instance_image_path)) + if self.num_class_images != 0: + example["class_prompt_ids"] = self.prompt_processor.get_input_ids(item.cprompt) example["class_images"] = image_transforms(get_image(item.class_image_path)) batch.append(example) -- cgit v1.2.3-70-g09d2