acorderob / sd-webui-prompt-postprocessor

Stable Diffusion WebUI & ComfyUI extension to post-process the prompt, including sending content from the prompt to the negative prompt and wildcards.
MIT License
23 stars 1 forks source link

[Issue] prompt # we ignore weight and any other paramet #7

Closed DivanoDova closed 8 months ago

DivanoDova commented 8 months ago

When i try to use the extension i have this issue with the latest version.

Everything worked well using v2.1.5

* Error running process: C:\amd_sd\stable-diffusion-webui-directml\extensions\sd-webui-prompt-postprocessor\scripts\ppp_script.py Traceback (most recent call last): File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\load_grammar.py", line 961, in _parse_grammar tree = _get_parser().parse(text + '\n', start) File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\parser_frontends.py", line 96, in parse return self.parser.parse(stream, chosen_start, kw) File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\parsers\lalr_parser.py", line 41, in parse return self.parser.parse(lexer, start) File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\parsers\lalr_parser.py", line 171, in parse return self.parse_from_state(parser_state) File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\parsers\lalr_parser.py", line 188, in parse_from_state raise e File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\parsers\lalr_parser.py", line 178, in parse_from_state for token in state.lexer.lex(state): File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\lexer.py", line 456, in lex yield self.next_token(state, parser_state) File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\lexer.py", line 466, in next_token raise UnexpectedCharacters(lex_state.text, line_ctr.char_pos, line_ctr.line, line_ctr.column, lark.exceptions.UnexpectedCharacters: No terminal matches '#' in the current parser context, at line 7 col 32

                choice: prompt # we ignore weight and any other paramet
                               ^
Expected one of:
    * OP
    * _OR
    * _LBRA
    * NUMBER
    * _DOT
    * _LPAR
    * _RPAR
    * _DECLARE
    * _NL_OR
    * TERMINAL
    * _COMMA
    * _TO
    * TILDE
    * RULE_MODIFIERS
    * _IMPORT
    * REGEXP
    * STRING
    * _LBRACE
    * _DOTDOT
    * _EXTEND
    * _RBRA
    * _RBRACE
    * _NL
    * _OVERRIDE
    * _IGNORE
    * _COLON
    * RULE

Previous tokens: Token('RULE', 'prompt')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\amd_sd\stable-diffusion-webui-directml\modules\scripts.py", line 718, in process
    script.process(p, *script_args)
  File "C:\amd_sd\stable-diffusion-webui-directml\extensions\sd-webui-prompt-postprocessor\scripts\ppp_script.py", line 88, in process
    ppp = PromptPostProcessor(self, opts, is_i2i)
  File "C:\amd_sd\stable-diffusion-webui-directml\extensions\sd-webui-prompt-postprocessor\ppp.py", line 98, in __init__
    self.__parser_complete = lark.Lark(
  File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\lark.py", line 333, in __init__
    self.grammar, used_files = load_grammar(grammar, self.source_path, self.options.import_paths, self.options.keep_all_tokens)
  File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\load_grammar.py", line 1408, in load_grammar
    builder.load_grammar(grammar, source)
  File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\load_grammar.py", line 1233, in load_grammar
    tree = _parse_grammar(grammar_text, grammar_name)
  File "C:\amd_sd\stable-diffusion-webui-directml\venv\lib\site-packages\lark\load_grammar.py", line 964, in _parse_grammar
    raise GrammarError("Unexpected input at line %d column %d in %s: \n\n%s" %
lark.exceptions.GrammarError: Unexpected input at line 7 column 32 in <string>:

                choice: prompt # we ignore weight and any other paramet
                               ^
acorderob commented 8 months ago

I think this is caused because you have an old version of the lark library (lower than 1.1.6) in your SD installation.

Can you check which one do you have? You need to activate the SD venv in a command prompt window (.\venv\Scripts\activate.bat or similar) and then run pip show lark.

But I will change the grammar in the next version so it doesn't give this problem.

If you do have an old version, you can probably fix the problem by updating manually the lark library or just resetting the venv folder.

DivanoDova commented 8 months ago

I was using lark v1.1.2 now i updated to 1.1.9 and still the same issue occurs

acorderob commented 8 months ago

Is it exactly the same error?

acorderob commented 8 months ago

I just released a new version. I hope it fixes the problem.

DivanoDova commented 8 months ago

Don't know what you did but it look like it now works as intented, no error log and the negatives tags are now in negative prompts :)