text stringlengths 0 1.47k |
|---|
return compute_clip_windows(nframes, max_clip_len, clip_stride) |
clip_end = min(nframes, max_clip_len) if max_clip_len else nframes |
return [(0, clip_end)] |
# --------------------------------------------------------------------------- |
# Summary |
# --------------------------------------------------------------------------- |
def print_summary(stats): |
print(f'Total clips: {stats["total_clips"]}, Frames: {stats["total_frames"]}, ' |
f'Duration: {stats["duration_min"]:.1f}m (@{stats.get("fps", 30)} fps), ' |
f'Max joints: {stats["max_njoints"]}') |
# ===== file: data_process/joint_annotation/__init__.py ===== |
# ===== file: data_process/joint_annotation/face_correct_llm.py ===== |
"""Re-run LLM face-joint selection on rigs the first pass got wrong. |
:mod:`face_select_llm` writes the empty sentinel |
``{r_hip: {raw:"", clean:""}, l_hip: {raw:"", clean:""}, source: "empty"}`` |
whenever neither the rule-based hint nor the LLM finds a bilateral pair or |
a head/tail body axis. This script re-attempts those rigs (by default every |
``source == "empty"`` entry in ``--face``; optionally a subset listed in |
``--failed_list``) and, when the LLM now finds a valid pair, overwrites the |
entry in place. Rigs that still fail keep their existing entry. |
Unlike a plain re-run, this pass actually changes the odds: it uses a |
correction system prompt (re-derive from scratch, 'empty' only as a last |
resort), OMITS the rule-based hint that anchored the first pass, and |
defaults to a larger token/reasoning/timeout budget. Pair it with a |
stronger ``--model`` for best effect. |
NOTE on ``--failed_list``: ``failed_face_joints.txt`` records rigs that |
fell back to the RULE-BASED resolver — most of their entries are non-empty, |
so by default they are skipped. Pass ``--force_reattempt`` to re-attempt |
them; only a clean non-empty LLM win replaces an existing entry. |
A ``.bak`` sibling of ``--face`` is created on first run. Rigs that were |
empty and remain empty are appended to ``still_empty_face_joints.txt``. |
Usage: |
python -m data_process.joint_annotation.face_correct_llm \\ |
--raw <export_dir>/joint_names.json \\ |
--cleaned <export_dir>/clean_joint_names.json \\ |
--face <export_dir>/face_joint_names.json [--model gpt-5] |
""" |
import argparse |
import json |
import os |
import shutil |
import sys |
from loguru import logger |
from tqdm import tqdm |
_REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) |
if _REPO_ROOT not in sys.path: |
sys.path.insert(0, _REPO_ROOT) |
from data_process.joint_annotation.face_select_llm import ( # noqa: E402 |
SYSTEM_PROMPT, |
resolve_rig, |
) |
from data_process.joint_annotation.llm import ( # noqa: E402 |
LLMClient, |
MAX_RETRIES, |
add_llm_args, |
append_id_list, |
read_id_list, |
save_json, |
) |
# ───────────────────────────────────────────────────────────────────────────── |
# Correction-mode system prompt addendum |
# ───────────────────────────────────────────────────────────────────────────── |
# |
# Re-running the selection prompt verbatim on a rig it already got wrong |
# mostly reproduces the same answer. This pass therefore (a) appends the |
# preamble below and (b) omits the rule-based hint from the user prompt |
# (resolve_rig include_hint=False) — the hint IS the failed answer. |
CORRECTION_PREAMBLE = ( |
"=========================================================================\n" |
"CORRECTION PASS — A PREVIOUS RUN FAILED ON THIS RIG.\n" |
"=========================================================================\n" |
"An earlier pass could not produce a confident answer for this rig: it " |
"returned the 'empty' sentinel, or silently fell back to the " |
"deterministic resolver. No rule-based hint is shown in this pass — " |
"re-derive the answer from scratch by executing the ALGORITHM above, " |
"with extra care:\n" |
" - STEP 1: compare suffixes AFTER stripping the side prefix AND any " |
"trailing ' <digits>' — 'Right Thigh 1' / 'Left Thigh 2' DO overlap " |
"(suffix 'Thigh'). Digits and chain position never break a pair.\n" |
" - STEP 3: HEAD/TAIL rows also match ignoring trailing ' <digits>' " |
"('Tail 30' is a valid TAIL endpoint).\n" |
" - Return 'empty' ONLY when, after honestly executing steps 1-3, " |
"OVERLAP is empty AND no HEAD+TAIL axis exists. Vehicles, props and " |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.