Commit Graph
31 Commits
Author SHA1 Message Date
Cherokee 85e2dc2fd2 feat: add bg_color option for cutout background (transparent/green/blue/black/white)
Default is transparent (WebM with VP9 alpha). Colored backgrounds output
MP4 with the selected solid color filling non-person pixels.
Transparent previews saved as PNG, colored as JPG.
2026-04-30 16:35:17 +08:00
Cherokee 2f58b7e589 fix: exclude frames without face detection from preview candidates
Only frames where InsightFace detected a face are considered for
preview selection. No fallback to mask bbox area — if no face was
detected, that frame is simply not a preview candidate.
2026-04-30 15:54:42 +08:00
Cherokee 3f91b426de fix: sort preview images by face area instead of mask bbox area
IdentityCluster now records face bbox areas during clustering (when
InsightFace already detects faces). Preview image selection uses
these face areas for sorting, with fallback to mask bbox area when
no face was detected.
2026-04-30 15:22:23 +08:00
Cherokee 322f8d9b71 improve: performance optimization — downscale inference, defer green screen, add skip_every_n
- Optimization 1: Downscale frames to 640px max-side before YOLOv8-seg
  inference in segmenter.py, resize masks back to original resolution
  (~13% speedup from reduced post-processing)
- Optimization 2: Store bool masks instead of composited BGR frames in
  MaskActor.frames (~97% memory reduction per tracked frame, from ~6MB
  to ~200KB per entry). Green screen now applied on-the-fly during
  encoding rather than during tracking.
- Optimization 3: Add skip_every_n parameter to VideoActorExtractor
  (default 1=all, 2=every other frame, up to 30). Users can trade
  precision for speed.
- Add per-substep timing (Detection vs Tracking) printed after frame loop
2026-04-30 14:04:35 +08:00
Cherokee 7f9d51c55d chore: prepare pyproject.toml for ComfyUI registry publishing
- Set PublisherId to ahkimkoo
- Add DisplayName, Repository URL
- Bump version to 1.0.0 for initial registry release
- Switch license from Apache-2.0 to MIT
2026-04-30 11:44:28 +08:00
Cherokee 0abc9b54c3 docs: add plain-language explanation for face_threshold and min_track_length 2026-04-30 11:32:35 +08:00
Cherokee 2092da6623 feat: auto-check and download missing models at pipeline start
- Add core/model_utils.py with ensure_models_exist() function
- Auto-download yolov8n.pt and yolov8n-seg.pt from GitHub if missing
- Auto-download InsightFace buffalo_l via InsightFace API if missing
- Handle InsightFace path quirk (models/buffalo_l/ -> buffalo_l/)
- Call ensure_models_exist() at start of VideoActorExtractor.extract()
2026-04-30 11:06:14 +08:00
Cherokee 7b19351c36 feat: preview sorting by bbox area, output frame indexes as INT list, update README
- Sort preview images by mask bbox area (proxy for face size) instead of mask pixel area
- MaskActor.frames now stores 4-tuple (frame_idx, masked_frame, mask_area, bbox_area)
- SelectActorPreview outputs indexes as INT list (not JSON string)
- Add OUTPUT_IS_LIST for indexes output
- Save frame indexes JSON alongside preview JPGs for each actor
- Update README with full node I/O documentation, workflow screenshot, and workflow file link
- Update examples: add screenshot, update workflow JSON
2026-04-30 10:59:17 +08:00
Cherokee 59e768891c improve: SelectActorPreview returns full IMAGE batch instead of single photo
- Remove photo_index parameter; load all actor_{i}_*.jpg previews automatically
- Return [N, H, W, 3] batch tensor with all preview images for the actor
- Fix return type: must return (tensor,) tuple for ComfyUI merge_result_data
2026-04-29 18:19:08 +08:00
Cherokee d6d208081b feat: add SelectActorPreview node, identity temporal constraints, and preview images to disk
- Add SelectActorPreview node to load per-actor preview images as ComfyUI IMAGE tensors
- Fix SelectActorPreview return value: must return (tensor,) tuple, not bare tensor,
  to prevent ComfyUI's merge_result_data from misinterpreting batch dimension as
  output count (root cause of 1920-image bug)
- Change VideoActorExtractor third output from IMAGE tensor to INT actor_count
- Save top-5 preview JPGs per actor to {output_dir}/previews/ instead of
  building a large preview tensor in memory
- Unify InsightFace model path to ComfyUI/models/video-actor-extract/buffalo_l/
- Add temporal gap penalty with grace gap to identity clustering
- Add temporal boost with Gaussian decay and spatial blocker check
- Add dual-signal track splitting (centroid displacement + bbox area ratio)
- Add spatial centroid proximity tiebreaker for identity merging
- Add debris mask filtering (min_mask_area=20000) in MaskTracker
- Clean up unused imports across modified files
- Add AGENTS.md project guidelines and test infrastructure
2026-04-29 09:34:33 +08:00
Cherokee f1cd44a280 docs: rewrite installation section for ComfyUI Manager distribution
- Add ComfyUI Manager and git clone installation methods
- Replace hardcoded paths with ComfyUI/ relative path convention
- Add YOLOv8 model download commands (yolov8n.pt, yolov8n-seg.pt)
- Add InsightFace buffalo_l download via Python API with directory fix
- Include final model directory tree structure
- Update project structure to include nodes/select_preview.py
2026-04-28 17:45:28 +08:00
Cherokee 75b7a432f5 feat(preview): reshape actor_preview_images to [num_actors, 5, H, W, 3]
- Group preview frames per actor instead of flat list
- Pad each actor to exactly 5 frames with black frames
- Update all empty_preview shapes to match new 5D format
- Add debug print for preview tensor shape verification
2026-04-28 16:16:09 +08:00
Cherokee 1701944636 fix: identity clustering with track splitting, spatial tiebreaker, and temporal constraints
- Add dual-signal track splitting (centroid displacement + bbox area ratio)
  with dominant outlier detection to split mixed-identity tracks before
  clustering, so each subtrack gets an independent merge decision
- Move track splitting from cluster_tracks() to actor_extractor.py to
  preserve subtrack identity through the pipeline
- Add spatial centroid proximity tiebreaker: when face similarity scores
  are within 0.1 margin, prefer merging with the spatially closer actor
- Add temporal gap penalty (gap < max_lost_frames) to respect tracker's
  rejection decision, with grace gap (≤2 frames) for timing artifacts
- Add temporal boost (gap ≥ max_lost_frames, no blocker) for same-person
  return detection using Gaussian decay confidence
- Add spatial blocker check: tracks in the temporal gap near the candidate
  prevent incorrect cross-gap merges
- Add min_mask_area filtering (20000px) in MaskTracker to reject debris
  masks from scene transitions
2026-04-28 15:39:18 +08:00
Cherokee 63e4f0e525 docs: comprehensive README with architecture, usage, and testing guide 2026-04-24 16:08:32 +08:00
Cherokee 764c3ed9b3 improve: identity clustering with connected components, better face detection, and debug logging
Key improvements:
1. Face detection: Try multiple crop sizes (0.6, 1.0, 1.5, 2.0x expansion) + full frame fallback
2. Frame sampling: 30 frames per track (up from 10), prioritize largest area frames
3. Clustering: Connected components instead of greedy, with temporal constraints
   - Temporally adjacent tracks (gap <= 100 frames): normal threshold
   - Non-adjacent tracks: require higher similarity (0.75) to merge
4. Debug logging: Print face detection counts and similarity scores

Test results on mmexport1776472655192.mp4 (1 adult + 2 children):
- 4 tracks detected by mask tracker
- Track 0: frames 0-100 (adult)
- Track 1: frames 97-196 (child 1)
- Track 2: frames 97-196 (child 2)
- Track 3: frames 197-288 (adult reappears)
- Similarity: Track 1 vs 2 = 0.982 (very high, likely same child or twins)
- Similarity: Track 1 vs 3 = 0.734, Track 2 vs 3 = 0.725 (adult-child similarity)
- Result: 2 actors (adult + child)

Note: Only 2 actors instead of expected 3 because Track 1 and Track 2 have
very high face similarity (0.982), suggesting they may be the same child or
twins. The face detection may not distinguish between the 2 children.
2026-04-24 15:48:33 +08:00
Cherokee 3bc44d42dd fix: correct identity renumbering to preserve integer track ID keys
The renumbering step in identity.py was iterating over actor_map.items()
(old_actor_name -> new_index) instead of track_to_actor (track_id -> old_name),
causing the returned dict to have string keys instead of integer track IDs.
This led to KeyError when downstream code looked up tracks in long_actors.
2026-04-24 10:19:04 +08:00
Cherokee aa2e07167d fix: per-frame processing to avoid 14GB memory spike 2026-04-23 18:01:17 +08:00
Cherokee 63fc34bd5a fix: improve identity clustering + model paths to ComfyUI/models/video-actor-extract 2026-04-23 15:38:30 +08:00
Cherokee 967fe6da2b fix: mask tracker for complete person extraction + continuous segments
- Replace ByteTrack mask assignment with centroid-distance MaskTracker
- Every detected person mask gets extracted, no more missed people
- Continuous segment output with interpolation for small gaps
- Accurate start_frame/end_frame/frame_count in JSON
2026-04-23 10:52:20 +08:00
Cherokee df3feddbb1 fix: use unique output directory per run (uuid4 short) 2026-04-22 18:32:24 +08:00
Cherokee eef072e85e feat: integrate PersonSegmenter for mask-based green screen extraction
- Replace bbox crop with YOLOv8-seg person segmentation
- Full-frame green screen: only person silhouette kept
- Top 5 preview images per actor by mask area (IMAGE output)
- Accurate time segmentation: only frames where person is visible
- No green gaps between segments
- Add seg_model_path parameter
2026-04-22 17:08:54 +08:00
Cherokee 713596c1d3 fix: remove incorrect squeeze(0) on 4D IMAGE tensor 2026-04-21 19:16:06 +08:00
Cherokee 4a819d659e feat: update node to accept IMAGE input from VHS LoadVideo
- Changed video_path (STRING) to images (IMAGE) as required input
- Removed fps_sample parameter (process all frames from VHS)
- Added optional video_path for metadata fallback
- Updated workflow file with VHS_LoadVideo node
- Saved workflow to ~/App/ComfyUI/user/default/workflows/
- Node now connects: VHS LoadVideo IMAGE -> VideoActorExtractor
2026-04-21 19:09:32 +08:00
Cherokee 41510eecbe feat: add ComfyUI workflow file and usage examples
- video-actor-extract.json: drag-and-drop workflow for ComfyUI
- Includes VideoActorExtractor + Save Text File nodes
- README with parameter tuning guide
- Saved to both examples/ and ComfyUI output/workflows/
2026-04-21 18:54:20 +08:00
Cherokee ebad5ec8a2 fix: resolve namespace conflict with ComfyUI nodes module
- Rewrote __init__.py to use importlib for loading modules
- Avoids conflict between plugin's nodes/ dir and ComfyUI's nodes.py
- Tested in ComfyUI with 1080x1920 18.7s video
- Successfully detected 10 actors with green screen output
- actor_1 correctly shows 2 segments (appeared mid-video, left, returned)
- All actor_info.json and per-actor MP4s generated correctly
2026-04-21 17:34:14 +08:00
Cherokee 4c04bcfc26 test: full pipeline test passed
- YOLOv8 model downloaded successfully (6.5MB)
- Tested with sample_demo_1.mp4 (640x360, 25fps, 9.7s)
- Detected 1 actor (actor_0)
- Output: actor_0.mp4 (497KB, green screen cropped)
- Output: actor_info.json (valid JSON with frame ranges)
- Node loads correctly in ComfyUI environment
- Symlink to custom_nodes verified
2026-04-21 17:21:03 +08:00
Cherokee 67fdc05c9c fix: import DEFAULT_YOLO_MODEL in actor_extractor node 2026-04-20 15:01:07 +08:00
Cherokee 53b2246c81 chore: add .gitignore, remove pycache files 2026-04-20 15:00:04 +08:00
Cherokee 6e6564ff6a feat: add model_path parameter and README
- Added model_path input to VideoActorExtractor node
- Added comprehensive README with setup instructions
- Cleaned up test artifacts
2026-04-20 14:59:51 +08:00
Cherokee 968b9e6b19 feat: initial implementation of VideoActorExtract plugin
- YOLOv8 person detection (ultralytics)
- ByteTrack multi-object tracking (with greedy fallback)
- InsightFace face recognition + cosine similarity clustering
- Green screen actor cropping
- Multi-segment video merging with ffmpeg
- ComfyUI node: VideoActorExtractor (category: video/actor)
- Output: per-actor MP4 + actor_info.json
2026-04-20 14:36:09 +08:00
Cherokee e88b73dafd Initial commit: requirements and architecture docs 2026-04-20 14:09:02 +08:00