Skip to content

Commit

Permalink
fix(api): better logging when converting textual inversions
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Mar 2, 2023
1 parent 46aac26 commit 9a0d205
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/onnx_web/convert/diffusion/textual_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def convert_diffusion_textual_inversion(
# separate token and embeds
trained_token = list(string_to_token.keys())[0]
embeds = string_to_param[trained_token]
else:
raise ValueError(f"unknown textual inversion format: {format}")

logger.info("found embedding for token %s: %s", trained_token, embeds.shape)

Expand Down Expand Up @@ -88,8 +90,10 @@ def convert_diffusion_textual_inversion(
return_tensors="pt",
)

logger.info("saving tokenizer for textual inversion")
tokenizer.save_pretrained(path.join(dest_path, "tokenizer"))

logger.info("saving text encoder for textual inversion")
export(
text_encoder,
# casting to torch.int32 until the CLIP fix is released: https://github.com/huggingface/transformers/pull/18515/files
Expand All @@ -103,3 +107,5 @@ def convert_diffusion_textual_inversion(
do_constant_folding=True,
opset_version=context.opset,
)

logger.info("textual inversion saved to %s", dest_path)

0 comments on commit 9a0d205

Please sign in to comment.