From f68d8cb6840988fb0319a6e7c56e644aa3833b24 Mon Sep 17 00:00:00 2001 From: gesen2egee <79357052+gesen2egee@users.noreply.github.com> Date: Mon, 18 Mar 2024 12:53:31 +0800 Subject: [PATCH] Revert "Merge remote-tracking branch 'origin/loss-by-image-feature'" This reverts commit bef8f6c5273ad18cbfb41e67eeface2c412ec3d6, reversing changes made to d4634db80391c27197107edd2194a97d63b5127a. --- library/config_util.py | 3 +-- library/train_util.py | 17 +---------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/library/config_util.py b/library/config_util.py index 7c5b80792..475e7f471 100644 --- a/library/config_util.py +++ b/library/config_util.py @@ -80,7 +80,7 @@ class BaseSubsetParams: caption_tag_dropout_rate: float = 0.0 token_warmup_min: int = 1 token_warmup_step: float = 0 - sample_weight: bool = False + @dataclass class DreamBoothSubsetParams(BaseSubsetParams): @@ -198,7 +198,6 @@ def __validate_and_convert_scalar_or_twodim(klass, value: Union[float, Sequence] "token_warmup_step": Any(float, int), "caption_prefix": str, "caption_suffix": str, - "sample_weight": bool, } # DO means DropOut DO_SUBSET_ASCENDABLE_SCHEMA = { diff --git a/library/train_util.py b/library/train_util.py index c7219c7e9..7d6d87deb 100644 --- a/library/train_util.py +++ b/library/train_util.py @@ -453,7 +453,6 @@ def __init__( caption_suffix: Optional[str], token_warmup_min: int, token_warmup_step: Union[float, int], - sample_weight: bool, ) -> None: self.image_dir = image_dir self.num_repeats = num_repeats @@ -477,7 +476,7 @@ def __init__( self.token_warmup_min = token_warmup_min # step=0におけるタグの数 self.token_warmup_step = token_warmup_step # N(N<1ならN*max_train_steps)ステップ目でタグの数が最大になる - self.sample_weight = sample_weight + self.img_count = 0 @@ -508,7 +507,6 @@ def __init__( caption_suffix, token_warmup_min, token_warmup_step, - sample_weight, ) -> None: assert image_dir is not None, "image_dir must be specified / image_dirは指定が必須です" @@ -534,7 +532,6 @@ def __init__( caption_suffix, token_warmup_min, token_warmup_step, - sample_weight, ) self.is_reg = is_reg @@ -574,7 +571,6 @@ def __init__( caption_suffix, token_warmup_min, token_warmup_step, - sample_weight, ) -> None: assert metadata_file is not None, "metadata_file must be specified / metadata_fileは指定が必須です" @@ -600,7 +596,6 @@ def __init__( caption_suffix, token_warmup_min, token_warmup_step, - sample_weight, ) self.metadata_file = metadata_file @@ -637,7 +632,6 @@ def __init__( caption_suffix, token_warmup_min, token_warmup_step, - sample_weight, ) -> None: assert image_dir is not None, "image_dir must be specified / image_dirは指定が必須です" @@ -663,7 +657,6 @@ def __init__( caption_suffix, token_warmup_min, token_warmup_step, - sample_weight, ) self.conditioning_data_dir = conditioning_data_dir @@ -1271,13 +1264,6 @@ def __getitem__(self, index): image_info = self.image_data[image_key] subset = self.image_to_subset[image_key] sample_weight = 1.0 - if self.sample_weight is not None: - sample_weight_path = os.path.splitext(info.absolute_path)[0] + ".weight" - try: - with open(sample_weight_path, 'r', encoding='utf-8') as file: - sample_weight = float(file.readline().strip()) - except (OSError, ValueError): - pass loss_weights.append(sample_weight * (self.prior_loss_weight if image_info.is_reg else 1.0)) # in case of fine tuning, is_reg is always False flipped = subset.flip_aug and random.random() < 0.5 # not flipped or flipped with 50% chance @@ -1962,7 +1948,6 @@ def __init__( subset.caption_suffix, subset.token_warmup_min, subset.token_warmup_step, - subset.sample_weight, ) db_subsets.append(db_subset)