Skip to content

Commit

Permalink
add load tokenizers from pretrained_model_name_or_path if available
Browse files Browse the repository at this point in the history
  • Loading branch information
heyalexchoi committed Jun 15, 2024
1 parent fa9c4be commit 19e38df
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions library/sdxl_train_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ def _load_target_model(
def load_tokenizers(args: argparse.Namespace):
logger.info("prepare tokenizers")

# load diffusers tokenizers if available
name_or_path = args.pretrained_model_name_or_path
if os.path.isdir(name_or_path):
tokenizer_path = os.path.join(name_or_path, "tokenizer")
tokenizer_2_path = os.path.join(name_or_path, "tokenizer_2")
if os.path.exists(tokenizer_path) \
and os.path.exists(tokenizer_2_path):
logger.info(f"load tokenizers from pretrained_model_name_or_path: {name_or_path}")
tokeniers = [
CLIPTokenizer.from_pretrained(tokenizer_path),
CLIPTokenizer.from_pretrained(tokenizer_2_path),
]
return tokeniers

original_paths = [TOKENIZER1_PATH, TOKENIZER2_PATH]
tokeniers = []
for i, original_path in enumerate(original_paths):
Expand Down

0 comments on commit 19e38df

Please sign in to comment.