Loading...
Loading...
Generates a new image that imitates the style of a reference image while updating content based on user intent. Uses a three-stage pipeline: image annotation (long caption), caption rewriting, and image generation. Use when user asks to "imitate style", "保持这个风格重画", "按这张图风格生成", or "style transfer with new content".
npx skill4agent add opensensenova/sensenova-skills sn-image-imitatesn-image-recognizesn-text-optimizesn-image-generatesn-image-basereference_imagetarget_contentoutput_modefriendlyfriendlyverboseaspect_ratio16:9image_size2kmax_attempts3layout_threshold0.75sn-image-baseSN_BASE_URL="https://token.sensenova.cn/v1"
SN_API_KEY="your-api-key"SN_TEXT_API_KEYSN_CHAT_API_KEYSN_API_KEYSN_VISION_API_KEYSN_CHAT_API_KEYSN_API_KEYSN_IMAGE_GEN_API_KEYSN_API_KEYsn-image-generate_en.mdsn_agent_runner.pysn-image-basesn-image-basesn-image-recognizesn-text-optimizesn-image-generateMissingApiKeyError$SN_IMAGE_BASE/references/api_spec.md$SN_IMAGE_BASE$SN_IMAGE_BASEsn-image-baseSKILL.mdsn-image-basereference_imagetarget_contentoutput_modefriendlyaspect_ratio16:9image_size2kmax_attempts3layout_threshold0.75reference_imagetarget_content"Using sn-image-imitate skill to generate a style-consistent image, please wait..."status=okstatus=errorreference_imagetarget_contentoutput_modeaspect_ratioimage_sizemax_attemptslayout_threshold$SKILL_DIRsn_agent_runner.pystatus=errorresultstatus=errortask_idYYYYMMDD_HHMMSS/tmp/openclaw/sn-image-imitate/<task_id>/TEMP_DIRREFERENCE_IMAGEecho "$TARGET_CONTENT" > "$TEMP_DIR/target-content.txt"prompts/image_annotate.mdsn-image-recognizepython "$SN_IMAGE_BASE/scripts/sn_agent_runner.py" sn-image-recognize \
--system-prompt-path "$SKILL_DIR/prompts/image_annotate.md" \
--user-prompt "Please annotate this reference image and follow the required output format." \
--images "$REFERENCE_IMAGE" \
--output-format jsonresultSHORT_CAPTION: ...LONG_CAPTION: ...LAYOUT_BLUEPRINT_JSON: { ... }LONG_CAPTIONLAYOUT_BLUEPRINT_JSONstatus=errorecho "$SHORT_CAPTION" > "$TEMP_DIR/reference-short-caption.txt"
echo "$LONG_CAPTION" > "$TEMP_DIR/reference-long-caption.txt"
echo "$LAYOUT_BLUEPRINT_JSON" > "$TEMP_DIR/layout-blueprint.json"target_contentlayout-blueprint.jsonprompts/caption_rewrite.mdRewrite the long caption by preserving style and layout constraints while replacing semantic content according to user target. Do not change block topology, reading order, or visual hierarchy. Keep the caption detailed and directly usable for image generation.sn-text-optimizepython "$SN_IMAGE_BASE/scripts/sn_agent_runner.py" sn-text-optimize \
--system-prompt-path "$SKILL_DIR/prompts/caption_rewrite.md" \
--user-prompt "Reference long caption:\n$LONG_CAPTION\n\nLayout blueprint JSON:\n$LAYOUT_BLUEPRINT_JSON\n\nTarget content:\n$TARGET_CONTENT\n\nReturn only the rewritten long caption." \
--output-format jsonresultNEW_LONG_CAPTIONstatus=errorecho "$NEW_LONG_CAPTION" > "$TEMP_DIR/new-long-caption.txt"attempt1max_attemptssn-image-basesn-image-generatepython "$SN_IMAGE_BASE/scripts/sn_agent_runner.py" sn-image-generate \
--prompt "$CURRENT_PROMPT" \
--aspect-ratio "$ASPECT_RATIO" \
--image-size "$IMAGE_SIZE" \
--save-path "$TEMP_DIR/attempt_<N>.png" \
--output-format jsonmax_attempts > 1max_attempts1max_attempts > 1prompts/layout_review.mdpython "$SN_IMAGE_BASE/scripts/sn_agent_runner.py" sn-image-recognize \
--system-prompt-path "$SKILL_DIR/prompts/layout_review.md" \
--user-prompt "Reference is image[0], candidate is image[1]. Layout blueprint JSON:\n$LAYOUT_BLUEPRINT_JSON\n\nEvaluate layout similarity and return JSON only." \
--images "$REFERENCE_IMAGE" "$TEMP_DIR/attempt_<N>.png" \
--output-format jsonresult{
"layout_similarity_score": 0.0,
"style_similarity_score": 0.0,
"pass": false,
"major_deviations": [],
"fix_hints": []
}{
"attempt": 1,
"image": "$TEMP_DIR/attempt_1.png",
"layout_similarity_score": 0.0,
"style_similarity_score": 0.0,
"pass": false,
"major_deviations": [],
"timing": {
"image_generation": { "elapsed_seconds": 12.34, "model": "sn_image_model" },
"vlm_review": { "elapsed_seconds": 5.67, "model": "sensenova-122b" }
}
}elapsed_seconds--output-format jsonimage_generation.model"sn_image_model"vlm_review.modeltiming.vlm_reviewmax_attempts=1max_attempts > 1layout_similarity_score >= layout_thresholdpass = trueLayout correction requirements:
- <fix_hint_1>
- <fix_hint_2>
...layout_passed=false{
"status": "ok",
"need_main_agent_send": true,
"output_mode": "friendly|verbose",
"result": {
"image": "/tmp/openclaw/sn-image-imitate/<task_id>/attempt_2.png",
"reference_image": "<resolved_reference_image>",
"reference_short_caption": "<short caption from step 1>",
"reference_long_caption": "<long caption from step 1>",
"layout_blueprint": { "...": "..." },
"new_long_caption": "<rewritten long caption from step 2>",
"layout_passed": true,
"selected_attempt": 2
},
"attempts": [
{
"attempt": 1,
"image": "/tmp/openclaw/sn-image-imitate/<task_id>/attempt_1.png",
"layout_similarity_score": 0.62,
"style_similarity_score": 0.79,
"pass": false,
"major_deviations": ["center panel too narrow", "title block moved to top-right"]
},
{
"attempt": 2,
"image": "/tmp/openclaw/sn-image-imitate/<task_id>/attempt_2.png",
"layout_similarity_score": 0.81,
"style_similarity_score": 0.84,
"pass": true,
"major_deviations": []
}
],
"review": {
"threshold": 0.75
},
"timing": {
"total_elapsed_seconds": 24.56,
"annotate": { "elapsed_seconds": 3.21, "model": "sensenova-122b" },
"rewrite": { "elapsed_seconds": 2.45, "model": "sensenova-122b" },
"generation_total": { "elapsed_seconds": 11.90, "model": "sn_image_model" },
"review_total": { "elapsed_seconds": 7.00, "model": "sensenova-122b" }
}
}{
"status": "error",
"error": "<actual_error_message>"
}status=okneed_main_agent_send: trueresult.imagetiming.total_elapsed_secondsstatus=errorattemptsresult.layout_passed=falseresult.imageStyle imitation result
---
Reference short caption: <reference_short_caption>
---
Style/layout cues:
<brief extraction from reference_long_caption + layout_blueprint>
---
New long caption:
<new_long_caption>
---
#1 attempt=<n> layout_score=<0.00> style_score=<0.00> pass=<true|false> [selected]
deviations: <major_deviations or none>
#2 attempt=<n> layout_score=<0.00> style_score=<0.00> pass=<true|false>
deviations: <major_deviations or none>
...
---
Layout threshold: <0.75> | Passed: <true|false> | Selected: attempt <n>
Time statistics: Total <total>s | Annotation <t>s | Rewrite <t>s | Generation <t>s×<n> attempts | Review <t>s×<n> attempts
---
Images (selected image)sn-image-basesn-image-recognizesn-text-optimizesn-image-generateprompts/image_annotate.mdprompts/caption_rewrite.mdprompts/layout_review.md../sn-image-base/SKILL.md