How pq-yang/matanyone2 works
MatAnyone 2 is a human video-matting framework. Its main workflow takes a video and first-frame target mask, processes frames with persistent object and memory state, and produces foreground and alpha videos. Users can run this through the CLI/Python inference path or the interactive demo, which adds click-based mask creation; evaluation scripts are a separate capability. The graph reflects documented workflows and indexed source references; some internal implementations and demo wiring were not excerpted, so unsupported links are omitted.
Main entry points: inference_core.py Inference orchestration · app.py Gradio demo · matanyone2.py MatAnyone2 network · memory_manager.py Memory management
Components 26
User entry points
- Video and mask
- CLI
matanyone2/cli.py - Inference script
inference_matanyone2.py - Python API
matanyone2/inference/inference_core.py
Interactive mask demo
- Gradio demo
hugging_face/app.py - Click interaction
hugging_face/tools/interact_tools.py - Mask painting
hugging_face/tools/mask_painter.py - Result painter
hugging_face/tools/painter.py - Demo model wrapper
hugging_face/matanyone2_wrapper.py
Video inference runtime
- Frame input
matanyone2/utils/inference_utils.py - Inference orchestration
matanyone2/inference/inference_core.py - Image features
matanyone2/inference/image_feature_store.py - Memory management
matanyone2/inference/memory_manager.py - Key-value memory
matanyone2/inference/kv_memory_store.py - Object tracking
matanyone2/inference/object_manager.py - Foreground and alpha
Matting model
- MatAnyone2 network
matanyone2/model/matanyone2.py - Pixel and mask encoding
matanyone2/model/big_modules.py - Grouped features
matanyone2/model/group_modules.py - Object query transformer
matanyone2/model/transformer/object_transformer.py - Object summarizer
matanyone2/model/transformer/object_summarizer.py
Evaluation
- Evaluation scripts
evaluation/eval_crgnn.py - High-resolution evaluation
evaluation/eval_hr.py - Low-resolution evaluation
evaluation/eval_lr.py - Inference evaluation
evaluation/inference_matanyone_eval.py
Other components
- Video user
Connections 31
- Video user → Video and mask: provides
README.md - Video and mask → CLI: runs with
README.md - Video and mask → Inference script: runs with
README.md - Video user → Gradio demo: opens
README.md - CLI → Inference orchestration: invokes
matanyone2/cli.py - Inference script → Inference orchestration: invokes
inference_matanyone2.py - Python API → Inference orchestration: processes video
README.md - Gradio demo → Click interaction: uses
hugging_face/app.py - Gradio demo → Mask painting: uses
hugging_face/app.py - Gradio demo → Result painter: uses
hugging_face/app.py - Gradio demo → Demo model wrapper: uses
hugging_face/app.py - Demo model wrapper → Inference orchestration: wraps inference
hugging_face/matanyone2_wrapper.py - Click interaction → Mask painting: uses
hugging_face/tools/interact_tools.py - Click interaction → Result painter: uses
hugging_face/tools/interact_tools.py - Inference orchestration → Frame input: reads frames
matanyone2/inference/inference_core.py - Inference orchestration → Image features: uses
matanyone2/inference/inference_core.py - Inference orchestration → Memory management: manages memory
matanyone2/inference/inference_core.py - Inference orchestration → Object tracking: tracks objects
matanyone2/inference/inference_core.py - Inference orchestration → MatAnyone2 network: runs network
matanyone2/inference/inference_core.py - Inference orchestration → Foreground and alpha: writes videos
README.md - Memory management → Key-value memory: stores values
matanyone2/inference/memory_manager.py - Memory management → Object tracking: consults objects
matanyone2/inference/memory_manager.py - Memory management → MatAnyone2 network: uses network
matanyone2/inference/memory_manager.py - MatAnyone2 network → Pixel and mask encoding: encodes features
matanyone2/model/matanyone2.py - MatAnyone2 network → Object query transformer: reads queries
matanyone2/model/matanyone2.py - MatAnyone2 network → Object summarizer: uses summaries
matanyone2/model/matanyone2.py - Pixel and mask encoding → Grouped features: uses grouped ops
matanyone2/model/big_modules.py - Object query transformer → Grouped features: uses grouped ops
matanyone2/model/transformer/object_transformer.py - Evaluation scripts → High-resolution evaluation: includes
- Evaluation scripts → Low-resolution evaluation: includes
- Inference evaluation → Inference orchestration: evaluates inference
evaluation/inference_matanyone_eval.py