Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Heuristic:PeterL1n BackgroundMattingV2 Backbone Scale Selection

From Leeroopedia
Revision as of 10:47, 16 February 2026 by Admin (talk | contribs) (Auto-imported from heuristics/PeterL1n_BackgroundMattingV2_Backbone_Scale_Selection.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)




Knowledge Sources
Domains Computer_Vision, Optimization
Last Updated 2026-02-09 02:00 GMT

Overview

Resolution-dependent backbone scale selection: use 0.25 for HD (1080p) and 0.125 for 4K, with a hard constraint that backbone_scale must not exceed 0.5.

Description

The `backbone_scale` parameter controls the downsampling factor applied to input images before passing through the encoder backbone. A lower scale means the backbone processes a smaller image, reducing computation and memory, while the refinement network recovers full-resolution detail in error-prone regions. The scale must be tuned based on input resolution to balance quality and speed.

Usage

Use this heuristic when configuring MattingRefine for inference or training. The correct backbone_scale depends on the target input resolution. Choosing too high a scale wastes computation on the backbone; choosing too low a scale degrades coarse prediction quality beyond what the refiner can recover.

The Insight (Rule of Thumb)

  • Action: Set `backbone_scale` based on input resolution.
  • Value: `0.25` for HD (1920x1080), `0.125` for 4K (3840x2160). Default is `0.25`.
  • Hard Constraint: `backbone_scale` must not exceed `0.5` (enforced by assertion).
  • Trade-off: Lower scale = faster backbone pass but coarser initial prediction; higher scale = better coarse output but slower and more memory.

Reasoning

The backbone operates at `backbone_scale` of the full resolution. At 0.25 scale, a 1920x1080 input becomes 480x270 for the backbone, which is sufficient for coarse alpha/foreground/error prediction. The refinement network then selectively upsamples error-prone regions at full resolution. The 0.5 upper bound is enforced because processing at more than half resolution negates the efficiency benefit of the two-stage architecture. The official documentation recommends `backbone_scale=0.25, refine_sample_pixels=80000` for HD and `backbone_scale=0.125, refine_sample_pixels=320000` for 4K.

Code evidence from `model/model.py:150`:

assert backbone_scale <= 1/2, 'backbone_scale should not be greater than 1/2'

Documentation evidence from `doc/model_usage.md:160`:

We recommend backbone_scale=0.25, refine_sample_pixels=80000 for HD
and backbone_scale=0.125, refine_sample_pixels=320000 for 4K.

Default in training from `train_refine.py:52`:

parser.add_argument('--model-backbone-scale', type=float, default=0.25)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment