Nodes/ComfyUI-WanAnimatePreprocessV2/Pupil Dilation Tracker
ComfyUI Node

Pupil Dilation Tracker

Track pupil dilation without the camera-distance trap

By Code2Collapse·Created 8 months ago·Updated 8 days ago· 17
Pupil Dilation Tracker
  • pose_data
  • face_bboxes
  • dilation_report_json
  • radius_series_json
  • mean_normalized
  • stddev_normalized
normalisereye_width
event_threshold1.25
min_consecutive_frames3
smooth_window5
fps30.0

Pupil dilation is one of those signals that reads as deeply human - surprise, focus, arousal - and that AI-generated faces get subtly wrong. PupilDilationTrackerC2C measures it from your driving video's pose_data: it tracks the per-frame pupil radius and normalizes it against an invariant scale, so a person walking toward the camera (which makes their pupils look bigger in raw pixels) doesn't get misreported as dilation.

It's another KANIBUS eye-measurement node, pure analysis, no model. The clever part is the normalization, because raw pupil radius in pixels is meaningless when the subject's distance to camera changes mid-clip - which is most clips.

How it works

The node pulls the pupil radius for each eye from pose_data's iris data, then divides by a per-frame scale factor chosen by the normaliser dropdown:

  • eye_width (default) - the horizontal distance between the outer/inner eye corners. This is the canonical choice, and the point is that eye width is a stable property of the face while pupil size changes, so the ratio is distance-invariant.
  • face_bbox_diag - the diagonal of the per-frame face bounding box (needs the face_bboxes BBOX wired in).
  • first_frame_radius - the pupil radius measured on the first valid frame, giving you "% of baseline" reporting.

After normalization it median-smooths over a causal window and reports a dilation event when the normalized radius rises above mean_normalized × event_threshold for at least min_consecutive_frames frames. That threshold-as-multiple-of-the-mean framing means it's adaptive: it flags excursions above the clip's own baseline rather than an absolute pixel value.

Inputs and outputs

The four knobs: event_threshold (1.25, meaning 25% above the clip mean), min_consecutive_frames (3), smooth_window (5), and fps. Outputs: dilation_report_json (per-frame series plus a list of detected events with start/end frames), radius_series_json, and two float summaries - mean_normalized and stddev_normalized - that give you a single "how lively are the pupils in this clip" number pair. A higher stddev relative to mean is the tell of genuine dilation dynamics.

The honest take

This is the most niche node in the pack, and it's fine to say so. If you're doing talking-head driving for Wan Animate, pupil dilation is a subtlety that will mostly get flattened by the face encoder's compression anyway - the pack's own spec notes say the encoder packs motion into a small fixed-capacity vector, and subtle signals sit near the noise floor. Where this node earns its keep is as a source-footage QA check (does the actor actually dilate on that reaction?) or as research instrumentation. If you're wondering whether your driving clip has the micro-signals you want the character to inherit, it gives you a number instead of a guess.

Caveat that applies to the whole KANIBUS series: these nodes read whatever pose_data gives them, so pupil detection quality matters. On close-up to medium shots where the eye is wide enough, the iris data is solid; on distant subjects the detection falls back to a geometric center with low confidence, and your dilation series quietly turns into noise. Check the debug image from the detection node before trusting the numbers.

Install: shared pack path - ComfyUI Manager, or git clone https://github.com/Code2Collapse/ComfyUI-WanAnimatePreprocessV2 into custom_nodes + pip install -r requirements.txt + restart.

CategoryWanAnimatePreprocess_V2/KANIBUS

Inputs (7)

NameTypeDefaultDescription
pose_dataPOSEDATA
normaliserCOMBOeye_width3 options: eye_width, face_bbox_diag, first_frame_radius
event_thresholdFLOAT1.251–3
min_consecutive_framesINT31–60
smooth_windowINT51–31
fpsFLOAT30.01–240
face_bboxesoptBBOX

Outputs (4)

NameTypeDescription
dilation_report_jsonSTRING
radius_series_jsonSTRING
mean_normalizedFLOAT
stddev_normalizedFLOAT