[feature]: add partial prompt support to `blend` syntax
Is there an existing issue for this?
- [X] I have searched the existing issues
OS
Linux
GPU
cuda
VRAM
24
What happened?
Prompt with further terms beyond the 'blend' syntax results in a ParseException error server-side.
e.g. ("deer","raptor").blend(1,2) bad pencil drawing
>> Image generation requested: {'prompt': '("deer","raptor").blend(1,2) bad pencil drawing', 'iterations': 1, 'steps': 32, 'cfg_scale': 7.5, 'threshold': 0, 'perlin': 0, 'height': 512, 'width': 512, 'sampler_name': 'k_euler_a', 'seed': 1046506886, 'progress_images': False, 'progress_latents': True, 'save_intermediates': 5, 'generation_mode': 'txt2img', 'init_mask': '...', 'seamless': False, 'hires_fix': False, 'variation_amount': 0}
ESRGAN parameters: {'level': 2, 'strength': 0.4}
Facetool parameters: False
{'prompt': '("deer","raptor").blend(1,2) bad pencil drawing', 'iterations': 1, 'steps': 32, 'cfg_scale': 7.5, 'threshold': 0, 'perlin': 0, 'height': 512, 'width': 512, 'sampler_name': 'k_euler_a', 'seed': 1046506886, 'progress_images': False, 'progress_latents': True, 'save_intermediates': 5, 'generation_mode': 'txt2img', 'init_mask': '', 'seamless': False, 'hires_fix': False, 'variation_amount': 0}
Expected {explicit_conjunction | {{blend | Group:([{cross_attention_substitute | attention | Forward: string enclosed in '"' | parenthesized_fragment | free_word | Suppress:(<SP><TAB><CR><LF>)}]...)} StringEnd}}, found 'bad' (at char 29), (line:1, col:30)
Traceback (most recent call last):
File "/home/fortyseven/opt/ai/invoke-ai/backend/invoke_ai_web_server.py", line 1116, in generate_images
self.generate.prompt2image(
File "/home/fortyseven/opt/ai/invoke-ai/ldm/generate.py", line 456, in prompt2image
uc, c, extra_conditioning_info = get_uc_and_c_and_ec(
File "/home/fortyseven/opt/ai/invoke-ai/ldm/invoke/conditioning.py", line 47, in get_uc_and_c_and_ec
parsed_prompt = pp.parse_conjunction(prompt_string_cleaned).prompts[0]
File "/home/fortyseven/opt/ai/invoke-ai/ldm/invoke/prompt_parser.py", line 273, in parse_conjunction
root = self.conjunction.parse_string(prompt)
File "/home/fortyseven/opt/ai/invoke-ai/venv/lib/python3.10/site-packages/pyparsing/core.py", line 1141, in parse_string
raise exc.with_traceback(None)
pyparsing.exceptions.ParseException: Expected {explicit_conjunction | {{blend | Group:([{cross_attention_substitute | attention | Forward: string enclosed in '"' | parenthesized_fragment | free_word | Suppress:(<SP><TAB><CR><LF>)}]...)} StringEnd}}, found 'bad' (at char 29), (line:1, col:30)
Noticed on 8999a5564bf940f89327ef00bf2b83a2069965b5.
Additionally I've noticed putting terms BEFORE the blend tends to mess with the expected results.
For instance, in the given example, if it's rewritten as bad pencil drawing ("deer","raptor").blend(1,2), only imagery of deer/buck/etc are generated.
And for those wondering... bad pencil drawing, deer raptor... :wink:

at the moment blend only supports blending entire prompts. there is an existing feature request/discussion to introduce what you need, #1273.
Actually that's a "discussion" rather than a feature request per se. i'll leave this open.
Ah, okay -- now that I've re-read the docs with that in mind, I realize those are intended to be entire prompts, not just blended terms of a single prompt. :ok_hand:
yeah the docs were adapted in a rush from notes on the Pull Request where I first implemented the new prompt synax (the blend feature was around already) - been meaning to re-do them but haven't found the time.