Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'origin/loss-by-image-feature'"
Browse files Browse the repository at this point in the history
This reverts commit bef8f6c, reversing
changes made to d4634db.
  • Loading branch information
gesen2egee committed Mar 18, 2024
1 parent 711e057 commit f68d8cb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
3 changes: 1 addition & 2 deletions library/config_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = {
Expand Down
17 changes: 1 addition & 16 deletions library/train_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down Expand Up @@ -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は指定が必須です"

Expand All @@ -534,7 +532,6 @@ def __init__(
caption_suffix,
token_warmup_min,
token_warmup_step,
sample_weight,
)

self.is_reg = is_reg
Expand Down Expand Up @@ -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は指定が必須です"

Expand All @@ -600,7 +596,6 @@ def __init__(
caption_suffix,
token_warmup_min,
token_warmup_step,
sample_weight,
)

self.metadata_file = metadata_file
Expand Down Expand Up @@ -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は指定が必須です"

Expand All @@ -663,7 +657,6 @@ def __init__(
caption_suffix,
token_warmup_min,
token_warmup_step,
sample_weight,
)

self.conditioning_data_dir = conditioning_data_dir
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit f68d8cb

Please sign in to comment.