Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] Automatically print token being modified (and by how much) when generating an image #4

Open
lendrick opened this issue Sep 10, 2022 · 1 comment

Comments

@lendrick
Copy link

I was getting some nonsensical results for a little while until it occurred to me that some words are multiple tokens (and punctuation, etc, are tokens as well).

Here's some code I'm using to do it:

        #Process prompt editing
        if prompt_edit is not None:
            tokens_conditional_edit = clip_tokenizer(prompt_edit, padding="max_length", max_length=clip_tokenizer.model_max_length, truncation=True, return_tensors="pt", return_overflowing_tokens=True)
            embedding_conditional_edit = clip(tokens_conditional_edit.input_ids.to(device)).last_hidden_state
            
            init_attention_edit(tokens_conditional, tokens_conditional_edit)
            
            #My code starts here
            for t in prompt_edit_token_weights:
                token_word = prompt_token(prompt_edit, t[0])
                print(f"{token_word}: {t[1]}")
        else:
            for t in prompt_edit_token_weights:
                token_word = prompt_token(prompt, t[0])
                print(f"{token_word}: {t[1]}")

Probably ought to check and make sure I'm not misunderstanding anything, but it appears to work.

@bloc97
Copy link
Owner

bloc97 commented Sep 10, 2022

Yeah, I'll get back to working on it during the week. Adding a more intuitive prompt editing method, such as using brackets (eg. a landscape of (mountains:-10) with (rivers and trees:+3)) would be for me one of the high priority improvements that can be added.

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

No branches or pull requests

2 participants