mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Negative / Unconditioned Prompts (#661)
Co-Authored-By: rabidcopy <8052832+rabidcopy@users.noreply.github.com> Co-authored-by: rabidcopy <8052832+rabidcopy@users.noreply.github.com>
This commit is contained in:
parent
b68cb521ba
commit
0a4397094e
@ -2,15 +2,16 @@
|
||||
title: Contributors
|
||||
---
|
||||
|
||||
The list of all the amazing people who have contributed to the various features that you get to experience in this fork.
|
||||
The list of all the amazing people who have contributed to the various features that you get to
|
||||
experience in this fork.
|
||||
|
||||
We thank them for all of their time and hard work.
|
||||
|
||||
## __Original Author:__
|
||||
## **Original Author:**
|
||||
|
||||
- [Lincoln D. Stein](mailto:lincoln.stein@gmail.com)
|
||||
|
||||
## __Contributions by:__
|
||||
## **Contributions by:**
|
||||
|
||||
- [Sean McLellan](https://github.com/Oceanswave)
|
||||
- [Kevin Gibbons](https://github.com/bakkot)
|
||||
@ -52,8 +53,9 @@ We thank them for all of their time and hard work.
|
||||
- [Doggettx](https://github.com/doggettx)
|
||||
- [Matthias Wild](https://github.com/mauwii)
|
||||
- [Kyle Schouviller](https://github.com/kyle0654)
|
||||
- [rabidcopy](https://github.com/rabidcopy)
|
||||
|
||||
## __Original CompVis Authors:__
|
||||
## **Original CompVis Authors:**
|
||||
|
||||
- [Robin Rombach](https://github.com/rromb)
|
||||
- [Patrick von Platen](https://github.com/patrickvonplaten)
|
||||
@ -65,4 +67,5 @@ We thank them for all of their time and hard work.
|
||||
|
||||
---
|
||||
|
||||
_If you have contributed and don't see your name on the list of contributors, please let one of the collaborators know about the omission, or feel free to make a pull request._
|
||||
_If you have contributed and don't see your name on the list of contributors, please let one of the
|
||||
collaborators know about the omission, or feel free to make a pull request._
|
||||
|
@ -13,7 +13,20 @@ import re
|
||||
import torch
|
||||
|
||||
def get_uc_and_c(prompt, model, log_tokens=False, skip_normalize=False):
|
||||
uc = model.get_learned_conditioning([''])
|
||||
# Extract Unconditioned Words From Prompt
|
||||
unconditioned_words = ''
|
||||
unconditional_regex = r'\[(.*?)\]'
|
||||
unconditionals = re.findall(unconditional_regex, prompt)
|
||||
|
||||
if len(unconditionals) > 0:
|
||||
unconditioned_words = ' '.join(unconditionals)
|
||||
|
||||
# Remove Unconditioned Words From Prompt
|
||||
unconditional_regex_compile = re.compile(unconditional_regex)
|
||||
clean_prompt = unconditional_regex_compile.sub(' ', prompt)
|
||||
prompt = re.sub(' +', ' ', clean_prompt)
|
||||
|
||||
uc = model.get_learned_conditioning([unconditioned_words])
|
||||
|
||||
# get weighted sub-prompts
|
||||
weighted_subprompts = split_weighted_subprompts(
|
||||
@ -34,6 +47,7 @@ def get_uc_and_c(prompt, model, log_tokens=False, skip_normalize=False):
|
||||
else: # just standard 1 prompt
|
||||
log_tokenization(prompt, model, log_tokens)
|
||||
c = model.get_learned_conditioning([prompt])
|
||||
uc = model.get_learned_conditioning([unconditioned_words])
|
||||
return (uc, c)
|
||||
|
||||
def split_weighted_subprompts(text, skip_normalize=False)->list:
|
||||
|
Loading…
Reference in New Issue
Block a user