Rework vision encoding prompts for proper image framing

Sampler vision re-encoding: prefix scene text with
"Continuing from this scene: {text}" so the model treats the
previous frame as temporal context, not an unrelated subject.

Studio per-scene reference conditioning: re-enable reference_image
with prefix "The character shown performs the following: {encode_text}"
so the model knows the image is a character reference, not something
to describe. Only applies when source_image is connected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
digital-garbage
2026-05-29 00:43:28 +03:00
co-authored by Claude Sonnet 4.6
parent bfa2bda7ab
commit 8846bdbce2
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -6397,7 +6397,7 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner):
scene_effects.append(effect)
return scene_texts, scene_effects
def _v2_transition_scene_conditionings(self, clip, scene_texts, scene_effects=None, encode_cache=None):
def _v2_transition_scene_conditionings(self, clip, scene_texts, scene_effects=None, encode_cache=None, reference_image=None):
if clip is None:
return None
scene_texts = list(scene_texts or [])
@@ -6412,7 +6412,8 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner):
seen_count = seen_texts.get(scene_text, 0)
seen_texts[scene_text] = seen_count + 1
encode_text = f"Returning to an earlier scene: {scene_text}" if seen_count > 0 else scene_text
cond, meta, _ = self._v2_encode_prompt(clip, encode_text, encode_cache=encode_cache)
vision_text = f"The character shown performs the following: {encode_text}" if reference_image is not None else encode_text
cond, meta, _ = self._v2_encode_prompt(clip, vision_text, encode_cache=encode_cache, reference_image=reference_image)
if not isinstance(cond, torch.Tensor):
return None
scene_meta = dict(meta) if isinstance(meta, dict) else {"pooled_output": None}
@@ -11839,6 +11840,7 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner):
if scene_texts:
scene_conditionings = self._v2_transition_scene_conditionings(
clip, scene_texts, scene_effects=split_scene_effects, encode_cache=encode_cache,
reference_image=source_image,
)
if scene_conditionings is not None:
output_conditioning = self._v2_apply_scene_seed_metadata(
+1 -1
View File
@@ -1366,7 +1366,7 @@ class FunPackLTXAVSceneChainSampler:
text = existing_meta.get("funpack_encode_text") or self._scene_text(next_cond, next_index)
if not text:
return None
tokens = clip.tokenize(text, image=pixel_frame, skip_template=False)
tokens = clip.tokenize(f"Continuing from this scene: {text}", image=pixel_frame, skip_template=False)
encoded = clip.encode_from_tokens_scheduled(tokens)
if not isinstance(encoded, list) or not encoded:
return None