| """ |
| Centralized default values for HomePilot. |
| |
| This file contains constants that should be used consistently across |
| the application. Modify these values to change behavior globally. |
| """ |
|
|
| |
| |
| |
|
|
| |
| |
| ANTI_DUPLICATE_TERMS = ( |
| "multiple people, two heads, fused face, split view, collage" |
| ) |
|
|
| |
| |
| QUALITY_NEGATIVE_TERMS = ( |
| "blurry, low quality, worst quality, text, watermark, " |
| "bad anatomy, jpeg artifacts" |
| ) |
|
|
| |
| |
| DEFAULT_NEGATIVE_PROMPT = f"{QUALITY_NEGATIVE_TERMS}, {ANTI_DUPLICATE_TERMS}" |
|
|
| |
| DEFAULT_NEGATIVE_PROMPT_SHORT = ( |
| "blurry, low quality, bad anatomy, multiple people, two heads, split view" |
| ) |
|
|
|
|
| def enhance_negative_prompt(negative: str | None) -> str: |
| """ |
| Ensure a negative prompt includes anti-duplicate terms. |
| |
| If the provided negative prompt is empty, weak, or missing anti-duplicate |
| terms, this function will enhance it with the standard terms. |
| |
| Args: |
| negative: The original negative prompt (can be None or empty) |
| |
| Returns: |
| Enhanced negative prompt with anti-duplicate terms |
| """ |
| if not negative or not negative.strip(): |
| return DEFAULT_NEGATIVE_PROMPT |
|
|
| negative_lower = negative.lower() |
|
|
| |
| weak_patterns = [ |
| "avoid blurry", |
| "avoid low", |
| "no blurry", |
| "without blur", |
| ] |
| is_weak = any(pattern in negative_lower for pattern in weak_patterns) |
|
|
| |
| |
| has_anti_duplicate = any(term in negative_lower for term in [ |
| "two heads", "split view", "fused face" |
| ]) |
|
|
| if is_weak: |
| |
| return DEFAULT_NEGATIVE_PROMPT |
|
|
| if not has_anti_duplicate: |
| |
| return f"{negative}, {ANTI_DUPLICATE_TERMS}" |
|
|
| return negative |
|
|