Comments (2)
claude 3.5 told me how to fix it
- i asked
how do i fix this error?
. - it told me to mod the file
magic_prompt.py
. - i pasted the file's content and asked how to modify to fix it.
amazingly it gave me this working code to replace with:
import re
from itertools import zip_longest
import torch
from dynamicprompts.generators.magicprompt import MagicPromptGenerator
from sd_dynamic_prompts.special_syntax import (
append_chunks,
remove_a1111_special_syntax_chunks,
)
def massage_prompt(prompt: str) -> str:
# Coalesce repeated punctuation to a single instance
prompt = re.sub(r"([.,])\1+", r"\1", prompt)
# Remove leading/trailing whitespace
prompt = prompt.strip()
return prompt
class SpecialSyntaxAwareMagicPromptGenerator(MagicPromptGenerator):
"""
Magic Prompt generator that is aware of A1111 special syntax (LoRA, hypernet, etc.).
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
self.model.to(self.device)
def _generate_magic_prompts(self, orig_prompts: list[str]) -> list[str]:
orig_prompts, chunks = zip(
*(remove_a1111_special_syntax_chunks(p) for p in orig_prompts),
)
# Move input to the correct device
input_ids = self.tokenizer(list(orig_prompts), return_tensors="pt", padding=True).input_ids
input_ids = input_ids.to(self.device)
# Generate the magic prompts
with torch.no_grad():
output = self.model.generate(
input_ids,
max_length=100,
num_return_sequences=1,
no_repeat_ngram_size=2
)
# Decode the output
magic_prompts = self.tokenizer.batch_decode(output, skip_special_tokens=True)
# Massage the prompts
magic_prompts = [massage_prompt(prompt) for prompt in magic_prompts]
# Append chunks and return
return [
append_chunks(prompt, chunk)
for prompt, chunk in zip_longest(magic_prompts, chunks, fillvalue=None)
]
so if anyone has the same error as me and wants to fix it: just overwrite/replace the above code into \stable-diffusion-webui-forge\extensions\sd-dynamic-prompts\sd_dynamic_prompts\magic_prompt.py
, save it and restart forge
from sd-dynamic-prompts.
Thanks for sharing the fix, had the same problem!
from sd-dynamic-prompts.
Related Issues (20)
- save wildcards hash in pnginfo HOT 1
- bug: min range not work HOT 2
- Nested Wildcards
- bug:Using the Choosing Multiple Values function with dynamic prompts in ComfyUI does not work.
- Unable to compare LORA strenghs - Only first value used
- Error running process HOT 4
- Move the `Dynamic Prompts enabled` to the accordion label
- prompt matrix broken when enable dynamic-prompts HOT 2
- Bug: Issue with dynamic prompts + hi-res fix + batch count > 1 (in A1111 / unclear beyond that)
- [Documentation Question] Is single asterisk after path separator incorrect?
- support load all "extensions/*/wildcards" HOT 2
- Problem with seeds being fixed when running random scripts
- wildcards not working... parsing error HOT 1
- feature request: Extra path to scan for wildcard files HOT 1
- Error running process for Magic Prompt
- Save original prompt [feature request] (easy fix) HOT 1
- variables in wildcards doesn't apply to upper scope same-name variable HOT 1
- Doesn't work when the LoRA has "__" on it's name HOT 3
- Error ((((( Help me please
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sd-dynamic-prompts.