You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document maps every equation of the ReDiMask paper to the implementation,
and records the decisions taken where the paper specifies the role of a term but
not its functional form.
Sec. III-B — Regionized Diffusion Labeling
Paper
Implementation
Eq. (1) region descriptor h^t_{i,j} = mean of F^t_phi(x_i) over region r_{i,j}
redimask/regions.py::RegionAggregator.descriptors
Region partition R_i = {r_{i,j}} (SLIC, spatial support only)
redimask/regions.py::slic_partition
Eq. (2) assignment margin rho^t_{i,j} = sim to nearest minus sim to second-nearest prototype
Eq. (11) candidate-assignment count v_{i,j}, mean margin rho_bar
RegionizedDiffusionLabeling.render
Eq. (12) region label in {1, 0, 255}
RegionizedDiffusionLabeling.render
Pixel projection of region labels
RegionizedDiffusionLabeling.render
Decisions where the paper leaves the functional form open
M_k (margin term, Eq. 8) — implemented as the mean prototype margin of
the regions supporting group k, then min-max normalised across groups.
S_k (timestep-consistency term, Eq. 8) — the paper states "whether the
cluster is repeatedly supported by the same regions across low-noise
timesteps". Implemented as the mean, over the supporting regions, of the
fraction of timesteps in which the region is aligned to group k. The value
already lies in [0, 1] and is min-max normalised with the other terms.
R_k (spatial-regularity term, Eq. 8) — the paper states it is computed
from image-derived region supports. Implemented as the mean isoperimetric
ratio 4*pi*A / P^2 of the supporting SLIC regions, which down-weights
fragmented or sprawling supports. The hard coverage filter (0.5%–70%) is
applied before ranking, as described in the paper.
Group coverage — computed from the aligned assignments at the reference
timestep so that per-image coverage is non-overlapping and deterministic.
tau_m and tau- — both set to the image-level median of the prototype
margins, as stated in the Implementation Details ("the image-level median of
prototype margins is used as the margin cutoff"; "regions that never belong to
candidate groups and have above-median margins are labeled as reliable
non-building").
Native resolution of the feature map — RDL is defined on the 16x16
mid-block activation resized to the 256px patch. The structural response
B_i is computed at 16x16 and then resized, and the region descriptors are
obtained with the equivalent bilinear aggregation matrix, so that the
1280x256x256 tensor is never materialised.
Sec. III-C — Coarse segmentation student
Paper
Implementation
Eq. (13) A_c = S_theta(x) single-channel building score map
redimask/student.py::CoarseStudent.forward
Eq. (14) P_c = Sigmoid(A_c)
redimask/student.py::CoarseStudent.probability
Eq. (15) valid pixel set Omega_v (all pixels with a non-ignored label)
redimask/student.py::partial_bce
Eq. (16) partial BCE over Omega_v
redimask/student.py::partial_bce
Student frozen before W-MR training
tools/train_wmr.py (requires_grad_(False))
The paper does not fix the student architecture; a three-level U-Net with
base_channels = 32 is used (redimask/nets.py).
The paper writes the student output as a single-channel score map. The
implementation can also carry a native class map; in that case the building
score is read as the building logit minus the log-sum-exp of the remaining
logits, exposed as redimask/student.py::building_binary_logit. Both forms
describe A_c of Eq. (13) and the single-channel reduction is the default.
Decisions where the paper leaves the functional form open
T_infer (Eq. 25) — the Q = 3 fixed noise-condition levels are evenly
spaced over the training range, from the upper bound down to the lower bound.
tau_seg — the paper introduces it in Algorithm 2 without a value; the
default is 0.5.
Timestep conditioning — the noise level is supplied to the residual
branch as a broadcast scalar channel. This is the only conditioning the paper
requires ("conditioned on the image, the perturbed mask state, and the noise
level").
L_ref numerics — computed with binary_cross_entropy_with_logits on
A_r, which is algebraically identical to BCE(P_r, Y_hat) with
P_r = Sigmoid(A_r) and numerically stable.
Anchoring of the loss — Omega_g is the intersection of the valid
pseudo-label set Omega_v and the gate, exactly as written in Eq. (23).
alpha (Eq. 21) and T_train (Eq. 17) — the paper gives the role of both
but no value. The defaults are alpha = 1.0 and T_train = [0.0, 0.30].
Perturbation schedule (Eq. 17) — projection, the form written in the
paper, is the default. variance_preserving is offered through
wmr.noise_schedule as an alternative normalisation of the perturbed state.
positive_dropout — defaults to 0.0, i.e. no foreground pixels are
removed before perturbation. The value is exposed for completeness.
Sec. III-E — Interior Consistency Correction
Paper
Implementation
Enclosed non-building component, no border contact, area <= 1024, mean probability >= 0.15
redimask/icr.py::apply_icr
Small reliable interior holes only
4-connectivity components, area threshold, probability threshold
Sec. IV-A — Metrics
Paper
Implementation
Eq. (26) IoU, F1
redimask/metrics.py::mask_metrics
Eq. (27) boundary precision/recall with 3-pixel dilation tolerance
mask_metrics, binary_boundary, dilate_binary
Eq. (28) BoundF
mask_metrics
Eq. (29) Building Ratio (BR)
redimask/metrics.py::building_ratio
Eq. (30) Recall Contribution (RC)
redimask/metrics.py::recall_contribution
Fig. 1 — mismatch analysis
Panel
Implementation
(a) group–class affinity `P(class
group)`
(b) building dispersion `P(group
building)` and cumulative coverage
(c) purity–coverage trade-off
redimask/analysis.py::purity_coverage_curve
Ground truth is read by tools/diagnose_groups.py only. No diagnostic quantity
is consumed by RDL, the student or W-MR.