P6 — Image→Persona Analyzer
Transforms 1, N reference images into deterministic Persona hints including appearance tags, palette, pose anchors, expression prototypes, and style/LoRA suggestions.
What this file does
Transforms 1, N reference images into deterministic Persona hints including appearance tags, palette, pose anchors, expression prototypes, and style/LoRA suggestions.
When to use it
- Building a character profile from reference images in a ComfyUI project
- Adding deterministic image analysis to a persona or asset pipeline
- Implementing hash-stable feature extraction for versioned assets
- Extending style suggestion registries with custom rules
Assumes this stack
P6 — Image→Persona Analyzer
Feature flag:
features.enable_image2persona(defaults false). Keep the flag off until the modder/QA lane verifies pipelines and hashes.
Checker:python tools/check_current_system.py --profile p6_image2persona --base http://127.0.0.1:8001
Intent
Turn 1–N reference images into structured Persona hints: appearance tags, color palette, pose anchors, expression prototypes, and downstream style/LoRA suggestions. The analyzer is deterministic (hash-stable) so assets can be versioned, diffed, and merged with the Persona schema and provenance logs.
Pipeline Overview
- Normalization – Each image is EXIF-transposed and converted to RGB before hashing (
sha1(version + dims + bytes)) to guarantee stable digests and provenance sidecars. - Palette extraction – RGB median-cut quantization (5–8 swatches) produces normalized swatches (
hex,rgb,luma,ratio,name). Sorting favours coverage, then hex to keep output stable across runs. - Appearance tagging – Heuristics derive
species,fur_skin,colorways,accent_colors, andclothing_motifsfrom palette statistics (with optional contributor overrides via hooks). - Pose anchors – A grayscale percentile mask estimates a subject bounding box; anchors are emitted for face, hands, and feet with normalized coordinates and confidence scores.
- Expression prototypes – Brightness/contrast metrics seed a neutral baseline plus optional
smile,soft_smile, andangerprototypes. Each carries mood, trigger hints, and average confidence. - Style fusion – Appearance tags feed
StyleSuggestionRegistry, returning studio-friendly style hints plus optional LoRA names (names only, no URLs/downloads). - Merge – Multiple images merge through weighted averages. Conflicts (e.g., disagreeing
speciesorprimary_color) are surfaced for review.
The top-level summary lives under metadata.image2persona when merged into a Persona profile and includes:
{
"appearance": {...},
"palette": [...],
"pose_anchors": {...},
"expression_set": {...},
"style": {
"styles": [{"id": "studio-portrait-soft", "priority": 0.6}],
"lora": [{"name": "portraitplus-v15", "priority": 0.55}],
"applied_tags": ["species:human", "clothing:minimalist"]
},
"conflicts": [{"field": "appearance.species", "values": ["human", "unspecified"]}]
}
Python API
from comfyvn.persona.image2persona import (
analyze_images,
ImagePersonaAnalyzer,
PersonaImageOptions,
)
sources = ["./persona_refs/front.png", "./persona_refs/profile.png"]
options = PersonaImageOptions(debug=True)
suggestion = analyze_images(sources, persona_id="heroine-01", options=options)
print(suggestion.summary["appearance"]["colorways"])
# ['primary:warm:orange', 'secondary:neutral:stone', 'accent:cool:teal']
profile = {}
analyzer = ImagePersonaAnalyzer(options)
merged_profile = analyzer.merge_into_persona_profile(profile, suggestion)
PersonaImageOptions.hooksaccepts optional callables (appearance,palette,anchors,expressions,summary) for modder overrides. Each hook receives the current payload and can return replacements/patches.options.debug=Trueattachesmetrics, palette tokens, and anchor boxes to each per-image report for tooling dashboards.- Output is fully JSON serializable; call
suggestion.as_json(indent=2)to persist snapshots for reviews.
Style & LoRA Suggestions
comfyvn/persona/style_suggestions.py ships a baseline registry. Contributors can extend it:
from comfyvn.persona.style_suggestions import StyleSuggestionRegistry
registry = StyleSuggestionRegistry.default()
registry.register_style("species:android", "hard-light-cyberpunk", 0.7)
registry.register_lora("colorway:accent:cool:teal", "cyan-rim-v12", 0.5)
options = PersonaImageOptions(style_registry=registry)
The analyzer only surfaces names; downstream fetchers are intentionally out-of-scope.
Debugging & Determinism
- Hashes include the analyzer version string (
p6.image2persona.v1). Bumping the algorithm requires updatingANALYZER_VERSIONand documenting changes in the changelog. conflictsenumerate mismatched attributes so producers can reconcile persona packs manually.- Enable
LOG_LEVEL=DEBUGand wrap extractor calls to logsuggestion.provenancefor QA pipelines. - Smoke tests: feed the same image set twice and assert identical
summary_digestvalues. Mix formats (PNG/JPEG/WebP) to confirm EXIF normalization.
Integration Notes
- Persona Manager consumers should treat
metadata.image2personaas advisory data. Leave canonical persona fields (name,expression,poses) unchanged unless the user confirms merges. - GUI/CLI panels can surface the palette and anchor previews by reading
PersonaSuggestion.per_image[*].debugwhen debug mode is enabled. - Feature flag stays off until
p6_image2personachecker passes (docs, files, flag defaults, API surface).
What's inside
7 pipeline steps, 2 Python classes, 1 style registry, 1 debug mode, 1 conflict detection, 1 integration note section
Change this for your project
- Replace
comfyvn.persona.image2personawith your own package path - Replace
ANALYZER_VERSIONstringp6.image2persona.v1with your version - Replace
http://127.0.0.1:8001in checker URL with your service endpoint
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Feature flag gating with a checker script before enabling
- Deterministic hashing including version string for stable asset versioning
- Conflict detection when merging multiple image analyses
Related Documents
Dota 2 Analysis Persona
Defines a structured persona for analyzing Dota 2 replays with frameworks, output formats, and tone guidelines.
🏂 Ridge - 滑雪板店铺AI助手
Defines a snowboard specialist persona named Ridge with 5 MCP tool triggers and 4 conversation flow examples for a Shopify chatbot.
AI_persona
Defines a meticulous, systematic AI coding assistant persona focused on codebase management, debugging, and improvement.
CTO Persona
Defines a CTO persona with decision frameworks, quality standards, and communication style for AI-assisted development.