比较提交

...
登录以创建新的合并请求。

1 提交

作者 SHA1 备注 提交日期
6e2d37b320 feat: add style profile v2 transfer pipeline 2026-07-22 00:03:52 +08:00
共有 14 个文件被更改,包括 211 次插入 和 53 次删除

查看文件

@ -1,3 +1,7 @@
## 1.0.67
- Introduce Style Profile V2 with region-level invariants, scale adapters, prompt budgeting, and structured consensus payloads for more faithful face, hair, linework, shading, clothing-rendering, and background transfer.
## 1.0.66 ## 1.0.66
- Complete P0-P2 style-profile hardening: decouple age and anatomy evidence, enforce review consistency caps, gate core traits by cross-context evidence, re-audit semantic rewrites, deduplicate scale capsules, use neutral validation scenes, add layered rendering review, improve score trust display, and block automatic adoption of regressed candidates. - Complete P0-P2 style-profile hardening: decouple age and anatomy evidence, enforce review consistency caps, gate core traits by cross-context evidence, re-audit semantic rewrites, deduplicate scale capsules, use neutral validation scenes, add layered rendering review, improve score trust display, and block automatic adoption of regressed candidates.

查看文件

@ -229,6 +229,12 @@ _LITERAL_SHAPE_NEGATIVE_GUARDS: tuple[str, ...] = (
# comparable across providers and prevents a visually attractive image from # comparable across providers and prevents a visually attractive image from
# receiving a high score while missing the actual line, face or shading grammar. # receiving a high score while missing the actual line, face or shading grammar.
STYLE_REVIEW_SCHEMA_VERSION = 3 STYLE_REVIEW_SCHEMA_VERSION = 3
STYLE_PROFILE_V2_SCHEMA_VERSION = 1
STYLE_PROFILE_V2_REGION_ORDER = (
"face", "eyes", "hair", "linework", "shading", "palette",
"clothing_rendering", "background_rendering", "texture", "anatomy",
)
STYLE_PROFILE_V2_PROMPT_BUDGET = 12
STYLE_REVIEW_DIMENSIONS: tuple[str, ...] = ( STYLE_REVIEW_DIMENSIONS: tuple[str, ...] = (
"face_structure", "face_structure",
"eye_design", "eye_design",
@ -1735,6 +1741,12 @@ class AdvancedStyleSetService:
), ),
"feature_evidence": _list(provider_result.get("feature_evidence")), "feature_evidence": _list(provider_result.get("feature_evidence")),
"color_hierarchy": _normalize_color_hierarchy(provider_result.get("color_hierarchy")), "color_hierarchy": _normalize_color_hierarchy(provider_result.get("color_hierarchy")),
"style_profile_v2": _build_style_profile_v2({
**provider_result,
**structures,
"artist_signature": provider_result.get("artist_signature"),
"color_hierarchy": _normalize_color_hierarchy(provider_result.get("color_hierarchy")),
}),
"prompt_priority_groups": _object(provider_result.get("prompt_priority_groups")), "prompt_priority_groups": _object(provider_result.get("prompt_priority_groups")),
"scale_capsules": _object(provider_result.get("scale_capsules")), "scale_capsules": _object(provider_result.get("scale_capsules")),
"semantic_risk_audit": _list(provider_result.get("semantic_risk_audit")), "semantic_risk_audit": _list(provider_result.get("semantic_risk_audit")),
@ -2290,6 +2302,7 @@ class AdvancedStyleSetService:
"generation_capsules": consensus.result.get("generation_capsules"), "generation_capsules": consensus.result.get("generation_capsules"),
"prompt_priority_groups": consensus.result.get("prompt_priority_groups"), "prompt_priority_groups": consensus.result.get("prompt_priority_groups"),
"scale_capsules": consensus.result.get("scale_capsules"), "scale_capsules": consensus.result.get("scale_capsules"),
"style_profile_v2": consensus.result.get("style_profile_v2"),
"semantic_risk_audit": consensus.result.get("semantic_risk_audit"), "semantic_risk_audit": consensus.result.get("semantic_risk_audit"),
"validation_content_prompt": case.content_prompt, "validation_content_prompt": case.content_prompt,
"actual_generation_prompt": case.final_prompt, "actual_generation_prompt": case.final_prompt,
@ -4036,6 +4049,111 @@ def _style_kernel_parts(payload: dict[str, Any]) -> list[str]:
return _unique_prompt_parts(result) return _unique_prompt_parts(result)
def _style_profile_v2_region(value: Any) -> str:
text = str(value or "").casefold()
markers = {
"face": ("face", "facial", "jaw", "chin", "cheek", "nose", "mouth"),
"eyes": ("eye", "iris", "pupil", "lash", "eyelid", "catchlight"),
"hair": ("hair", "strand", "bang", "fringe", "lock", "curl", "sheen", "highlight"),
"linework": ("line", "ink", "outline", "contour", "stroke"),
"shading": ("shadow", "shading", "cel", "gradient", "occlusion"),
"palette": ("palette", "color", "colour", "chroma", "saturation", "hue", "pink", "lavender"),
"clothing_rendering": ("clothing", "garment", "fabric", "frill", "lace", "fold", "accessor", "ornament"),
"background_rendering": ("background", "environment", "scene", "bokeh", "architecture", "atmosphere"),
"texture": ("texture", "grain", "brush", "surface", "paper", "noise"),
"anatomy": ("anatomy", "proportion", "silhouette", "limb", "head-to-body"),
}
for region in STYLE_PROFILE_V2_REGION_ORDER:
if any(marker in text for marker in markers[region]):
return region
return "texture"
def _style_profile_v2_add(target: dict[str, list[str]], value: Any, *, region: Any = None) -> None:
text = _clean_prompt_text(str(value or "").strip())
if not text:
return
selected = str(region or _style_profile_v2_region(text))
if selected not in STYLE_PROFILE_V2_REGION_ORDER:
selected = _style_profile_v2_region(text)
target.setdefault(selected, []).append(text)
def _build_style_profile_v2(payload: Any) -> dict[str, Any]:
data = payload if isinstance(payload, dict) else {}
evidence = _normalized_feature_evidence(data.get("feature_evidence"))
invariant_parts: dict[str, list[str]] = {region: [] for region in STYLE_PROFILE_V2_REGION_ORDER}
signatures = _normalize_artist_signature(data.get("artist_signature"), [])
for item in signatures:
if not isinstance(item, dict):
continue
phrase = item.get("phrase")
if _style_trait_is_supported(phrase, evidence, required=bool(evidence)):
_style_profile_v2_add(invariant_parts, phrase, region={
"face_structure": "face", "eye_design": "eyes", "hair_rendering": "hair",
"linework": "linework", "shading": "shading", "palette": "palette",
"highlights": "hair", "texture": "texture", "anatomy": "anatomy",
}.get(str(item.get("dimension") or "")))
profile = data.get("normalized_asset_profile") if isinstance(data.get("normalized_asset_profile"), dict) else {}
for phrase in _prompt_parts(profile.get("must_preserve")):
if _style_trait_is_supported(phrase, evidence, required=bool(evidence)):
_style_profile_v2_add(invariant_parts, phrase)
for phrase in _style_kernel_parts(data):
_style_profile_v2_add(invariant_parts, phrase)
for key, value in _normalize_color_hierarchy(data.get("color_hierarchy")).items():
_style_profile_v2_add(invariant_parts, f"{key.replace('_', ' ')}: {value}", region="palette")
attributes = profile.get("attributes") if isinstance(profile.get("attributes"), dict) else {}
for key, raw in attributes.items():
if not isinstance(raw, dict) or raw.get("transfer_role") != "style_structure":
continue
value = _optional_text(raw.get("value"))
if value:
_style_profile_v2_add(invariant_parts, value, region="face" if "facial" in str(key) else "anatomy")
invariants: dict[str, list[str]] = {}
for region in STYLE_PROFILE_V2_REGION_ORDER:
parts = _compact_style_prompt_parts(
[_strip_style_background_effects(_normalize_style_prompt_conflicts(item)) for item in invariant_parts[region]],
limit=2,
)
if parts:
invariants[region] = parts
adapters: dict[str, list[str]] = {}
raw_scales = data.get("scale_capsules") if isinstance(data.get("scale_capsules"), dict) else {}
for case_key in ("portrait", "fullbody", "novel_scene"):
raw = raw_scales.get(case_key)
parts = _prompt_parts(raw.get("prompt_parts") or raw.get("positive_additions")) if isinstance(raw, dict) else _prompt_parts(raw)
sanitized = []
for item in _split_prompt_clauses(parts):
safe, _ = _sanitize_minor_age_text(_normalize_style_prompt_conflicts(item))
safe = _strip_style_background_effects(safe)
if safe:
sanitized.append(safe)
if sanitized:
adapters[case_key] = _compact_style_prompt_parts(sanitized, limit=4)
variable = _unique_prompt_parts(
_optional_text(item.get("trait") if isinstance(item, dict) else item) or ""
for item in _list(data.get("variable_style_features"))
)
return {
"schema_version": STYLE_PROFILE_V2_SCHEMA_VERSION,
"invariants": invariants,
"adapters": adapters,
"variable_features": variable[:8],
"evidence_supported_count": sum(1 for item in evidence if item.get("supported")),
"region_order": list(STYLE_PROFILE_V2_REGION_ORDER),
}
def _style_profile_v2_prompt_parts(payload: dict[str, Any]) -> list[str]:
profile = payload.get("style_profile_v2") if isinstance(payload.get("style_profile_v2"), dict) else _build_style_profile_v2(payload)
invariants = profile.get("invariants") if isinstance(profile.get("invariants"), dict) else {}
parts: list[str] = []
for region in STYLE_PROFILE_V2_REGION_ORDER:
for item in _prompt_parts(invariants.get(region))[:2]:
parts.append(f"{region.replace('_', ' ')}: {item}")
return _compact_style_prompt_parts(parts, limit=STYLE_PROFILE_V2_PROMPT_BUDGET)
def _strip_style_background_effects(value: Any) -> str: def _strip_style_background_effects(value: Any) -> str:
text = str(value or "").strip() text = str(value or "").strip()
for pattern, replacement in _STYLE_BACKGROUND_EFFECT_PATTERNS: for pattern, replacement in _STYLE_BACKGROUND_EFFECT_PATTERNS:
@ -4084,11 +4202,12 @@ def _detailed_style_prompt(result: Any, fallback: Any) -> str:
required=bool(_VARIABLE_CONTENT_PATTERNS.search(item)), required=bool(_VARIABLE_CONTENT_PATTERNS.search(item)),
) )
] ]
profile_v2_parts = _style_profile_v2_prompt_parts(payload)
signature_parts = _artist_signature_prompt_parts(payload) signature_parts = _artist_signature_prompt_parts(payload)
color_hierarchy = payload.get("color_hierarchy") if isinstance(payload.get("color_hierarchy"), dict) else {} color_hierarchy = payload.get("color_hierarchy") if isinstance(payload.get("color_hierarchy"), dict) else {}
color_parts = [f"{key.replace('_', ' ')}: {value}" for key, value in color_hierarchy.items()] color_parts = [f"{key.replace('_', ' ')}: {value}" for key, value in color_hierarchy.items()]
# Priority groups are the compact style kernel; signatures and capsules are supplementary evidence. # Style Profile V2 is region-aware; legacy fields remain fallback evidence for old consensus records.
supplemental_parts = [*gated_must_preserve, *capsule_parts, *signature_parts, *color_parts] supplemental_parts = [*profile_v2_parts, *gated_must_preserve, *capsule_parts, *signature_parts, *color_parts]
# Structural age stylization / body-ratio cues are not optional traits; keep them even when # Structural age stylization / body-ratio cues are not optional traits; keep them even when
# feature_evidence only covers linework/eyes. Chronological age attributes stay excluded. # feature_evidence only covers linework/eyes. Chronological age attributes stay excluded.
for key, raw in (profile.get("attributes") or {}).items() if isinstance(profile.get("attributes"), dict) else []: for key, raw in (profile.get("attributes") or {}).items() if isinstance(profile.get("attributes"), dict) else []:
@ -4129,7 +4248,7 @@ def _detailed_style_prompt(result: Any, fallback: Any) -> str:
filtered.append(item) filtered.append(item)
rewritten = filtered rewritten = filtered
# Do not inject mature-adult body locks after scrubbing chronological-minor wording. # Do not inject mature-adult body locks after scrubbing chronological-minor wording.
compiled = _compact_style_prompt_parts(rewritten, limit=16) compiled = _compact_style_prompt_parts(rewritten, limit=STYLE_PROFILE_V2_PROMPT_BUDGET)
if compiled: if compiled:
return _join_prompt( return _join_prompt(
*compiled, *compiled,
@ -4170,12 +4289,16 @@ def _detailed_style_negative_prompt(result: Any, fallback: Any) -> str:
def _scale_specific_style_prompt(result: Any, case_key: str, common_prompt: Any = None) -> str: def _scale_specific_style_prompt(result: Any, case_key: str, common_prompt: Any = None) -> str:
payload = result if isinstance(result, dict) else {} payload = result if isinstance(result, dict) else {}
scales = payload.get("scale_capsules") if isinstance(payload.get("scale_capsules"), dict) else {} profile_v2 = payload.get("style_profile_v2") if isinstance(payload.get("style_profile_v2"), dict) else _build_style_profile_v2(payload)
raw = scales.get(case_key) adapters = profile_v2.get("adapters") if isinstance(profile_v2.get("adapters"), dict) else {}
if isinstance(raw, dict): parts = _prompt_parts(adapters.get(case_key))
parts = _prompt_parts(raw.get("prompt_parts") or raw.get("positive_additions")) if not parts:
else: scales = payload.get("scale_capsules") if isinstance(payload.get("scale_capsules"), dict) else {}
parts = _prompt_parts(raw) raw = scales.get(case_key)
if isinstance(raw, dict):
parts = _prompt_parts(raw.get("prompt_parts") or raw.get("positive_additions"))
else:
parts = _prompt_parts(raw)
clauses = [] clauses = []
for part in parts: for part in parts:
clauses.extend(_split_prompt_clauses(part)) clauses.extend(_split_prompt_clauses(part))

查看文件

@ -1,7 +1,7 @@
plugin: plugin:
name: astrbot_plugin_imagestudio name: astrbot_plugin_imagestudio
display_name: ImageStudio display_name: ImageStudio
version: 1.0.66 version: 1.0.67
features: features:
quick_profile: true quick_profile: true

查看文件

@ -10,7 +10,7 @@ from core.runtime_paths import resolve_config_path
from database.db_helper import load_config_payload from database.db_helper import load_config_payload
PLUGIN_VERSION = "1.0.66" PLUGIN_VERSION = "1.0.67"
@dataclass(frozen=True) @dataclass(frozen=True)

查看文件

@ -1,12 +1,12 @@
{ {
"name": "astrbot-plugin-imagestudio-frontend", "name": "astrbot-plugin-imagestudio-frontend",
"version": "1.0.66", "version": "1.0.67",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "astrbot-plugin-imagestudio-frontend", "name": "astrbot-plugin-imagestudio-frontend",
"version": "1.0.66", "version": "1.0.67",
"dependencies": { "dependencies": {
"@vitejs/plugin-vue": "^5.2.0", "@vitejs/plugin-vue": "^5.2.0",
"pinia": "^2.3.0", "pinia": "^2.3.0",

查看文件

@ -1,6 +1,6 @@
{ {
"name": "astrbot-plugin-imagestudio-frontend", "name": "astrbot-plugin-imagestudio-frontend",
"version": "1.0.66", "version": "1.0.67",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {

查看文件

@ -2,7 +2,7 @@ name: astrbot_plugin_imagestudio
display_name: ImageStudio display_name: ImageStudio
desc: AstrBot >=4.25 ImageStudio role asset and image-generation workspace for Windows, Linux, macOS and Docker. desc: AstrBot >=4.25 ImageStudio role asset and image-generation workspace for Windows, Linux, macOS and Docker.
short_desc: AstrBot 鍐呯殑瑙掕壊璧勪骇銆佸伐浣滄祦涓庡浘鐗囩敓鎴愮鐞嗗伐浣滃彴銆? short_desc: AstrBot 鍐呯殑瑙掕壊璧勪骇銆佸伐浣滄祦涓庡浘鐗囩敓鎴愮鐞嗗伐浣滃彴銆?
version: 1.0.66 version: 1.0.67
author: YokiiroBW author: YokiiroBW
repo: "http://192.168.31.210:18085/YokiiroBW/astrbot_plugin_imagestudio" repo: "http://192.168.31.210:18085/YokiiroBW/astrbot_plugin_imagestudio"
astrbot_version: ">=4.25.0,<5" astrbot_version: ">=4.25.0,<5"

查看文件

@ -4,8 +4,8 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AstrBot ImageStudio</title> <title>AstrBot ImageStudio</title>
<script type="module" crossorigin src="./assets/index-BZ25rUbw.js"></script> <script type="module" crossorigin src="./assets/index-BdfW6FGF.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-B8Z-z8zX.css"> <link rel="stylesheet" crossorigin href="./assets/index-iU5Ed_RF.css">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

查看文件

@ -24,6 +24,7 @@ from backend.services.advanced_style_set_service import (
_normalize_artist_signature, _normalize_artist_signature,
_normalize_style_deltas, _normalize_style_deltas,
_normalize_style_dimension_scores, _normalize_style_dimension_scores,
_build_style_profile_v2,
_normalize_rendering_layer_scores, _normalize_rendering_layer_scores,
_normalized_feature_evidence, _normalized_feature_evidence,
_scale_specific_style_prompt, _scale_specific_style_prompt,
@ -1769,5 +1770,35 @@ class AdvancedStyleSetWorkflowTests(unittest.TestCase):
self.assertEqual(comparison["recommendation"], "keep_previous_candidate") self.assertEqual(comparison["recommendation"], "keep_previous_candidate")
self.assertIn("fullbody", comparison["scenario_regressions"]) self.assertIn("fullbody", comparison["scenario_regressions"])
def test_style_profile_v2_separates_regions_and_scale_adapters(self) -> None:
payload = {
"normalized_asset_profile": {
"must_preserve": [
"thin tinted lavender contour lines",
"short broad rounded face with a tiny tapered chin",
"opaque creamy hair highlight shapes",
]
},
"artist_signature": [
{"dimension": "eye_design", "phrase": "layered irises with clustered white catchlights", "support_ratio": 1.0, "confidence": 0.95},
{"dimension": "shading", "phrase": "two translucent lavender cel-shadow bands", "support_ratio": 1.0, "confidence": 0.95},
],
"scale_capsules": {
"portrait": {"prompt_parts": ["preserve face width-to-length ratio", "preserve iris construction"]},
"fullbody": {"prompt_parts": ["preserve adult-appropriate anatomy and limb length"]},
"novel_scene": {"prompt_parts": ["separate character linework from background detail"]},
},
"feature_evidence": [],
}
profile = _build_style_profile_v2(payload)
self.assertEqual(profile["schema_version"], 1)
self.assertIn("eyes", profile["invariants"])
self.assertIn("shading", profile["invariants"])
self.assertEqual(set(profile["adapters"]), {"portrait", "fullbody", "novel_scene"})
prompt = _detailed_style_prompt({**payload, "style_profile_v2": profile}, "fallback")
self.assertLessEqual(len(prompt.split(", ")), 14)
self.assertIn("layered irises", prompt)
self.assertIn("face:", prompt)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

文件差异因一行或多行过长而隐藏

文件差异因一行或多行过长而隐藏

查看文件

@ -4,8 +4,8 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AstrBot ImageStudio</title> <title>AstrBot ImageStudio</title>
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-EHiWqZav.js"></script> <script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-DLzyriu-.js"></script>
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-Fxlc51Vo.css"> <link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-C0KIlCkM.css">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>