31 lines
782 B
Python
31 lines
782 B
Python
from .tags import Tag, TagList
|
|
from .utils.project import get_project_info
|
|
|
|
|
|
class Pipeline:
|
|
"""
|
|
Pipeline that merges negative prompts into weighted positive prompts.
|
|
"""
|
|
|
|
def __init__(self):
|
|
self._displayName, self._version = get_project_info()
|
|
|
|
def run(self, positive: str, negative: str):
|
|
print(f"[{self._displayName} v{self._version}]")
|
|
result = TagList(positive)
|
|
|
|
# Combine the negatives.
|
|
for tag in TagList(negative):
|
|
pieces = [(text, -abs(weight)) for text, weight in tag.pieces]
|
|
result.append(Tag(True, tag.name, pieces))
|
|
|
|
# Log the output.
|
|
print(f"→ {result}")
|
|
return result
|
|
|
|
# Shared default instance.
|
|
DEFAULT: "Pipeline"
|
|
|
|
|
|
Pipeline.DEFAULT = Pipeline()
|