feat: improve representative style transfer
这个提交存在于:
父节点
b57ce466fe
当前提交
8f9c543918
共有 20 个文件被更改,包括 531 次插入 和 160 次删除
24
CHANGELOG.md
24
CHANGELOG.md
|
|
@ -1,3 +1,27 @@
|
||||||
|
## 1.0.65
|
||||||
|
|
||||||
|
- Improve style transfer with adaptive face and eye proportions, opaque pearlescent hair-highlight constraints, high-frequency representative-image guidance, and representative reference validation enabled by default with safe pure-text fallback.
|
||||||
|
|
||||||
|
## 1.0.64
|
||||||
|
|
||||||
|
- Preserve high-specificity artist signatures with an evidence-gated style kernel, scale-specific prompt adapters, and background-effect isolation for portrait, full-body, and novel-scene validation.
|
||||||
|
|
||||||
|
## 1.0.63
|
||||||
|
|
||||||
|
- Compact the final style prompt into an evidence-backed style kernel, preserve palette/highlights/shading traits after paraphrase, remove literal background effects without evidence, and neutralize age/body template locks.
|
||||||
|
|
||||||
|
## 1.0.62
|
||||||
|
|
||||||
|
- Soften facial-age and head-to-body style cues so user-requested age, gender presentation, body maturity and proportions remain authoritative; reduce childlike or adult template locking during style transfer.
|
||||||
|
|
||||||
|
## 1.0.61
|
||||||
|
|
||||||
|
- Add a selectable advanced-style consensus strategy: pure-text structured consensus by default, with opt-in vision-assisted consensus for cases that benefit from direct image review.
|
||||||
|
|
||||||
|
## 1.0.60
|
||||||
|
|
||||||
|
- Use pure-text structured cross-image consensus from per-image recognition reports, avoiding multi-image Vision relay timeouts while preserving the existing normalization and validation workflow.
|
||||||
|
|
||||||
## 1.0.59
|
## 1.0.59
|
||||||
|
|
||||||
- Reduce grouped consensus vision calls to one representative image plus structured reports to avoid relay multi-image stalls.
|
- Reduce grouped consensus vision calls to one representative image plus structured reports to avoid relay multi-image stalls.
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ from backend.services.material_service import (
|
||||||
from backend.services.worker_service import WorkerTaskUpdate
|
from backend.services.worker_service import WorkerTaskUpdate
|
||||||
from core.identity import RequestContext
|
from core.identity import RequestContext
|
||||||
from engines.image_provider import ImageProviderError
|
from engines.image_provider import ImageProviderError
|
||||||
from engines.vision_provider import VisionProviderError, VisionRecognitionRequest
|
from engines.vision_provider import VisionProviderError, VisionRecognitionRequest, VisionRecognitionResult
|
||||||
|
|
||||||
|
|
||||||
MIN_STYLE_SOURCES = 2
|
MIN_STYLE_SOURCES = 2
|
||||||
|
|
@ -79,6 +79,56 @@ _ARTIST_SIGNATURE_DIMENSION_MARKERS: dict[str, tuple[str, ...]] = {
|
||||||
"texture": ("texture", "grain", "brush", "surface", "paper", "noise"),
|
"texture": ("texture", "grain", "brush", "surface", "paper", "noise"),
|
||||||
"anatomy": ("head-to-body", "head to body", "proportion", "anatomy", "limb", "silhouette"),
|
"anatomy": ("head-to-body", "head to body", "proportion", "anatomy", "limb", "silhouette"),
|
||||||
}
|
}
|
||||||
|
_STYLE_KERNEL_RULES: tuple[tuple[tuple[str, ...], str], ...] = (
|
||||||
|
(
|
||||||
|
(r"wide|rounded", r"short|compact|tiny\s+chin|small\s+chin"),
|
||||||
|
"short broad rounded facial geometry with a compact tiny chin, preserving the source width-to-length variation without elongating it",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(r"oversized|very\s+large|large", r"eye|iris", r"layered|gradient|catchlight"),
|
||||||
|
"large round-oval eyes at the source-proportional scale with layered gradient irises, dark upper rims, and multiple crisp circular or crescent white catchlights",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(r"hair", r"broad|flowing|segment|gloss|highlight", r"white|bright|curved|sweep"),
|
||||||
|
"hair grouped into broad flowing segments with 2-4 opaque elongated pearlescent white sheen bands crossing each major curved lock, plus layered flyaways at the tips",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(r"colored", r"line|contour|outline|ink"),
|
||||||
|
"thin tapered linework tinted in local lavender, plum, rose, or blue fill colors instead of heavy black ink",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(r"high[- ]key|pastel|luminous", r"palette|spectrum|color|white|pink|blue|lavender"),
|
||||||
|
"high-key pastel color relationships built from luminous white, pink, powder blue, mint, and lavender accents",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(r"pink|peach|rose", r"blush|cheek|skin"),
|
||||||
|
"diffuse peach-pink cheek blush with small soft white highlight accents",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(r"cool|lavender|blue|violet|purple", r"shadow|shading|cel|gradient"),
|
||||||
|
"soft airbrush transitions combined with translucent cool lavender-blue cel-shadow bands and clear local edges",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
_STYLE_BACKGROUND_EFFECT_PATTERNS: tuple[tuple[str, str], ...] = (
|
||||||
|
(r"\bsoft\s+floating\s+particles\b", ""),
|
||||||
|
(r"\bfloating\s+particles\b", ""),
|
||||||
|
(r"\bsoft\s+background\s+bokeh\b", ""),
|
||||||
|
(r"\bbackground\s+bokeh\b", ""),
|
||||||
|
)
|
||||||
|
_STYLE_SCALE_KERNELS: dict[str, str] = {
|
||||||
|
"portrait": (
|
||||||
|
"at portrait scale prioritize the face width-to-length ratio, eye-to-face ratio, iris layers, clustered eye catchlights, "
|
||||||
|
"cheek blush accents, and surface-bound horizontal hair gloss; do not redesign or elongate the facial contour"
|
||||||
|
),
|
||||||
|
"fullbody": (
|
||||||
|
"at full-body scale keep a subject-appropriate stylized anatomy band of about 5-7 heads tall, never chibi 2-4 heads, "
|
||||||
|
"while preserving the same face, linework, hair highlight, and cool shadow grammar"
|
||||||
|
),
|
||||||
|
"novel_scene": (
|
||||||
|
"in a wide scene keep the character and environment in the same 2D pastel illustration grammar; simplify architecture and "
|
||||||
|
"surface detail, avoid photorealistic backgrounds, and let the requested scene content control setting and weather"
|
||||||
|
),
|
||||||
|
}
|
||||||
STYLE_DELTA_SEVERITY = {
|
STYLE_DELTA_SEVERITY = {
|
||||||
"low": 0.20,
|
"low": 0.20,
|
||||||
"minor": 0.25,
|
"minor": 0.25,
|
||||||
|
|
@ -150,7 +200,7 @@ _AGE_ATTRIBUTE_KEYS = {
|
||||||
}
|
}
|
||||||
_VARIABLE_CONTENT_PATTERNS = re.compile(
|
_VARIABLE_CONTENT_PATTERNS = re.compile(
|
||||||
r"\b(background|environment|scene|rooftop|garden|bokeh|lens\s+flare|dawn|sunset|sunrise|golden\s+hour|"
|
r"\b(background|environment|scene|rooftop|garden|bokeh|lens\s+flare|dawn|sunset|sunrise|golden\s+hour|"
|
||||||
r"neon|volumetric|rim\s+light|petals?|confetti|particles?|high[\s-]?key|pastel[\s-]?dominated|"
|
r"neon|volumetric|rim\s+light|petals?|confetti|particles?|"
|
||||||
r"hdr|cinematic\s+lighting|dramatic\s+backlight)\b",
|
r"hdr|cinematic\s+lighting|dramatic\s+backlight)\b",
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
|
@ -682,6 +732,13 @@ class AdvancedStyleSetService:
|
||||||
validation_instruction = _optional_text(payload.get("validation_instruction"))
|
validation_instruction = _optional_text(payload.get("validation_instruction"))
|
||||||
reuse_cases = payload.get("reuse_validation_cases") if not validation_instruction else []
|
reuse_cases = payload.get("reuse_validation_cases") if not validation_instruction else []
|
||||||
style_adjustment_plan = _style_adjustment_plan(payload.get("style_adjustment_plan"), style_adjustment)
|
style_adjustment_plan = _style_adjustment_plan(payload.get("style_adjustment_plan"), style_adjustment)
|
||||||
|
analysis_strategy = _optional_text(payload.get("analysis_strategy")) or "text_only"
|
||||||
|
if analysis_strategy not in {"text_only", "vision_assisted"}:
|
||||||
|
raise ApiError(
|
||||||
|
ErrorCode.VALIDATION_FAILED,
|
||||||
|
"analysis_strategy must be text_only or vision_assisted",
|
||||||
|
{"analysis_strategy": analysis_strategy},
|
||||||
|
)
|
||||||
consensus = self.repository.create_style_consensus_run(
|
consensus = self.repository.create_style_consensus_run(
|
||||||
{
|
{
|
||||||
"consensus_id": f"advconsensus_{uuid4().hex}",
|
"consensus_id": f"advconsensus_{uuid4().hex}",
|
||||||
|
|
@ -696,6 +753,7 @@ class AdvancedStyleSetService:
|
||||||
"validation_instruction": validation_instruction,
|
"validation_instruction": validation_instruction,
|
||||||
"reuse_validation_cases": reuse_cases if isinstance(reuse_cases, list) else [],
|
"reuse_validation_cases": reuse_cases if isinstance(reuse_cases, list) else [],
|
||||||
"style_adjustment_plan": style_adjustment_plan,
|
"style_adjustment_plan": style_adjustment_plan,
|
||||||
|
"analysis_strategy": analysis_strategy,
|
||||||
"comparison_attempt_id": _optional_text(payload.get("comparison_attempt_id")),
|
"comparison_attempt_id": _optional_text(payload.get("comparison_attempt_id")),
|
||||||
"comparison_consensus_id": _optional_text(payload.get("comparison_consensus_id")),
|
"comparison_consensus_id": _optional_text(payload.get("comparison_consensus_id")),
|
||||||
"comparison_source_ids": _string_list(payload.get("comparison_source_ids"))[:3],
|
"comparison_source_ids": _string_list(payload.get("comparison_source_ids"))[:3],
|
||||||
|
|
@ -1422,14 +1480,68 @@ class AdvancedStyleSetService:
|
||||||
"automatic_review_feedback": automatic_review_feedback,
|
"automatic_review_feedback": automatic_review_feedback,
|
||||||
}
|
}
|
||||||
route_name = self.owner._consensus_route() or consensus.model_route
|
route_name = self.owner._consensus_route() or consensus.model_route
|
||||||
|
requested_analysis_strategy = _optional_text(consensus.metadata.get("analysis_strategy")) or "text_only"
|
||||||
|
text_callable_factory = getattr(self.model_provider_runtime, "structured_text_callable", None)
|
||||||
|
text_callable = (
|
||||||
|
text_callable_factory(route_name)
|
||||||
|
if requested_analysis_strategy == "text_only" and callable(text_callable_factory)
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
provider = None
|
||||||
|
if text_callable is None:
|
||||||
provider = self.model_provider_runtime.vision_provider_for_route(
|
provider = self.model_provider_runtime.vision_provider_for_route(
|
||||||
{"route_name": route_name, "modality": "vision_recognition", "material_id": consensus_id, "image_uri": sources[0].source_image_uri}
|
{"route_name": route_name, "modality": "vision_recognition", "material_id": consensus_id, "image_uri": sources[0].source_image_uri}
|
||||||
)
|
)
|
||||||
if provider is None:
|
if provider is None:
|
||||||
raise ApiError(ErrorCode.MODEL_CAPABILITY_UNCONFIRMED, "advanced style consensus route is unavailable", {"route_name": route_name})
|
raise ApiError(ErrorCode.MODEL_CAPABILITY_UNCONFIRMED, "advanced style consensus route is unavailable", {"route_name": route_name})
|
||||||
analysis_strategy = "single_pass"
|
analysis_strategy = "text_only" if text_callable is not None else "single_pass"
|
||||||
try:
|
try:
|
||||||
if len(sources) <= 4 or previous_cases:
|
if text_callable is not None:
|
||||||
|
payload = {
|
||||||
|
"purpose": "advanced style cross-image text consensus",
|
||||||
|
"source_ids": [item.source_id for item in sources],
|
||||||
|
"source_reports": source_reports,
|
||||||
|
"comparison_context": comparison_payload,
|
||||||
|
"style_adjustment_plan": style_adjustment_plan,
|
||||||
|
"human_style_feedback": style_adjustment,
|
||||||
|
"recognition_instruction": _consensus_instruction(
|
||||||
|
source_ids=[item.source_id for item in sources],
|
||||||
|
style_adjustment=style_adjustment,
|
||||||
|
style_adjustment_plan=style_adjustment_plan,
|
||||||
|
validation_instruction=_optional_text(consensus.metadata.get("validation_instruction")),
|
||||||
|
has_previous_validation=bool(previous_cases),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
raw_result = text_callable(payload)
|
||||||
|
if isinstance(raw_result, str):
|
||||||
|
try:
|
||||||
|
raw_result = json.loads(raw_result)
|
||||||
|
except json.JSONDecodeError as exc:
|
||||||
|
raise ApiError(
|
||||||
|
ErrorCode.GENERATION_FAILED,
|
||||||
|
"advanced style text consensus returned invalid JSON",
|
||||||
|
{"route_name": route_name, "error": str(exc)[:300]},
|
||||||
|
) from None
|
||||||
|
if not isinstance(raw_result, dict):
|
||||||
|
raise ApiError(
|
||||||
|
ErrorCode.GENERATION_FAILED,
|
||||||
|
"advanced style text consensus returned a non-object result",
|
||||||
|
{"route_name": route_name},
|
||||||
|
)
|
||||||
|
structured = dict(raw_result)
|
||||||
|
recognition = VisionRecognitionResult(
|
||||||
|
provider_id=route_name,
|
||||||
|
model=route_name,
|
||||||
|
prompt=str(structured.get("prompt") or "").strip(),
|
||||||
|
negative_prompt=(str(structured["negative_prompt"]).strip() if structured.get("negative_prompt") is not None else None),
|
||||||
|
tags=_string_list(structured.get("tags")),
|
||||||
|
confidence=structured.get("confidence"),
|
||||||
|
description=(str(structured["description"]).strip() if structured.get("description") is not None else None),
|
||||||
|
structured_data=structured,
|
||||||
|
raw_metadata={"analysis_strategy": "text_only"},
|
||||||
|
)
|
||||||
|
image_manifest = []
|
||||||
|
elif len(sources) <= 4 or previous_cases:
|
||||||
request = VisionRecognitionRequest(
|
request = VisionRecognitionRequest(
|
||||||
display_name=f"{record.display_name} / cross-image style consensus",
|
display_name=f"{record.display_name} / cross-image style consensus",
|
||||||
image_uri=image_urls[0],
|
image_uri=image_urls[0],
|
||||||
|
|
@ -1635,6 +1747,7 @@ class AdvancedStyleSetService:
|
||||||
"comparison_context": comparison_payload,
|
"comparison_context": comparison_payload,
|
||||||
"automatic_review_feedback": automatic_review_feedback,
|
"automatic_review_feedback": automatic_review_feedback,
|
||||||
"analysis_strategy": analysis_strategy,
|
"analysis_strategy": analysis_strategy,
|
||||||
|
"requested_analysis_strategy": requested_analysis_strategy,
|
||||||
"image_manifest": image_manifest,
|
"image_manifest": image_manifest,
|
||||||
"effective_style_prompt": effective_prompt,
|
"effective_style_prompt": effective_prompt,
|
||||||
"effective_style_negative_prompt": effective_negative_prompt,
|
"effective_style_negative_prompt": effective_negative_prompt,
|
||||||
|
|
@ -1654,6 +1767,7 @@ class AdvancedStyleSetService:
|
||||||
"metadata": {
|
"metadata": {
|
||||||
**consensus.metadata,
|
**consensus.metadata,
|
||||||
"style_adjustment_plan": style_adjustment_plan,
|
"style_adjustment_plan": style_adjustment_plan,
|
||||||
|
"analysis_strategy": analysis_strategy,
|
||||||
"comparison_attempt_id": comparison_attempt_id,
|
"comparison_attempt_id": comparison_attempt_id,
|
||||||
"comparison_consensus_id": comparison_consensus_id,
|
"comparison_consensus_id": comparison_consensus_id,
|
||||||
"image_manifest": image_manifest,
|
"image_manifest": image_manifest,
|
||||||
|
|
@ -1748,7 +1862,7 @@ class AdvancedStyleSetService:
|
||||||
case_negative = _join_prompt(negative, scale_style_negative)
|
case_negative = _join_prompt(negative, scale_style_negative)
|
||||||
ref_clause = (
|
ref_clause = (
|
||||||
"optional style reference image is attached for visual grammar only; "
|
"optional style reference image is attached for visual grammar only; "
|
||||||
"copy linework, palette, eye geometry, shading edges and anatomy abstraction from the reference, "
|
"copy high-frequency visual grammar such as line pressure, palette relationships, eye geometry, hair-lock grouping, opaque pearlescent highlight shapes, shading edges and anatomy abstraction from the reference, "
|
||||||
"but invent a new character identity, costume, pose and scene from the content prompt; "
|
"but invent a new character identity, costume, pose and scene from the content prompt; "
|
||||||
"do not copy face identity, hairstyle identity, outfit design, props, pose or background from the reference"
|
"do not copy face identity, hairstyle identity, outfit design, props, pose or background from the reference"
|
||||||
if reference_plan["enabled"]
|
if reference_plan["enabled"]
|
||||||
|
|
@ -1790,7 +1904,7 @@ class AdvancedStyleSetService:
|
||||||
"effective_style_negative_prompt": detailed_style_negative,
|
"effective_style_negative_prompt": detailed_style_negative,
|
||||||
"scale_style_prompt": scale_style_prompt,
|
"scale_style_prompt": scale_style_prompt,
|
||||||
"scale_style_negative_prompt": scale_style_negative,
|
"scale_style_negative_prompt": scale_style_negative,
|
||||||
"style_compiler_version": 2,
|
"style_compiler_version": 3,
|
||||||
"content_leakage_exclusions": leakage,
|
"content_leakage_exclusions": leakage,
|
||||||
"retry_count": 0,
|
"retry_count": 0,
|
||||||
"prompt_only": not reference_plan["enabled"],
|
"prompt_only": not reference_plan["enabled"],
|
||||||
|
|
@ -2346,10 +2460,10 @@ def _consensus_instruction(
|
||||||
"composition from transferable style, while preserving domain-coupled structural stylization such as face proportions, "
|
"composition from transferable style, while preserving domain-coupled structural stylization such as face proportions, "
|
||||||
"eye geometry, nose/mouth simplification, head-to-body ratio and anatomy abstraction. Report facial_age_stylization, "
|
"eye geometry, nose/mouth simplification, head-to-body ratio and anatomy abstraction. Report facial_age_stylization, "
|
||||||
"actual_age_evidence and body_maturity_proportions separately. Chronological or identity age is not transferable style, "
|
"actual_age_evidence and body_maturity_proportions separately. Chronological or identity age is not transferable style, "
|
||||||
"but facial neoteny, eye scale, compact lower face and source head-to-body abstraction ARE transferable structural style and "
|
"but facial age stylization, eye scale, compact lower-face geometry and anatomy abstraction may be transferable only as soft structural cues. Never convert them into a fixed childlike, youthful or adult identity lock. "
|
||||||
"must be preserved. Do not rewrite style into a mature-adult identity lock. For full-body generation use a soft "
|
"The user content prompt controls chronological age, gender presentation, body maturity, build and requested proportions. For full-body generation use a flexible stylized "
|
||||||
"anatomy band of about 5-7 heads tall (prefer the observed source ratio when it falls inside that band); never collapse "
|
"anatomy band of about 5-7 heads tall only when compatible with that content prompt; never collapse "
|
||||||
"into chibi/super-deformed 2-4 heads, and do not force a mature 6.5-7.5 adult-woman body canon. "
|
"into chibi/super-deformed 2-4 heads, and never force a mature adult-woman body canon. "
|
||||||
"Validation subject age band is controlled only by validation_cases.content_prompt / human validation instruction; "
|
"Validation subject age band is controlled only by validation_cases.content_prompt / human validation instruction; "
|
||||||
"when unspecified, keep age-band neutral and let source anatomy style dominate. Sexualized, lingerie, underwear or nude "
|
"when unspecified, keep age-band neutral and let source anatomy style dominate. Sexualized, lingerie, underwear or nude "
|
||||||
"source content must never be combined with underage identity language. Do not classify a whole subject "
|
"source content must never be combined with underage identity language. Do not classify a whole subject "
|
||||||
|
|
@ -2523,8 +2637,8 @@ def _validation_instruction_prompt(case_key: str, instruction: str) -> str:
|
||||||
),
|
),
|
||||||
"fullbody": (
|
"fullbody": (
|
||||||
"For this controlled full-body comparison, preserve every requested identity, hairstyle, color, wardrobe and "
|
"For this controlled full-body comparison, preserve every requested identity, hairstyle, color, wardrobe and "
|
||||||
"requested age-band cues, show the complete character from head to toe, keep facial neoteny if present, and use "
|
"requested age-band cues, show the complete character from head to toe, preserve stylized facial geometry without forcing facial neoteny or a childlike identity, and use "
|
||||||
"a soft stylized anatomy band of about 5-7 heads tall (prefer the source ratio when available); not chibi, not "
|
"a flexible subject-appropriate stylized anatomy band of about 5-7 heads tall when compatible with the requested age and build; not chibi, not "
|
||||||
"super-deformed, and not a forced mature adult body canon"
|
"super-deformed, and not a forced mature adult body canon"
|
||||||
),
|
),
|
||||||
"novel_scene": (
|
"novel_scene": (
|
||||||
|
|
@ -2596,14 +2710,16 @@ def _clamp_head_ratio_range(range_value: tuple[float, float] | None) -> tuple[fl
|
||||||
def _anatomy_soft_band_phrase(range_value: tuple[float, float] | None = None, *, include_negative: bool = True) -> str:
|
def _anatomy_soft_band_phrase(range_value: tuple[float, float] | None = None, *, include_negative: bool = True) -> str:
|
||||||
low, high = _clamp_head_ratio_range(range_value)
|
low, high = _clamp_head_ratio_range(range_value)
|
||||||
if abs(low - high) < 0.05:
|
if abs(low - high) < 0.05:
|
||||||
core = f"natural stylized anime proportions about {low:.1f} heads tall with slender limbs"
|
ratio = f"around {low:.1f} heads tall"
|
||||||
else:
|
else:
|
||||||
core = f"natural stylized anime proportions about {low:.1f} to {high:.1f} heads tall with slender limbs"
|
ratio = f"around {low:.1f} to {high:.1f} heads tall"
|
||||||
|
core = (
|
||||||
|
f"flexible subject-appropriate stylized anatomy, {ratio} only when compatible with the requested age and build, "
|
||||||
|
"with natural limb length and no fixed childlike or adult body template"
|
||||||
|
)
|
||||||
if include_negative:
|
if include_negative:
|
||||||
return f"{core}, not chibi or super-deformed"
|
return f"{core}, not chibi or super-deformed"
|
||||||
return core
|
return core
|
||||||
|
|
||||||
|
|
||||||
def _source_anatomy_range_from_style_result(result: Any) -> tuple[float, float] | None:
|
def _source_anatomy_range_from_style_result(result: Any) -> tuple[float, float] | None:
|
||||||
payload = result if isinstance(result, dict) else {}
|
payload = result if isinstance(result, dict) else {}
|
||||||
texts: list[Any] = []
|
texts: list[Any] = []
|
||||||
|
|
@ -2821,6 +2937,26 @@ def _sanitize_style_prompt_parts(value: Any) -> list[str]:
|
||||||
return _unique_prompt_parts(result)
|
return _unique_prompt_parts(result)
|
||||||
|
|
||||||
|
|
||||||
|
def _normalize_style_prompt_conflicts(value: Any) -> str:
|
||||||
|
text = str(value or "").strip()
|
||||||
|
replacements = (
|
||||||
|
("stylized large head-to-body proportion", "flexible subject-appropriate head-to-body proportions"),
|
||||||
|
("large head-to-body proportion", "flexible subject-appropriate head-to-body proportions"),
|
||||||
|
("slim, simplified anatomy", "subject-appropriate stylized anatomy"),
|
||||||
|
("mature angular facial structure", "overly angular realistic facial structure"),
|
||||||
|
("mature angular facial proportions", "overly angular realistic facial proportions"),
|
||||||
|
("mature facial anatomy", "realistic angular facial anatomy"),
|
||||||
|
("airy, low-contrast, diffuse pastel background", "soft low-contrast atmospheric treatment over the requested scene"),
|
||||||
|
("airy diffuse low-contrast background", "soft low-contrast atmospheric treatment over the requested scene"),
|
||||||
|
("airy, low-density diffuse background", "soft low-contrast atmospheric treatment over the requested scene"),
|
||||||
|
("airy, low-contrast, diffuse pastel environment", "soft low-contrast atmospheric treatment over the requested scene"),
|
||||||
|
("airy, diffuse pastel environment", "soft low-contrast atmospheric treatment over the requested scene"),
|
||||||
|
)
|
||||||
|
for source, target in replacements:
|
||||||
|
text = re.sub(re.escape(source), target, text, flags=re.IGNORECASE)
|
||||||
|
return _clean_prompt_text(text)
|
||||||
|
|
||||||
|
|
||||||
def _clean_prompt_text(value: str) -> str:
|
def _clean_prompt_text(value: str) -> str:
|
||||||
text = re.sub(r"\s+", " ", str(value or ""))
|
text = re.sub(r"\s+", " ", str(value or ""))
|
||||||
text = re.sub(r"\s+([,.;:])", r"\1", text)
|
text = re.sub(r"\s+([,.;:])", r"\1", text)
|
||||||
|
|
@ -3705,6 +3841,57 @@ def _artist_signature_prompt_parts(payload: dict[str, Any]) -> list[str]:
|
||||||
parts.append(f"artist-specific {dimension.replace('_', ' ')} signature: {_join_prompt(*phrases)}")
|
parts.append(f"artist-specific {dimension.replace('_', ' ')} signature: {_join_prompt(*phrases)}")
|
||||||
return _unique_prompt_parts(parts)
|
return _unique_prompt_parts(parts)
|
||||||
|
|
||||||
|
|
||||||
|
def _style_feature_corpus(payload: dict[str, Any]) -> str:
|
||||||
|
pieces: list[str] = []
|
||||||
|
for key in ("feature_evidence", "variable_style_features", "source_content_features"):
|
||||||
|
raw = payload.get(key) if isinstance(payload, dict) else None
|
||||||
|
if isinstance(raw, list):
|
||||||
|
pieces.extend(
|
||||||
|
_optional_text(item.get("trait") if isinstance(item, dict) else item) or ""
|
||||||
|
for item in raw
|
||||||
|
)
|
||||||
|
priorities = payload.get("prompt_priority_groups") if isinstance(payload, dict) else None
|
||||||
|
if isinstance(priorities, dict):
|
||||||
|
for raw in priorities.values():
|
||||||
|
pieces.extend(_prompt_parts(raw))
|
||||||
|
capsules = payload.get("generation_capsules") if isinstance(payload, dict) else None
|
||||||
|
if isinstance(capsules, dict):
|
||||||
|
for raw in capsules.values():
|
||||||
|
if isinstance(raw, dict):
|
||||||
|
pieces.extend(_prompt_parts(raw.get("prompt_parts")))
|
||||||
|
pieces.extend(_prompt_parts(raw.get("must_preserve")))
|
||||||
|
profile = payload.get("normalized_asset_profile") if isinstance(payload, dict) else None
|
||||||
|
if isinstance(profile, dict):
|
||||||
|
pieces.extend(_prompt_parts(profile.get("must_preserve")))
|
||||||
|
attributes = profile.get("attributes")
|
||||||
|
if isinstance(attributes, dict):
|
||||||
|
pieces.extend(
|
||||||
|
_optional_text(item.get("value") if isinstance(item, dict) else item) or ""
|
||||||
|
for item in attributes.values()
|
||||||
|
)
|
||||||
|
pieces.extend(_artist_signature_prompt_parts(payload))
|
||||||
|
return " ".join(piece for piece in pieces if piece).casefold()
|
||||||
|
|
||||||
|
|
||||||
|
def _style_kernel_parts(payload: dict[str, Any]) -> list[str]:
|
||||||
|
corpus = _style_feature_corpus(payload)
|
||||||
|
result: list[str] = []
|
||||||
|
for patterns, phrase in _STYLE_KERNEL_RULES:
|
||||||
|
if all(re.search(pattern, corpus, re.IGNORECASE) for pattern in patterns):
|
||||||
|
result.append(phrase)
|
||||||
|
return _unique_prompt_parts(result)
|
||||||
|
|
||||||
|
|
||||||
|
def _strip_style_background_effects(value: Any) -> str:
|
||||||
|
text = str(value or "").strip()
|
||||||
|
for pattern, replacement in _STYLE_BACKGROUND_EFFECT_PATTERNS:
|
||||||
|
text = re.sub(pattern, replacement, text, flags=re.IGNORECASE)
|
||||||
|
text = re.sub(r"\bfeaturing\s+and\b", "with", text, flags=re.IGNORECASE)
|
||||||
|
text = re.sub(r"\s+([,.;])", r"\1", text)
|
||||||
|
text = re.sub(r"\b(?:and|with)\s*(?:[,.;]|$)", "", text, flags=re.IGNORECASE)
|
||||||
|
return _clean_prompt_text(text)
|
||||||
|
|
||||||
def _detailed_style_prompt(result: Any, fallback: Any) -> str:
|
def _detailed_style_prompt(result: Any, fallback: Any) -> str:
|
||||||
payload = result if isinstance(result, dict) else {}
|
payload = result if isinstance(result, dict) else {}
|
||||||
capsules = payload.get("generation_capsules") if isinstance(payload.get("generation_capsules"), dict) else {}
|
capsules = payload.get("generation_capsules") if isinstance(payload.get("generation_capsules"), dict) else {}
|
||||||
|
|
@ -3724,9 +3911,15 @@ def _detailed_style_prompt(result: Any, fallback: Any) -> str:
|
||||||
item for item in must_preserve
|
item for item in must_preserve
|
||||||
if _style_trait_is_supported(item, evidence, required=strict_evidence)
|
if _style_trait_is_supported(item, evidence, required=strict_evidence)
|
||||||
]
|
]
|
||||||
|
# Preserve compact provider-derived style priorities, but still gate literal
|
||||||
|
# scene/optical effects that lack cross-image evidence.
|
||||||
gated_priorities = [
|
gated_priorities = [
|
||||||
item for item in priority_parts
|
item for item in priority_parts
|
||||||
if _style_trait_is_supported(item, evidence, required=strict_evidence)
|
if _style_trait_is_supported(
|
||||||
|
item,
|
||||||
|
evidence,
|
||||||
|
required=bool(_VARIABLE_CONTENT_PATTERNS.search(item)),
|
||||||
|
)
|
||||||
]
|
]
|
||||||
capsule_parts = [
|
capsule_parts = [
|
||||||
item for item in _prompt_parts(detailed.get("prompt_parts"))
|
item for item in _prompt_parts(detailed.get("prompt_parts"))
|
||||||
|
|
@ -3737,7 +3930,8 @@ def _detailed_style_prompt(result: Any, fallback: Any) -> str:
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
signature_parts = _artist_signature_prompt_parts(payload)
|
signature_parts = _artist_signature_prompt_parts(payload)
|
||||||
parts = [*signature_parts, *gated_must_preserve, *gated_priorities, *capsule_parts]
|
# Priority groups are the compact style kernel; signatures and capsules are supplementary evidence.
|
||||||
|
supplemental_parts = [*gated_must_preserve, *capsule_parts, *signature_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 []:
|
||||||
|
|
@ -3747,20 +3941,43 @@ def _detailed_style_prompt(result: Any, fallback: Any) -> str:
|
||||||
if not value:
|
if not value:
|
||||||
continue
|
continue
|
||||||
if key in {"facial_age_stylization"} or str(key).endswith("facial_age_stylization"):
|
if key in {"facial_age_stylization"} or str(key).endswith("facial_age_stylization"):
|
||||||
parts.append(f"facial age stylization: {value}")
|
supplemental_parts.append(f"facial age stylization: {value}")
|
||||||
elif "body_maturity" in str(key) or "head_to_body" in str(key) or key in {"anatomy_scale"}:
|
elif "body_maturity" in str(key) or "head_to_body" in str(key) or key in {"anatomy_scale"}:
|
||||||
parts.append(value)
|
supplemental_parts.append(value)
|
||||||
risks = _normalize_semantic_risks(payload.get("semantic_risk_audit"))
|
risks = _normalize_semantic_risks(payload.get("semantic_risk_audit"))
|
||||||
|
priority_clauses = []
|
||||||
|
for item in gated_priorities:
|
||||||
|
priority_clauses.extend(_split_prompt_clauses(item))
|
||||||
|
kernel_parts = _style_kernel_parts(payload)
|
||||||
rewritten = []
|
rewritten = []
|
||||||
for item in parts:
|
for item in [*kernel_parts, *priority_clauses]:
|
||||||
safe, _ = _sanitize_minor_age_text(_apply_semantic_risk_rewrites(item, risks))
|
safe, _ = _sanitize_minor_age_text(_apply_semantic_risk_rewrites(item, risks))
|
||||||
safe = _strip_mature_body_locks(safe)
|
safe = _strip_style_background_effects(_normalize_style_prompt_conflicts(_strip_mature_body_locks(safe)))
|
||||||
if safe:
|
if safe:
|
||||||
rewritten.append(safe)
|
rewritten.append(safe)
|
||||||
|
for item in supplemental_parts:
|
||||||
|
safe, _ = _sanitize_minor_age_text(_apply_semantic_risk_rewrites(item, risks))
|
||||||
|
safe = _strip_style_background_effects(_normalize_style_prompt_conflicts(_strip_mature_body_locks(safe)))
|
||||||
|
if safe:
|
||||||
|
rewritten.append(safe)
|
||||||
|
if kernel_parts:
|
||||||
|
kernel_anchors = rewritten[:len(kernel_parts)]
|
||||||
|
filtered = list(kernel_anchors)
|
||||||
|
for item in rewritten[len(kernel_parts):]:
|
||||||
|
redundant = any(
|
||||||
|
_prompt_traits_overlap(item, anchor) and len(item) <= int(len(anchor) * 0.90)
|
||||||
|
for anchor in kernel_anchors
|
||||||
|
)
|
||||||
|
if not redundant:
|
||||||
|
filtered.append(item)
|
||||||
|
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=12)
|
compiled = _compact_style_prompt_parts(rewritten, limit=16)
|
||||||
if compiled:
|
if compiled:
|
||||||
return _join_prompt(*compiled)
|
return _join_prompt(
|
||||||
|
*compiled,
|
||||||
|
"follow the user's requested age, gender presentation, body maturity, build and proportions; do not apply a fixed childlike or adult template",
|
||||||
|
)
|
||||||
safe_fallback, _fallback_changed = _sanitize_minor_age_text(str(fallback or "").strip())
|
safe_fallback, _fallback_changed = _sanitize_minor_age_text(str(fallback or "").strip())
|
||||||
return _strip_mature_body_locks(safe_fallback)
|
return _strip_mature_body_locks(safe_fallback)
|
||||||
|
|
||||||
|
|
@ -3789,7 +4006,9 @@ def _detailed_style_negative_prompt(result: Any, fallback: Any) -> str:
|
||||||
_semantic_phrase_is_object_risky(item.get("safe_rewrite")) for item in risks
|
_semantic_phrase_is_object_risky(item.get("safe_rewrite")) for item in risks
|
||||||
):
|
):
|
||||||
parts.extend(_LITERAL_SHAPE_NEGATIVE_GUARDS)
|
parts.extend(_LITERAL_SHAPE_NEGATIVE_GUARDS)
|
||||||
return _join_prompt(*parts) if parts else str(fallback or "").strip()
|
normalized = [_normalize_style_prompt_conflicts(item) for item in parts if str(item or "").strip()]
|
||||||
|
compacted = _compact_style_prompt_parts(normalized, limit=18)
|
||||||
|
return _join_prompt(*compacted) if compacted else _normalize_style_prompt_conflicts(str(fallback or "").strip())
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
|
|
@ -3811,9 +4030,13 @@ def _scale_specific_style_prompt(result: Any, case_key: str, common_prompt: Any
|
||||||
sanitized = []
|
sanitized = []
|
||||||
for item in scale_only:
|
for item in scale_only:
|
||||||
safe, _ = _sanitize_minor_age_text(item)
|
safe, _ = _sanitize_minor_age_text(item)
|
||||||
|
safe = _strip_style_background_effects(_normalize_style_prompt_conflicts(safe))
|
||||||
if safe:
|
if safe:
|
||||||
sanitized.append(safe)
|
sanitized.append(safe)
|
||||||
return _join_prompt(*_compact_style_prompt_parts(sanitized, limit=5))
|
scale_kernel = _STYLE_SCALE_KERNELS.get(case_key)
|
||||||
|
if scale_kernel:
|
||||||
|
sanitized.insert(0, scale_kernel)
|
||||||
|
return _join_prompt(*_compact_style_prompt_parts(sanitized, limit=6))
|
||||||
|
|
||||||
|
|
||||||
def _scale_specific_style_negative_prompt(result: Any, case_key: str) -> str:
|
def _scale_specific_style_negative_prompt(result: Any, case_key: str) -> str:
|
||||||
|
|
@ -3831,8 +4054,8 @@ def _scale_transfer_instruction(case_key: str) -> str:
|
||||||
"hair strand grouping and surface-bound highlight placement; do not redesign or elongate the facial contour"
|
"hair strand grouping and surface-bound highlight placement; do not redesign or elongate the facial contour"
|
||||||
),
|
),
|
||||||
"fullbody": (
|
"fullbody": (
|
||||||
"at full-body scale preserve silhouette language and facial neoteny while using a soft stylized anatomy band of about "
|
"at full-body scale preserve silhouette language and stylized facial geometry without forcing facial neoteny or a childlike identity, while using a flexible stylized anatomy band of about "
|
||||||
"5-7 heads tall (prefer the observed source ratio when it falls inside that band); do not collapse into chibi/super-deformed "
|
"5-7 heads tall only when compatible with the requested subject; do not collapse into chibi/super-deformed "
|
||||||
"2-4 heads, and do not force a mature adult-woman body canon; preserve colored line hierarchy, clothing-fold shading regions "
|
"2-4 heads, and do not force a mature adult-woman body canon; preserve colored line hierarchy, clothing-fold shading regions "
|
||||||
),
|
),
|
||||||
"novel_scene": (
|
"novel_scene": (
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
plugin:
|
plugin:
|
||||||
name: astrbot_plugin_imagestudio
|
name: astrbot_plugin_imagestudio
|
||||||
display_name: ImageStudio
|
display_name: ImageStudio
|
||||||
version: 1.0.59
|
version: 1.0.65
|
||||||
|
|
||||||
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.59"
|
PLUGIN_VERSION = "1.0.65"
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
|
|
||||||
4
frontend/package-lock.json
自动生成
4
frontend/package-lock.json
自动生成
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "astrbot-plugin-imagestudio-frontend",
|
"name": "astrbot-plugin-imagestudio-frontend",
|
||||||
"version": "1.0.59",
|
"version": "1.0.65",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "astrbot-plugin-imagestudio-frontend",
|
"name": "astrbot-plugin-imagestudio-frontend",
|
||||||
"version": "1.0.59",
|
"version": "1.0.65",
|
||||||
"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.59",
|
"version": "1.0.65",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -344,6 +344,7 @@ export interface AdvancedMaterialDecisionRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdvancedStyleConsensusRequest {
|
export interface AdvancedStyleConsensusRequest {
|
||||||
|
analysis_strategy?: "text_only" | "vision_assisted"
|
||||||
included_source_ids?: string[]
|
included_source_ids?: string[]
|
||||||
validation_reference_enabled?: boolean
|
validation_reference_enabled?: boolean
|
||||||
validation_reference_source_id?: string
|
validation_reference_source_id?: string
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ const validationInstructionText = ref("")
|
||||||
const decisionNotes = ref("")
|
const decisionNotes = ref("")
|
||||||
const fidelityPercent = ref(85)
|
const fidelityPercent = ref(85)
|
||||||
const acceptConfirmed = ref(false)
|
const acceptConfirmed = ref(false)
|
||||||
const validationReferenceEnabled = ref(false)
|
const validationReferenceEnabled = ref(true)
|
||||||
|
const consensusAnalysisStrategy = ref<"text_only" | "vision_assisted">("text_only")
|
||||||
const validationReferenceSourceId = ref("")
|
const validationReferenceSourceId = ref("")
|
||||||
|
|
||||||
let pollTimer = 0
|
let pollTimer = 0
|
||||||
|
|
@ -696,6 +697,7 @@ async function createStyleConsensus() {
|
||||||
const referenceSourceId = effectiveValidationReferenceSourceId.value
|
const referenceSourceId = effectiveValidationReferenceSourceId.value
|
||||||
await postJson<unknown>(endpoints.advancedMaterialStyleConsensus(item.import_id), {
|
await postJson<unknown>(endpoints.advancedMaterialStyleConsensus(item.import_id), {
|
||||||
included_source_ids: recognizedStyleSources.value.map((source) => source.source_id),
|
included_source_ids: recognizedStyleSources.value.map((source) => source.source_id),
|
||||||
|
analysis_strategy: consensusAnalysisStrategy.value,
|
||||||
validation_reference_enabled: validationReferenceEnabled.value,
|
validation_reference_enabled: validationReferenceEnabled.value,
|
||||||
...(validationReferenceEnabled.value && referenceSourceId
|
...(validationReferenceEnabled.value && referenceSourceId
|
||||||
? { validation_reference_source_id: referenceSourceId }
|
? { validation_reference_source_id: referenceSourceId }
|
||||||
|
|
@ -1511,6 +1513,7 @@ function errorMessage(err: unknown) {
|
||||||
<article class="advanced-style-stage">
|
<article class="advanced-style-stage">
|
||||||
<header class="advanced-style-stage-header">
|
<header class="advanced-style-stage-header">
|
||||||
<div><span>01 · 并行识别</span><h4>画风样本 {{ recognizedStyleSources.length }}/{{ activeStyleSources.length || styleSources.length }} 已完成</h4><p>每张图片拥有独立任务、计时器和错误;失败不会中断其他样本。</p></div>
|
<div><span>01 · 并行识别</span><h4>画风样本 {{ recognizedStyleSources.length }}/{{ activeStyleSources.length || styleSources.length }} 已完成</h4><p>每张图片拥有独立任务、计时器和错误;失败不会中断其他样本。</p></div>
|
||||||
|
<label class="advanced-style-analysis-mode"><span>交叉归纳</span><select v-model="consensusAnalysisStrategy" :disabled="Boolean(actionBusy)"><option value="text_only">纯文本(推荐,避免视觉超时)</option><option value="vision_assisted">带图归纳(更强视觉复核)</option></select></label>
|
||||||
<button v-if="canRunStyleConsensus" type="button" class="primary" @click="createStyleConsensus">{{ actionBusy === "style-consensus" ? "入队中" : "交叉分析有效样本" }}</button>
|
<button v-if="canRunStyleConsensus" type="button" class="primary" @click="createStyleConsensus">{{ actionBusy === "style-consensus" ? "入队中" : "交叉分析有效样本" }}</button>
|
||||||
</header>
|
</header>
|
||||||
<div class="advanced-style-source-grid">
|
<div class="advanced-style-source-grid">
|
||||||
|
|
@ -1834,6 +1837,8 @@ button:disabled { cursor: not-allowed; opacity: .52; }
|
||||||
.advanced-style-stage { display: grid; gap: 11px; min-width: 0; border: 1px solid var(--border); border-radius: 9px; padding: 11px; background: var(--panel-muted); }
|
.advanced-style-stage { display: grid; gap: 11px; min-width: 0; border: 1px solid var(--border); border-radius: 9px; padding: 11px; background: var(--panel-muted); }
|
||||||
.advanced-style-stage-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
.advanced-style-stage-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
||||||
.advanced-style-stage-header > div { display: grid; gap: 3px; min-width: 0; }
|
.advanced-style-stage-header > div { display: grid; gap: 3px; min-width: 0; }
|
||||||
|
.advanced-style-analysis-mode { display: grid; gap: 4px; min-width: 190px; color: var(--text-soft); font-size: 11px; font-weight: 800; }
|
||||||
|
.advanced-style-analysis-mode select { min-height: 30px; border: 1px solid var(--border); border-radius: 7px; padding: 0 8px; color: var(--text); background: var(--panel); font-size: 11px; }
|
||||||
.advanced-style-stage-header span { color: var(--primary); font-size: 11px; font-weight: 900; letter-spacing: .04em; }
|
.advanced-style-stage-header span { color: var(--primary); font-size: 11px; font-weight: 900; letter-spacing: .04em; }
|
||||||
.advanced-style-stage-header h4 { margin: 0; color: var(--text); font-size: 16px; }
|
.advanced-style-stage-header h4 { margin: 0; color: var(--text); font-size: 16px; }
|
||||||
.advanced-style-stage-header p { margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.45; }
|
.advanced-style-stage-header p { margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.45; }
|
||||||
|
|
|
||||||
|
|
@ -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.59
|
version: 1.0.65
|
||||||
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-B46TB2JW.js"></script>
|
<script type="module" crossorigin src="./assets/index-DeH0Kig6.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="./assets/index-CzoN1_Mb.css">
|
<link rel="stylesheet" crossorigin href="./assets/index-Bw79A5u9.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|
|
||||||
|
|
@ -250,6 +250,10 @@ class _Runtime:
|
||||||
def __init__(self, vision: _StyleVisionProvider, image: _StyleImageProvider) -> None:
|
def __init__(self, vision: _StyleVisionProvider, image: _StyleImageProvider) -> None:
|
||||||
self.vision = vision
|
self.vision = vision
|
||||||
self.image = image
|
self.image = image
|
||||||
|
self.text_callable = None
|
||||||
|
|
||||||
|
def structured_text_callable(self, _route_name: str):
|
||||||
|
return self.text_callable
|
||||||
|
|
||||||
def vision_provider_for_route(self, _route: dict[str, Any]) -> _StyleVisionProvider:
|
def vision_provider_for_route(self, _route: dict[str, Any]) -> _StyleVisionProvider:
|
||||||
return self.vision
|
return self.vision
|
||||||
|
|
@ -558,6 +562,63 @@ class AdvancedStyleSetWorkflowTests(unittest.TestCase):
|
||||||
self.assertIsNotNone(record)
|
self.assertIsNotNone(record)
|
||||||
self.assertEqual(record.status, "awaiting_review")
|
self.assertEqual(record.status, "awaiting_review")
|
||||||
|
|
||||||
|
def test_consensus_prefers_pure_text_cross_image_analysis(self) -> None:
|
||||||
|
fixture = _fixture(self.root)
|
||||||
|
_import_id, consensus = _execute_source_stage(fixture, 8)
|
||||||
|
payloads: list[dict[str, Any]] = []
|
||||||
|
|
||||||
|
def complete(payload: dict[str, Any]) -> dict[str, Any]:
|
||||||
|
payloads.append(payload)
|
||||||
|
structured = _style_structures("shared fine ink linework, flat cel colors, two-band shadows")
|
||||||
|
structured.update(
|
||||||
|
{
|
||||||
|
"consensus_style": {"linework": "fine ink", "shading": "two-band cel"},
|
||||||
|
"representative_source_ids": payload["source_ids"][:3],
|
||||||
|
"validation_cases": [
|
||||||
|
{"case_key": "portrait", "content_prompt": "a portrait", "aspect_ratio": "1:1"},
|
||||||
|
{"case_key": "fullbody", "content_prompt": "a full body character", "aspect_ratio": "2:3"},
|
||||||
|
{"case_key": "novel_scene", "content_prompt": "a wide scene", "aspect_ratio": "16:9"},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
**structured,
|
||||||
|
"prompt": "shared fine ink linework, flat cel colors, two-band shadows",
|
||||||
|
"negative_prompt": "photorealism, source identity, watermark",
|
||||||
|
"tags": ["style", "ink", "cel-shading"],
|
||||||
|
"confidence": 0.93,
|
||||||
|
"description": "Text-only cross-image style consensus.",
|
||||||
|
}
|
||||||
|
|
||||||
|
fixture.service.model_provider_runtime.text_callable = complete
|
||||||
|
_execute_consensus(fixture, consensus)
|
||||||
|
|
||||||
|
self.assertEqual(len(payloads), 1)
|
||||||
|
self.assertEqual(len(payloads[0]["source_reports"]), 8)
|
||||||
|
self.assertEqual(len(fixture.vision.requests), 8)
|
||||||
|
completed = fixture.advanced.get_style_consensus_run(consensus.consensus_id)
|
||||||
|
self.assertIsNotNone(completed)
|
||||||
|
self.assertEqual(completed.result.get("analysis_strategy"), "text_only")
|
||||||
|
self.assertEqual(completed.result.get("image_manifest"), [])
|
||||||
|
record = fixture.advanced.get_import(consensus.import_id)
|
||||||
|
self.assertIsNotNone(record)
|
||||||
|
self.assertEqual(len(fixture.advanced.list_style_validation_cases(record.current_attempt_id)), 3)
|
||||||
|
def test_consensus_can_force_vision_assisted_analysis(self) -> None:
|
||||||
|
fixture = _fixture(self.root)
|
||||||
|
_import_id, consensus = _execute_source_stage(fixture, 8)
|
||||||
|
updated = fixture.advanced.update_style_consensus_run(
|
||||||
|
consensus.consensus_id,
|
||||||
|
{"metadata": {**consensus.metadata, "analysis_strategy": "vision_assisted"}},
|
||||||
|
expected_statuses={"queued"},
|
||||||
|
)
|
||||||
|
self.assertIsNotNone(updated)
|
||||||
|
fixture.service.model_provider_runtime.text_callable = lambda _payload: (_ for _ in ()).throw(
|
||||||
|
AssertionError("vision-assisted consensus must not call the text callable")
|
||||||
|
)
|
||||||
|
_execute_consensus(fixture, updated)
|
||||||
|
consensus_requests = fixture.vision.requests[8:]
|
||||||
|
self.assertEqual(len(consensus_requests), 3)
|
||||||
|
self.assertEqual([1 + len(item.image_uris) for item in consensus_requests], [1, 1, 1])
|
||||||
def test_large_consensus_uses_grouped_two_stage_vision_requests(self) -> None:
|
def test_large_consensus_uses_grouped_two_stage_vision_requests(self) -> None:
|
||||||
fixture = _fixture(self.root)
|
fixture = _fixture(self.root)
|
||||||
_import_id, consensus = _execute_source_stage(fixture, 8)
|
_import_id, consensus = _execute_source_stage(fixture, 8)
|
||||||
|
|
@ -1224,7 +1285,7 @@ class AdvancedStyleSetWorkflowTests(unittest.TestCase):
|
||||||
prompt = _detailed_style_prompt(payload, "fallback").casefold()
|
prompt = _detailed_style_prompt(payload, "fallback").casefold()
|
||||||
self.assertIn("thin colored lineart", prompt)
|
self.assertIn("thin colored lineart", prompt)
|
||||||
self.assertNotIn("circular bokeh", prompt)
|
self.assertNotIn("circular bokeh", prompt)
|
||||||
self.assertNotIn("pastel-dominated", prompt)
|
# Palette is a transferable style trait even when the provider paraphrases its evidence; literal scene effects still require evidence.
|
||||||
|
|
||||||
def test_semantic_second_pass_rewrites_provider_safe_band_and_adds_literal_shape_guards(self) -> None:
|
def test_semantic_second_pass_rewrites_provider_safe_band_and_adds_literal_shape_guards(self) -> None:
|
||||||
payload = {
|
payload = {
|
||||||
|
|
@ -1561,6 +1622,63 @@ class AdvancedStyleSetWorkflowTests(unittest.TestCase):
|
||||||
self.assertIn("local color separation", prompt)
|
self.assertIn("local color separation", prompt)
|
||||||
self.assertIn("diamond catchlight", prompt)
|
self.assertIn("diamond catchlight", prompt)
|
||||||
|
|
||||||
|
def test_style_kernel_preserves_high_specificity_traits_over_generic_summary(self) -> None:
|
||||||
|
prompt = _detailed_style_prompt(
|
||||||
|
{
|
||||||
|
"feature_evidence": [
|
||||||
|
{"trait": "High-key pastel color palette"},
|
||||||
|
{"trait": "Oversized layered glossy eyes"},
|
||||||
|
{"trait": "Broad white gloss streaks on hair"},
|
||||||
|
{"trait": "Thin tapered colored linework"},
|
||||||
|
{"trait": "Diffuse pink skin blush"},
|
||||||
|
{"trait": "Cool translucent cel-shadow bands"},
|
||||||
|
],
|
||||||
|
"normalized_asset_profile": {
|
||||||
|
"must_preserve": [
|
||||||
|
"Short rounded face, tiny chin, oversized eyes",
|
||||||
|
"Bright airy background with soft floating particles",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generation_capsules": {"detailed": {"prompt_parts": []}},
|
||||||
|
},
|
||||||
|
"fallback",
|
||||||
|
).casefold()
|
||||||
|
self.assertIn("short broad rounded facial geometry", prompt)
|
||||||
|
self.assertIn("multiple crisp circular or crescent white catchlights", prompt)
|
||||||
|
self.assertIn("opaque elongated pearlescent white sheen bands", prompt)
|
||||||
|
self.assertIn("local lavender, plum, rose, or blue", prompt)
|
||||||
|
self.assertIn("peach-pink cheek blush", prompt)
|
||||||
|
self.assertNotIn("floating particles", prompt)
|
||||||
|
|
||||||
|
def test_style_negative_prompt_rewrites_mature_face_wording(self) -> None:
|
||||||
|
negative = _detailed_style_negative_prompt(
|
||||||
|
{
|
||||||
|
"generation_capsules": {
|
||||||
|
"detailed": {
|
||||||
|
"negative_parts": ["mature angular facial proportions", "photorealistic rendering"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"",
|
||||||
|
).casefold()
|
||||||
|
self.assertIn("overly angular realistic facial proportions", negative)
|
||||||
|
self.assertNotIn("mature angular facial proportions", negative)
|
||||||
|
|
||||||
|
def test_scale_style_kernels_split_portrait_fullbody_and_scene(self) -> None:
|
||||||
|
payload = {
|
||||||
|
"scale_capsules": {
|
||||||
|
"portrait": {"prompt_parts": ["face details"]},
|
||||||
|
"fullbody": {"prompt_parts": ["body details"]},
|
||||||
|
"novel_scene": {"prompt_parts": ["scene details"]},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.assertIn("face width-to-length ratio", _scale_specific_style_prompt(payload, "portrait"))
|
||||||
|
self.assertIn("5-7 heads tall", _scale_specific_style_prompt(payload, "fullbody"))
|
||||||
|
self.assertIn("avoid photorealistic backgrounds", _scale_specific_style_prompt(payload, "novel_scene"))
|
||||||
|
|
||||||
|
scene_payload = {"scale_capsules": {"novel_scene": {"prompt_parts": ["soft floating particles"]}}}
|
||||||
|
self.assertNotIn("floating particles", _scale_specific_style_prompt(scene_payload, "novel_scene"))
|
||||||
|
|
||||||
def test_consensus_source_analysis_removes_textual_style_anchors(self) -> None:
|
def test_consensus_source_analysis_removes_textual_style_anchors(self) -> None:
|
||||||
cleaned = _consensus_source_analysis(
|
cleaned = _consensus_source_analysis(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
57
web/assets/index-BE0GnfZC.js
普通文件
57
web/assets/index-BE0GnfZC.js
普通文件
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
|
|
@ -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-CNbT4M0c.js"></script>
|
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BE0GnfZC.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-D0xKI0Zx.css">
|
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BqAqEWbf.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|
|
||||||
正在加载…
添加表格
在新工单中引用