Skip to content

Commit

Permalink
Add support for save_last_n_epochs
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaltais committed Oct 30, 2024
1 parent 695b44a commit 021c6f5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kohya_gui/class_advanced_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ def list_vae_files(path):
precision=0,
info="(Optional) Save only the specified number of states (old models will be deleted)",
)
self.save_last_n_epochs = gr.Number(
label="Save last N epochs",
value=self.config.get("advanced.save_last_n_epochs", 0),
precision=0,
info="(Optional) Save only the specified number of epochs (old epochs will be deleted)",
)
self.save_last_n_epochs_state = gr.Number(
label="Save last N epochs state",
value=self.config.get("advanced.save_last_n_epochs_state", 0),
Expand Down
5 changes: 5 additions & 0 deletions kohya_gui/dreambooth_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def save_configuration(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -372,6 +373,7 @@ def open_configuration(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -574,6 +576,7 @@ def train_model(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -990,6 +993,7 @@ def train_model(
"save_last_n_steps_state": (
save_last_n_steps_state if save_last_n_steps_state != 0 else None
),
"save_last_n_epochs": save_last_n_epochs if save_last_n_epochs != 0 else None,
"save_last_n_epochs_state": (
save_last_n_epochs_state if save_last_n_epochs_state != 0 else None
),
Expand Down Expand Up @@ -1343,6 +1347,7 @@ def dreambooth_tab(
advanced_training.save_every_n_steps,
advanced_training.save_last_n_steps,
advanced_training.save_last_n_steps_state,
advanced_training.save_last_n_epochs,
advanced_training.save_last_n_epochs_state,
advanced_training.skip_cache_check,
advanced_training.log_with,
Expand Down
5 changes: 5 additions & 0 deletions kohya_gui/finetune_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def save_configuration(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -386,6 +387,7 @@ def open_configuration(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -605,6 +607,7 @@ def train_model(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -1051,6 +1054,7 @@ def train_model(
"save_last_n_steps_state": (
save_last_n_steps_state if save_last_n_steps_state != 0 else None
),
"save_last_n_epochs": save_last_n_epochs if save_last_n_epochs != 0 else None,
"save_last_n_epochs_state": (
save_last_n_epochs_state if save_last_n_epochs_state != 0 else None
),
Expand Down Expand Up @@ -1475,6 +1479,7 @@ def list_presets(path):
advanced_training.save_every_n_steps,
advanced_training.save_last_n_steps,
advanced_training.save_last_n_steps_state,
advanced_training.save_last_n_epochs,
advanced_training.save_last_n_epochs_state,
advanced_training.skip_cache_check,
advanced_training.log_with,
Expand Down
5 changes: 5 additions & 0 deletions kohya_gui/lora_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def save_configuration(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -450,6 +451,7 @@ def open_configuration(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -749,6 +751,7 @@ def train_model(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -1505,6 +1508,7 @@ def train_model(
"save_last_n_steps_state": (
save_last_n_steps_state if save_last_n_steps_state != 0 else None
),
"save_last_n_epochs": save_last_n_epochs if save_last_n_epochs != 0 else None,
"save_last_n_epochs_state": (
save_last_n_epochs_state if save_last_n_epochs_state != 0 else None
),
Expand Down Expand Up @@ -2648,6 +2652,7 @@ def update_LoRA_settings(
advanced_training.save_every_n_steps,
advanced_training.save_last_n_steps,
advanced_training.save_last_n_steps_state,
advanced_training.save_last_n_epochs,
advanced_training.save_last_n_epochs_state,
advanced_training.skip_cache_check,
advanced_training.log_with,
Expand Down
5 changes: 5 additions & 0 deletions kohya_gui/textual_inversion_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def save_configuration(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -323,6 +324,7 @@ def open_configuration(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -481,6 +483,7 @@ def train_model(
save_every_n_steps,
save_last_n_steps,
save_last_n_steps_state,
save_last_n_epochs,
save_last_n_epochs_state,
skip_cache_check,
log_with,
Expand Down Expand Up @@ -845,6 +848,7 @@ def train_model(
"save_last_n_steps_state": (
save_last_n_steps_state if save_last_n_steps_state != 0 else None
),
"save_last_n_epochs": save_last_n_epochs if save_last_n_epochs != 0 else None,
"save_last_n_epochs_state": (
save_last_n_epochs_state if save_last_n_epochs_state != 0 else None
),
Expand Down Expand Up @@ -1226,6 +1230,7 @@ def list_embedding_files(path):
advanced_training.save_every_n_steps,
advanced_training.save_last_n_steps,
advanced_training.save_last_n_steps_state,
advanced_training.save_last_n_epochs,
advanced_training.save_last_n_epochs_state,
advanced_training.skip_cache_check,
advanced_training.log_with,
Expand Down

0 comments on commit 021c6f5

Please sign in to comment.