Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/compel/compel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import torch
from torch import Tensor
from transformers import CLIPTokenizer, CLIPTextModel
from pyparsing.exceptions import ParseException

from . import cross_attention_control
from .conditioning_scheduler import ConditioningScheduler, StaticConditioningScheduler
Expand Down Expand Up @@ -155,7 +156,10 @@ def parse_prompt_string(cls, prompt_string: str) -> Conjunction:
Parse the given prompt string and return a structured Conjunction object that represents the prompt it contains.
"""
pp = PromptParser()
conjunction = pp.parse_conjunction(prompt_string)
try:
conjunction = pp.parse_conjunction(prompt_string)
except ParseException:
return Conjunction(prompts=[FlattenedPrompt([(prompt_string, 1.0)])], weights=[1.0])
return conjunction

def describe_tokenization(self, text: str) -> List[str]:
Expand Down