poetic / tests /test_styles.py
yooi's picture
Upload folder using huggingface_hub
1a6e48a verified
Raw
History Blame Contribute Delete
1.97 kB
from poetic.styles import DEFAULT_IMAGE_STYLE, apply_image_style, is_image_style_id
def test_recognizes_only_supported_style_ids():
assert is_image_style_id("inkWash") is True
assert is_image_style_id("posterColor") is True
assert is_image_style_id("oilPainting") is False
def test_appends_curated_style_clause():
brief = apply_image_style("A lotus pond at dawn.", "watercolor")
assert "A lotus pond at dawn." in brief
assert "selected visual style is authoritative" in brief
assert "soft transparent watercolor painting" in brief
def test_realistic_style_overrides_chinese_painting_wording():
brief = apply_image_style("A shui-mo Chinese painting of red flowers.", "realistic")
assert "Selected style / 已选画风: Realistic / 写实" in brief
assert "selection is mandatory" in brief
assert "Avoid stylized Chinese painting" in brief
assert "red flowers" in brief
assert "A shui-mo Chinese painting of red flowers." not in brief
def test_removes_conflicting_art_direction_words_from_realistic_prompts():
brief = apply_image_style(
"A watercolor Chinese ink-wash shan-shui painting of red blossoms"
" on antique paper with decorative seal motifs.",
"realistic",
)
marker = "Real-world scene description extracted from the poem, with conflicting art-style words removed:"
cleaned_scene = brief.split(marker)[1].split("Make it look like a believable real-world scene first")[0]
assert "red blossoms" in cleaned_scene
assert "believable real-world scene" in brief
assert "on with" not in cleaned_scene
assert "watercolor Chinese ink-wash shan-shui painting" not in cleaned_scene
assert "antique paper" not in cleaned_scene
assert "decorative seal motifs" not in cleaned_scene
def test_defaults_to_watercolor():
assert DEFAULT_IMAGE_STYLE == "watercolor"
assert "soft transparent watercolor painting" in apply_image_style("A mountain.")