Revert long videos ref routing to release
This commit is contained in:
+8
-28
@@ -4558,7 +4558,7 @@ def _connected_refs(ref_slots):
|
||||
return [ref for ref in (ref_slots or []) if _reference_image(ref) is not None]
|
||||
|
||||
|
||||
def resolve_tagged_refs(text, ref_list):
|
||||
def resolve_tagged_refs(text, ref_list):
|
||||
"""(rewritten text, images, dropped) for the <Picture N> tags in ONE shot.
|
||||
|
||||
The tokenizer numbers references by their position in the list it is handed, so
|
||||
@@ -4579,31 +4579,11 @@ def resolve_tagged_refs(text, ref_list):
|
||||
return f"<Picture {renumber[n]}>" if n in renumber else ""
|
||||
|
||||
out = _PICTURE_TAG.sub(sub, text or "")
|
||||
if dropped: # tidy the gap a removed tag leaves behind
|
||||
out = re.sub(r"\s+([,.;:])", r"\1", out)
|
||||
out = re.sub(r"(,\s*){2,}", ", ", out)
|
||||
out = re.sub(r"\s{2,}", " ", out)
|
||||
return out.strip(), [ref_list[n - 1] for n in live], dropped
|
||||
|
||||
|
||||
def resolve_prompt_refs(text, ref_list):
|
||||
"""(rewritten text, refs, dropped) for the refs a shot actually carries.
|
||||
|
||||
Explicit <Picture N> tags still decide which slot numbers the prompt points at,
|
||||
but named character matches must ride into the real ref-image list too. Without
|
||||
that split, a shot could inherit the facts/context for "Mara" and "Jon" while
|
||||
only carrying a tagged location image, which reads exactly like the names were
|
||||
understood but the faces were ignored."""
|
||||
rewritten, tagged_refs, dropped = resolve_tagged_refs(text, ref_list)
|
||||
refs = list(tagged_refs)
|
||||
seen = {id(ref) for ref in refs}
|
||||
for _slot_number, ref in _named_character_refs_for_text(rewritten, ref_list):
|
||||
marker = id(ref)
|
||||
if marker in seen:
|
||||
continue
|
||||
seen.add(marker)
|
||||
refs.append(ref)
|
||||
return rewritten, refs, dropped
|
||||
if dropped: # tidy the gap a removed tag leaves behind
|
||||
out = re.sub(r"\s+([,.;:])", r"\1", out)
|
||||
out = re.sub(r"(,\s*){2,}", ", ", out)
|
||||
out = re.sub(r"\s{2,}", " ", out)
|
||||
return out.strip(), [ref_list[n - 1] for n in live], dropped
|
||||
|
||||
|
||||
def shot_references(ref_list, ref_mode, shot_index, handoff):
|
||||
@@ -6770,7 +6750,7 @@ class H3LongVideos:
|
||||
for shot_index, gen in enumerate(gens):
|
||||
shot_mode = beat_ref_mode_directive(beats[shot_index] if shot_index < len(beats) else "") or ref_mode
|
||||
if shot_mode in ("where tagged", "auto ref2v") and any_tags_anywhere:
|
||||
if resolve_prompt_refs(gen, ref_slots)[1]:
|
||||
if resolve_tagged_refs(gen, ref_slots)[1]:
|
||||
on.append(shot_index + 1)
|
||||
tagged_used = True
|
||||
else:
|
||||
@@ -6865,7 +6845,7 @@ class H3LongVideos:
|
||||
# The prompt itself says where each reference belongs: the shot whose
|
||||
# text names <Picture N> gets image N, renumbered to match what that
|
||||
# shot actually carries. Every untagged shot keeps its handoff.
|
||||
gen_prompt, shot_refs, dropped = resolve_prompt_refs(gen_prompt, ref_slots)
|
||||
gen_prompt, shot_refs, dropped = resolve_tagged_refs(gen_prompt, ref_slots)
|
||||
for n in dropped:
|
||||
if n not in ref_missing:
|
||||
ref_missing.append(n)
|
||||
|
||||
Reference in New Issue
Block a user