Skip to content

Commit 23ad1a2

Browse files
dxqbclaude
andcommitted
Merge ctk_copy: LoKr support, Scaled OFT, ETA fix, row counter fix; keep ctk_abstraction for UI conflicts
- Apply LoKr and Scaled OFT additions to BaseLoraTabView/LoraTabController - Apply ETA session-tracking fix to TrainUIController - Apply local row counter fix to BaseTrainingTabView.__create_text_encoder_frame - Keep both supported_caption_extensions and json_path_modifier in path_util Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2 parents 19b5724 + c602458 commit 23ad1a2

30 files changed

Lines changed: 555 additions & 52 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414
- id: check-yaml
1515

1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.15.12
17+
rev: v0.15.14
1818
hooks:
1919
# Run the Ruff linter, but not the formatter.
2020
- id: ruff

modules/cloud/BaseCloud.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from abc import ABCMeta, abstractmethod
33
from pathlib import Path
44

5+
from modules.util import path_util
56
from modules.util.callbacks.TrainCallbacks import TrainCallbacks
67
from modules.util.commands.TrainCommands import TrainCommands
78
from modules.util.config.CloudConfig import CloudConfig
@@ -54,6 +55,7 @@ def upload_config(self,commands : TrainCommands=None):
5455
if hasattr(add_embedding,"local_model_name"):
5556
self.file_sync.sync_up(local=Path(add_embedding.local_model_name),remote=Path(add_embedding.model_name))
5657

58+
concept_extensions = path_util.supported_image_extensions() | path_util.supported_video_extensions() | path_util.supported_caption_extensions()
5759
for concept in self.config.concepts:
5860
print(f"uploading concept {concept.name}...")
5961
if commands and commands.get_stop_command():
@@ -63,11 +65,16 @@ def upload_config(self,commands : TrainCommands=None):
6365
self.file_sync.sync_up_dir(
6466
local=Path(concept.local_path),
6567
remote=Path(concept.path),
66-
recursive=concept.include_subdirectories)
68+
recursive=concept.include_subdirectories,
69+
skip_hidden=True,
70+
allowed_extensions=concept_extensions)
6771

6872
if hasattr(concept.text,"local_prompt_path"):
6973
self.file_sync.sync_up_file(local=Path(concept.text.local_prompt_path),remote=Path(concept.text.prompt_path))
7074

75+
if hasattr(concept.text,"local_tag_dropout_special_tags"):
76+
self.file_sync.sync_up_file(local=Path(concept.text.local_tag_dropout_special_tags),remote=Path(concept.text.tag_dropout_special_tags))
77+
7178
@staticmethod
7279
def _filter_download(config : CloudConfig,path : Path):
7380
if 'samples' in path.parts:

modules/cloud/BaseFileSync.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def sync_up_file(self,local : Path,remote : Path):
2525
pass
2626

2727
@abstractmethod
28-
def sync_up_dir(self,local : Path,remote: Path,recursive: bool):
28+
def sync_up_dir(self,local : Path,remote: Path,recursive: bool,sync_info=None,
29+
skip_hidden: bool=False, allowed_extensions: set[str] | None=None):
2930
pass
3031

3132
@abstractmethod

modules/cloud/BaseSSHFileSync.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,26 @@ def sync_up_file(self,local : Path,remote : Path):
4646
self.upload_file(local_file=local,remote_file=remote)
4747

4848

49-
def sync_up_dir(self,local : Path,remote: Path,recursive: bool,sync_info=None):
49+
def sync_up_dir(self,local : Path,remote: Path,recursive: bool,sync_info=None,
50+
skip_hidden: bool=False, allowed_extensions: set[str] | None=None):
5051
if sync_info is None:
5152
sync_info=self.__get_sync_info(remote)
5253
self.sync_connection.open()
5354
self.sync_connection.run(f'mkdir -p {shlex.quote(remote.as_posix())}',in_stream=False)
5455
files=[]
5556
for local_entry in local.iterdir():
5657
if local_entry.is_file():
58+
if allowed_extensions is not None and local_entry.suffix.lower() not in allowed_extensions:
59+
continue
5760
remote_entry=remote/local_entry.name
5861
if self.__needs_upload(local=local_entry,remote=remote_entry,sync_info=sync_info):
5962
files.append(local_entry)
6063
elif recursive and local_entry.is_dir():
61-
self.sync_up_dir(local=local_entry,remote=remote/local_entry.name,recursive=True,sync_info=sync_info)
64+
if skip_hidden and local_entry.name.startswith('.'):
65+
continue
66+
self.sync_up_dir(local=local_entry,remote=remote/local_entry.name,recursive=True,
67+
sync_info=sync_info,skip_hidden=skip_hidden,
68+
allowed_extensions=allowed_extensions)
6269

6370
self.upload_files(local_files=files,remote_dir=remote)
6471

modules/dataLoader/FluxBaseDataLoader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _preparation_modules(self, config: TrainConfig, model: FluxModel):
4141
shuffle_mask_channels = ShuffleFluxFillMaskChannels(in_name='mask', out_name='latent_mask')
4242
encode_conditioning_image = EncodeVAE(in_name='conditioning_image', out_name='latent_conditioning_image_distribution', vae=model.vae, autocast_contexts=[model.autocast_context], dtype=model.train_dtype.torch_dtype())
4343
conditioning_image_sample = SampleVAEDistribution(in_name='latent_conditioning_image_distribution', out_name='latent_conditioning_image', mode='mean')
44-
tokenize_prompt_1 = Tokenize(in_name='prompt_1', tokens_out_name='tokens_1', mask_out_name='tokens_mask_1', tokenizer=model.tokenizer_1, max_token_length=model.tokenizer_1.model_max_length)
44+
tokenize_prompt_1 = Tokenize(in_name='prompt_1', tokens_out_name='tokens_1', mask_out_name='tokens_mask_1', tokenizer=model.tokenizer_1, max_token_length=77)
4545
tokenize_prompt_2 = Tokenize(in_name='prompt_2', tokens_out_name='tokens_2', mask_out_name='tokens_mask_2', tokenizer=model.tokenizer_2, max_token_length=config.text_encoder_2_sequence_length)
4646
encode_prompt_1 = EncodeClipText(in_name='tokens_1', tokens_attention_mask_in_name=None, hidden_state_out_name='text_encoder_1_hidden_state', pooled_out_name='text_encoder_1_pooled_state',
4747
add_layer_norm=False, text_encoder=model.text_encoder_1, hidden_state_output_index=-(2 + config.text_encoder_layer_skip), autocast_contexts=[model.autocast_context],

modules/model/ChromaModel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def encode_text(
208208
)
209209

210210
# apply dropout FIXME not a real dropout
211-
if text_encoder_dropout_probability is not None:
211+
if text_encoder_dropout_probability is not None and text_encoder_dropout_probability > 0.0:
212212
dropout_text_encoder_mask = (torch.tensor(
213213
[rand.random() > text_encoder_dropout_probability for _ in range(batch_size)],
214214
device=train_device)).float()

modules/model/FluxModel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,13 @@ def encode_text(
287287
)
288288

289289
# apply dropout
290-
if text_encoder_1_dropout_probability is not None:
290+
if text_encoder_1_dropout_probability is not None and text_encoder_1_dropout_probability > 0.0:
291291
dropout_text_encoder_1_mask = (torch.tensor(
292292
[rand.random() > text_encoder_1_dropout_probability for _ in range(batch_size)],
293293
device=train_device)).float()
294294
pooled_text_encoder_1_output = pooled_text_encoder_1_output * dropout_text_encoder_1_mask[:, None]
295295

296-
if text_encoder_2_dropout_probability is not None:
296+
if text_encoder_2_dropout_probability is not None and text_encoder_2_dropout_probability > 0.0:
297297
dropout_text_encoder_2_mask = (torch.tensor(
298298
[rand.random() > text_encoder_2_dropout_probability for _ in range(batch_size)],
299299
device=train_device)).float()

modules/model/HiDreamModel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,26 +442,26 @@ def encode_text(
442442
# )
443443

444444
# apply dropout
445-
if text_encoder_1_dropout_probability is not None:
445+
if text_encoder_1_dropout_probability is not None and text_encoder_1_dropout_probability > 0.0:
446446
dropout_text_encoder_1_mask = (torch.tensor(
447447
[rand.random() > text_encoder_1_dropout_probability for _ in range(batch_size)],
448448
device=train_device)).float()
449449
pooled_text_encoder_1_output = pooled_text_encoder_1_output * dropout_text_encoder_1_mask[:, None]
450450

451-
if text_encoder_2_dropout_probability is not None:
451+
if text_encoder_2_dropout_probability is not None and text_encoder_2_dropout_probability > 0.0:
452452
dropout_text_encoder_2_mask = (torch.tensor(
453453
[rand.random() > text_encoder_2_dropout_probability for _ in range(batch_size)],
454454
device=train_device)).float()
455455
pooled_text_encoder_2_output = pooled_text_encoder_2_output * dropout_text_encoder_2_mask[:, None]
456456

457-
if text_encoder_3_dropout_probability is not None:
457+
if text_encoder_3_dropout_probability is not None and text_encoder_3_dropout_probability > 0.0:
458458
dropout_text_encoder_3_mask = (torch.tensor(
459459
[rand.random() > text_encoder_3_dropout_probability for _ in range(batch_size)],
460460
device=train_device)).float()
461461
text_encoder_3_output = text_encoder_3_output * dropout_text_encoder_3_mask[:, None, None]
462462

463463
text_encoder_4_output = torch.stack(text_encoder_4_output, dim=0)
464-
if text_encoder_4_dropout_probability is not None:
464+
if text_encoder_4_dropout_probability is not None and text_encoder_4_dropout_probability > 0.0:
465465
dropout_text_encoder_4_mask = (torch.tensor(
466466
[rand.random() > text_encoder_4_dropout_probability for _ in range(batch_size)],
467467
device=train_device)).float()

modules/model/HunyuanVideoModel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,13 @@ def encode_text(
300300
)
301301

302302
# apply dropout
303-
if text_encoder_1_dropout_probability is not None:
303+
if text_encoder_1_dropout_probability is not None and text_encoder_1_dropout_probability > 0.0:
304304
dropout_text_encoder_1_mask = (torch.tensor(
305305
[rand.random() > text_encoder_1_dropout_probability for _ in range(batch_size)],
306306
device=train_device)).float()
307307
text_encoder_1_output = text_encoder_1_output * dropout_text_encoder_1_mask[:, None, None]
308308

309-
if text_encoder_2_dropout_probability is not None:
309+
if text_encoder_2_dropout_probability is not None and text_encoder_2_dropout_probability > 0.0:
310310
dropout_text_encoder_2_mask = (torch.tensor(
311311
[rand.random() > text_encoder_2_dropout_probability for _ in range(batch_size)],
312312
device=train_device)).float()

modules/model/PixArtAlphaModel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def encode_text(
211211
)
212212

213213
# apply dropout
214-
if text_encoder_dropout_probability is not None:
214+
if text_encoder_dropout_probability is not None and text_encoder_dropout_probability > 0.0:
215215
dropout_text_encoder_mask = (torch.tensor(
216216
[rand.random() > text_encoder_dropout_probability for _ in range(batch_size)],
217217
device=train_device)).float()

0 commit comments

Comments
 (0)