From 9491ae430ca637659ca38dd380d9fa498dd21bf3 Mon Sep 17 00:00:00 2001 From: Joel Holdbrooks Date: Mon, 23 Jan 2023 12:44:48 -0800 Subject: [PATCH] Initialize is_undersized to False, fix bug in directory resolver --- data/image_train_item.py | 1 + data/resolver.py | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/data/image_train_item.py b/data/image_train_item.py index 44a03be..fa13e3b 100644 --- a/data/image_train_item.py +++ b/data/image_train_item.py @@ -271,6 +271,7 @@ class ImageTrainItem: else: self.image = image + self.is_undersized = False self.error = None self.__compute_target_width_height() diff --git a/data/resolver.py b/data/resolver.py index 973c0b2..0662991 100644 --- a/data/resolver.py +++ b/data/resolver.py @@ -13,6 +13,7 @@ from data.image_train_item import ImageCaption, ImageTrainItem class DataResolver: def __init__(self, aspects: list[typing.Tuple[int, int]], flip_p=0.0, seed=555): + self.seed = seed self.aspects = aspects self.flip_p = flip_p @@ -146,9 +147,6 @@ class DirectoryResolver(DataResolver): if cur_file_multiplier > 0: if randomizer.random() < cur_file_multiplier: items.append(item) - - if item: - items.append(item) return items @staticmethod @@ -230,7 +228,7 @@ def resolve(value: typing.Union[dict, str], aspects: list[float], flip_p: float= case 'multi': items = [] for resolver in value.get('resolvers', []): - items.extend(resolve(resolver, aspects, flip_p, seed)) + items += resolve(resolver, aspects, flip_p, seed) return items case _: raise ValueError(f"Cannot resolve training data for resolver value '{resolver}'") \ No newline at end of file