Skip to content

Fix loaded_token reference before definition#3523

Merged
patrickvonplaten merged 1 commit into
huggingface:mainfrom
eminn:patch-1
May 26, 2023
Merged

Fix loaded_token reference before definition#3523
patrickvonplaten merged 1 commit into
huggingface:mainfrom
eminn:patch-1

Conversation

@eminn

@eminn eminn commented May 23, 2023

Copy link
Copy Markdown
Contributor

The below check fails when token is provided for loading textual inversion from a file (e.g. safetensors) as loaded_token variable is not defined.

if token is not None and loaded_token != token:
    logger.info(f"The loaded token: {loaded_token} is overwritten by the passed token {token}.")
else:
    token = loaded_token

Fails with:

  File "/zzzzz", line 699, in load_textual_inversion
    if token is not None and loaded_token != token:
       │                                     └ 'zzzz'
       └ 'zzzz'

UnboundLocalError: cannot access local variable 'loaded_token' where it is not associated with a value

@HuggingFaceDocBuilderDev

HuggingFaceDocBuilderDev commented May 23, 2023

Copy link
Copy Markdown

The documentation is not available anymore as the PR was closed or merged.

@eminn

eminn commented May 23, 2023

Copy link
Copy Markdown
Contributor Author

@williamberman do you mind having a look, it's a one-liner blocking us to use textual inversions

@williamberman williamberman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I think this is right, cc @patrickvonplaten can you double check, I'm not as familiar with this part of the code

@pcuenca pcuenca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@patrickvonplaten

Copy link
Copy Markdown
Contributor

Great!

@patrickvonplaten patrickvonplaten merged commit d8ce53a into huggingface:main May 26, 2023
@eminn eminn deleted the patch-1 branch May 26, 2023 09:34
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants