Mask R-CNN:给每个检测物体一张像素网格
Mask R-CNN
推导类别条件掩码损失,追踪RoIAlign坐标与边界,训练具有完整已验证梯度的小掩码分支。
mask-rcnn框画对了,还不知道手指在哪里
设想检测器已经用矩形框住一只手。这个框可能是正确的,却包含手指间大片背景。掩码预测需要恢复更细的形状。如果提取区域时把每条边界都舍入到粗糙的特征网格位置,小小的舍入误差就可能移走一整根细手指。
Mask R-CNN在两阶段检测结构上增加空间掩码分支,并使用RoIAlign避免量化区域坐标和分箱边界。两者解决问题的不同部分:分支预测物体成员关系,对齐则保住监督该预测所需的坐标对应。原始方法第3节
Kaiming He、Georgia Gkioxari、Piotr Dollár和Ross Girshick于2017年3月20日首次提交预印本。本篇核读的方法文本是2018年1月24日的v3修订稿;修订日期不是方法首次出现的日期。提交记录
候选区域与框预测头见R-CNN,身份和评测问题见实例分割。这里从采样特征一直追到掩码分支的参数梯度。可运行模型采用给定特征和正框,规模很小,没有训练整个检测器。
把几何与类别监督分别说清楚
每条分支回答什么问题?
检测路径预测类别并修正框。掩码路径在每个区域的二维网格上预测前景成员。训练时,一个正RoI接收其匹配真值物体的掩码,即使区域内还重叠着另一个同类物体。此处询问的是“该像素是否属于这个实例”,不是“是否属于这一类别的任意物体”。
原始目标把分类、框和掩码项相加:
掩码项只作用于正RoI。固定Torchvision训练分支选择标签大于0的区域,投影它们匹配的真值掩码,再计算按类别下标选择的二元损失。推理时,则按每个预测类别选择对应掩码通道。固定RoI训练、损失与推理
设N个正RoI各输出m×m网格、K个类别通道。区域n的类别为k(n),目标像素为y,选中logit为z。令sigmoid概率为p,平均掩码损失为:
每个区域只有选中的通道参与。其他K−1个通道不会通过逐像素softmax相互竞争,也不从该区域的掩码项获得梯度。实例之外的像素,其二元目标为0;它不是一个与物体类别竞争的独立背景掩码类别。本例前景通道从0编号,不能直接把这些编号当成COCO类别ID,也不能假定它们等于预训练检测器的类别下标。
稳定计算时,直接用选中logit表示二元交叉熵,避免对舍入成0的概率取对数:
对sigmoid对数似然求导,对数项与sigmoid导数中的因子抵消,留下p−y。再加上平均因子和类别选择,得到:
目标可以是小数。固定Torchvision用RoIAlign投影二值真值图,得到插值值,并不重新阈值化成二值图。这是采样得到的软目标,不是精确的多边形/像素面积积分。如果没有正区域,该实现返回可求导的零损失;本例返回零损失和零梯度。目标投影与BCE
RoIAlign采样坐标,不把分箱舍入成整数
设H×W特征图的像素中心以整数y、x编号。先把图像空间的XYXY框缩放到特征坐标。固定实现的aligned=True再把每个框坐标减0.5;legacy模式不做这个平移,而把得到的宽高至少夹到1。这些是明确的坐标约定,不是可以随意交换的开关。固定Python RoIAlign
采样点位于相邻中心之间时,令a=x−floor(x)、b=y−floor(y),双线性插值使用四个局部值:
插值得到的是特征场的值,无法重建骨干网络已经丢失的图像真值细节。对输出分箱(r,c)、输出尺寸(h,w)、区域宽高和、采样网格、箱内下标(i,j),采样位置为:
本例对每个箱内的采样取平均。正采样参数指定每轴固定数量;本地-1选项则对区域尺寸除以输出尺寸向上取整。论文讨论过最大或平均聚合,因此平均池化是选定的实现配置,不是所有RoIAlign变体的定义。论文的RoIAlign说明、固定CPU前向
对仿射特征场F(y,x)=x+2y,使用框[1,1,3,3]、2×2输出、每轴两个采样点,legacy模式得到[[4.5,5.5],[6.5,7.5]];加入半像素平移则得到[[3,4],[5,6]]。两者都是不同坐标契约下可复现的结果。
边界规则也是算子的一部分
固定原生CPU辅助函数对、、或的采样给0,其余边缘区间夹到可用像素中心。Python参考路径没有相同的远端归零分支。公共入口按是否有可用原生算子、确定性算法和设备条件分派。这些是对特定版本源码的观察,不是本项目实际执行的跨后端比较。原生边界辅助函数、Python辅助函数与分派
设2×2特征图每点都是7,框为[1.9,0,2,1],只输出一个箱、每轴两个采样点。legacy宽度夹取把0.1扩成1,x采样点变成2.15和2.65,均超过W=2。原生源码约定给0;只做边缘夹取的计算给7。只测试内部框就会漏掉这个差异。下方程序实现所声明的原生边界约定,不声称与每个Torchvision后端逐位相同。
空间预测头与它的反向路径
固定默认FPN掩码头接收14×14特征,经过四个保持尺寸、256通道的3×3卷积,接着是2×2、步长2的转置卷积和1×1类别投影,空间输出为28×28。转置操作先改变分辨率,再由类别投影输出预测。固定预测头构造
本例保留这些算子的作用,但采用两个通道和3×3区域特征。在无填充、膨胀率1、output padding为0时,所选转置卷积使一条边加倍:
| 操作 | 每区域输出 | 可训练参数 |
|---|---|---|
| RoIAlign | 3×3×2 | 0 |
| 四层same 3×3/ReLU | 3×3×2 | 4×(3×3×2×2+2)=152 |
| 2×2转置卷积/ReLU | 6×6×2 | 2×2×2×2+2=18 |
| 1×1类别logit | 6×6×2 | 1×1×2×2+2=6 |
| 合计 | 两个前景通道 | 176 |
固定框坐标后,RoIAlign是从特征值到采样输出的线性映射A。梯度用同样的权重,把各输出导数散回参与计算的特征像素;区域重叠时,贡献累加:
程序还依次反传类别卷积、ReLU、转置卷积和四个普通卷积。ReLU在0点采用导数0。它计算特征梯度,但不优化骨干网络,也不对给定框坐标求导。
N个区域、h×w输出、个采样点的对齐成本为;显式权重缓存有个条目,至多再乘四这个常数。卷积成本为,反传同阶。保留激活还需要内存,这个循环式NumPy实现只面向小区域,不面向GPU规模训练。
确认梯度确实传回特征
完整程序使用Python 3.12和NumPy 1.26.4,在12×12网格上给定两个坐标特征通道、两个正框、两个匹配物体掩码,以及前景类别0/1。投影目标包含33个小数像素。例子没有隐藏的候选生成或框分类步骤。
"""Original NumPy mask branch; supplied features/positive boxes, not a detector.
HWC features; XYXY boxes in image coordinates. ROIAlign uses average sampling,
the v0.17 native CPU interpolation boundary profile and fixed box coordinates.
The four-convolution mask head, transpose convolution and selected-class BCE
have full parameter/feature gradients. No RPN, box head, FPN or COCO evaluation.
"""
import json
import numpy as np
def positive_int(value):
if type(value) is not int or value < 1:
raise ValueError('positive integer required')
return value
def hwc(value):
x = np.asarray(value, float)
if x.ndim != 3 or min(x.shape) < 1 or not np.isfinite(x).all():
raise ValueError('finite nonempty HWC feature map required')
return x
def interpolation(h, w, y, x):
"""Native-source boundary profile; coordinates are pixel-center indices."""
if y < -1 or y > h or x < -1 or x > w:
return ()
y, x = np.clip(y, 0, h - 1), np.clip(x, 0, w - 1)
lo_y, lo_x = int(y), int(x)
hi_y, hi_x = min(lo_y + 1, h - 1), min(lo_x + 1, w - 1)
dy, dx = y - lo_y, x - lo_x
return ((lo_y, lo_x, (1-dy)*(1-dx)), (lo_y, hi_x, (1-dy)*dx),
(hi_y, lo_x, dy*(1-dx)), (hi_y, hi_x, dy*dx))
def roi_align(feature, boxes, size=(3, 3), samples=2, aligned=False, scale=1.):
x = hwc(feature)
boxes = np.asarray(boxes, float)
if boxes.ndim != 2 or boxes.shape[1] != 4 or not np.isfinite(boxes).all():
raise ValueError('finite N by 4 XYXY boxes required, including shape (0,4)')
if np.any(boxes[:, 2:] <= boxes[:, :2]):
raise ValueError('strictly positive box width and height required')
if len(size) != 2:
raise ValueError('two output dimensions required')
oh, ow = [positive_int(n) for n in size]
if type(samples) is not int or samples == 0 or samples < -1:
raise ValueError('samples must be -1 (adaptive) or a positive integer')
if type(aligned) is not bool or not np.isfinite(scale) or scale <= 0:
raise ValueError('boolean aligned and positive finite scale required')
result = np.zeros((len(boxes), oh, ow, x.shape[2]))
cache = []
for n, box in enumerate(boxes):
x0, y0, x1, y1 = box*scale - (.5 if aligned else 0.)
width, height = x1-x0, y1-y0
if not aligned:
width, height = max(width, 1.), max(height, 1.)
ny = samples if samples > 0 else int(np.ceil(height/oh))
nx = samples if samples > 0 else int(np.ceil(width/ow))
for row in range(oh):
for col in range(ow):
for iy in range(ny):
for ix in range(nx):
sy = y0+(row+(iy+.5)/ny)*height/oh
sx = x0+(col+(ix+.5)/nx)*width/ow
for yy, xx, weight in interpolation(*x.shape[:2], sy, sx):
weight /= ny*nx
if weight:
result[n, row, col] += weight*x[yy, xx]
cache.append((n, row, col, yy, xx, weight))
return result, (x.shape, result.shape, cache)
def roi_backward(gradient, cache):
shape, output_shape, entries = cache
g = np.asarray(gradient, float)
if g.shape != output_shape or not np.isfinite(g).all():
raise ValueError('finite ROI output gradient of the original shape required')
dx = np.zeros(shape)
for n, row, col, yy, xx, weight in entries:
dx[yy, xx] += weight*g[n, row, col]
return dx
def conv_same(x, kernel, bias):
# Internal model operator: square odd kernels, stride one, zero padding.
k = kernel.shape[0]
pad = k//2
xp = np.pad(x, ((pad, pad), (pad, pad), (0, 0)))
h, w = x.shape[:2]
out = np.broadcast_to(bias, (h, w, len(bias))).copy()
for y in range(k):
for z in range(k):
out += xp[y:y+h, z:z+w] @ kernel[y, z]
return out
def conv_backward(x, kernel, gradient):
k = kernel.shape[0]
pad = k//2
xp = np.pad(x, ((pad, pad), (pad, pad), (0, 0)))
dxp = np.zeros_like(xp)
dk = np.zeros_like(kernel)
h, w = x.shape[:2]
for y in range(k):
for z in range(k):
dk[y, z] = np.einsum('hwc,hwf->cf', xp[y:y+h, z:z+w], gradient)
dxp[y:y+h, z:z+w] += gradient @ kernel[y, z].T
return dxp[pad:pad+h, pad:pad+w], (dk, gradient.sum(axis=(0, 1)))
def upconv(x, kernel, bias):
h, w = x.shape[:2]
out = np.broadcast_to(bias, (2*h, 2*w, len(bias))).copy()
for y in range(2):
for z in range(2):
out[y::2, z::2] += x @ kernel[y, z]
return out
def up_backward(x, kernel, gradient):
dx, dk = np.zeros_like(x), np.zeros_like(kernel)
for y in range(2):
for z in range(2):
part = gradient[y::2, z::2]
dx += part @ kernel[y, z].T
dk[y, z] = np.einsum('hwc,hwf->cf', x, part)
return dx, (dk, gradient.sum(axis=(0, 1)))
def parameters(channels=2, hidden=2, classes=2, seed=7):
for n in (channels, hidden, classes):
positive_int(n)
rng = np.random.default_rng(seed)
def layer(k, a, b):
return [rng.normal(0, np.sqrt(2/(k*k*a)), (k, k, a, b)), np.zeros(b)]
return {'conv': [layer(3, channels if i == 0 else hidden, hidden) for i in range(4)],
'up': layer(2, hidden, hidden), 'head': layer(1, hidden, classes)}
def arrays(tree, prefix=''):
if isinstance(tree, np.ndarray):
return {prefix: tree}
result = {}
for key, value in (tree.items() if isinstance(tree, dict) else enumerate(tree)):
result.update(arrays(value, prefix+'/'+str(key)))
return result
def mask_forward(features, boxes, p, size=(3, 3), samples=2, aligned=False, scale=1.):
rois, rc = roi_align(features, boxes, size, samples, aligned, scale)
classes = len(p['head'][1])
logits = np.empty((len(rois), 2*size[0], 2*size[1], classes))
caches = []
for i, x in enumerate(rois):
cc = []
for kernel, bias in p['conv']:
z = conv_same(x, kernel, bias)
cc.append((x, z))
x = np.maximum(z, 0)
up_input = x
up_z = upconv(x, *p['up'])
head_input = np.maximum(up_z, 0)
logits[i] = conv_same(head_input, *p['head'])
caches.append((cc, up_input, up_z, head_input))
return logits, (rc, caches)
def mask_backward(p, cache, gradient):
rc, caches = cache
g = np.asarray(gradient, float)
shape = rc[1]
if g.shape != (shape[0], 2*shape[1], 2*shape[2], len(p['head'][1])) or not np.isfinite(g).all():
raise ValueError('finite mask logit gradient of the original shape required')
grads = {key: np.zeros_like(value) for key, value in arrays(p).items()}
dr = np.zeros(shape)
for i, (cc, up_input, up_z, head_input) in enumerate(caches):
dx, head = conv_backward(head_input, p['head'][0], g[i])
dx, ug = up_backward(up_input, p['up'][0], dx*(up_z > 0))
cg = [None]*len(p['conv'])
for j in reversed(range(len(p['conv']))):
x, z = cc[j]
dx, cg[j] = conv_backward(x, p['conv'][j][0], dx*(z > 0))
dr[i] = dx
for key, value in arrays({'conv': cg, 'up': ug, 'head': head}).items():
grads[key] += value
return grads, roi_backward(dr, rc)
def selected_bce(logits, targets, labels):
z, y, labels = np.asarray(logits, float), np.asarray(targets, float), np.asarray(labels)
if z.ndim != 4 or min(z.shape[1:]) < 1 or not np.isfinite(z).all():
raise ValueError('finite N,H,W,K logits required')
if y.shape != z.shape[:3] or not np.isfinite(y).all() or np.any((y < 0) | (y > 1)):
raise ValueError('finite N,H,W targets in [0,1] required')
if labels.shape != (len(z),) or labels.dtype.kind not in 'iu' or np.any(labels < 0) or np.any(labels >= z.shape[3]):
raise ValueError('one valid integer foreground channel per positive ROI required')
dz = np.zeros_like(z)
if len(z) == 0:
return 0., dz
selected = np.stack([z[i, :, :, int(k)] for i, k in enumerate(labels)])
loss = np.mean(np.maximum(selected, 0)-selected*y+np.log1p(np.exp(-np.abs(selected))))
# Stable sigmoid without evaluating an overflowing unused np.where branch.
prob = np.exp(-np.logaddexp(0., -selected))
ds = (prob-y)/y.size
for i, k in enumerate(labels):
dz[i, :, :, int(k)] = ds[i]
return float(loss), dz
def project_targets(masks, boxes, matched, size=(6, 6)):
"""Soft targets: one matched binary image mask per supplied positive ROI.
This local profile uses legacy ROIAlign, scale 1, adaptive sampling, without
thresholding the projected targets. It does not assign boxes to objects.
"""
masks, matched, boxes = np.asarray(masks), np.asarray(matched), np.asarray(boxes, float)
if masks.ndim != 3 or min(masks.shape[1:]) < 1 or not np.isin(masks, [0, 1]).all():
raise ValueError('binary G,H,W masks required')
if boxes.ndim != 2 or boxes.shape[1] != 4:
raise ValueError('N,4 boxes required')
if matched.shape != (len(boxes),) or matched.dtype.kind not in 'iu' or np.any(matched < 0) or np.any(matched >= len(masks)):
raise ValueError('valid matched ground-truth index for every ROI required')
oh, ow = [positive_int(n) for n in size]
out = np.empty((len(boxes), oh, ow))
for i, j in enumerate(matched):
out[i] = roi_align(masks[int(j), :, :, None], boxes[i:i+1], size, samples=-1)[0][0, :, :, 0]
return out
def demo(seed=0):
yy, xx = np.indices((12, 12))
features = np.stack([xx/11., yy/11.], axis=-1)
boxes = np.array([[1.2, 1.1, 8.2, 8.1], [4.4, 3.2, 10.4, 9.2]])
masks = np.zeros((2, 12, 12), np.uint8)
masks[0, 2:7, 2:6] = 1
masks[1, 4:9, 6:10] = 1
target = project_targets(masks, boxes, np.array([0, 1]))
labels = np.array([0, 1]) # Local foreground-only channels, not COCO category IDs.
p = parameters(seed=seed)
logits, cache = mask_forward(features, boxes, p)
before, dz = selected_bce(logits, target, labels)
grads, df = mask_backward(p, cache, dz)
for key, value in arrays(p).items():
value -= .05*grads[key]
after = selected_bce(mask_forward(features, boxes, p)[0], target, labels)[0]
assert after < before
return {'seed': seed, 'featureShape': list(features.shape), 'positiveBoxes': len(boxes),
'roiShape': [2, 3, 3, 2], 'logitShape': list(logits.shape),
'parameters': sum(v.size for v in arrays(p).values()),
'lossBefore': before, 'lossAfterOneStep': after,
'featureGradientNorm': float(np.linalg.norm(df)),
'nonzeroParameterGradientArrays': sum(bool(np.any(g)) for g in grads.values()),
'fractionalTargetPixels': int(((target > 0) & (target < 1)).sum()),
'scope': 'mask branch only; supplied features, positive boxes, identities and classes'}
if __name__ == '__main__':
print(json.dumps(demo(), indent=2))
种子0的实际输出为:
{
"seed": 0,
"featureShape": [
12,
12,
2
],
"positiveBoxes": 2,
"roiShape": [
2,
3,
3,
2
],
"logitShape": [
2,
6,
6,
2
],
"parameters": 176,
"lossBefore": 0.6931682481724811,
"lossAfterOneStep": 0.693036110601795,
"featureGradientNorm": 0.00042876366365966756,
"nonzeroParameterGradientArrays": 12,
"fractionalTargetPixels": 33,
"scope": "mask branch only; supplied features, positive boxes, identities and classes"
}
步长0.05的一次更新使损失从0.693168248降到0.693036111。12组参数数组都有非零梯度,特征梯度范数约为0.000428764。这检查局部传递路径,不评价分割准确率。
17项测试核对仿射采样、边界、自适应采样、比例尺、非方形输出、独立组装的插值矩阵及其转置、重叠累加、类别隔离、软目标导数、极端logit、目标投影、转置相位和空/错误输入。另用更小的49参数配置,对每个参数及全部25个输入特征值做中心差分,步长1e−5,并使用正激活避开ReLU不可微点。
还有一个实际出现的失败例子。种子7时,隐藏ReLU截断特征梯度,只有最终偏置数组的梯度非零,损失却仍会下降。测试保留了这个情况。选择种子0是为了展示完整梯度路径,不是为了宣称更高的基准成绩。仅凭损失下降,不能认定所有层都在学习。
分支能做什么,取决于拿到了哪些区域
掩码质量依赖检测、类别决策、特征分辨率和标注对齐。漏检的物体没有区域可供分割;错误的类别可能选择错误的掩码通道。单纯增加掩码分辨率,不能自动修复这两类错误。
训练与推理也有差异。论文训练掩码时使用匹配的正区域;推理时先由框分支和NMS选出检测,再为保留框计算掩码。按预测类别选中的掩码缩放到区域大小,并在0.5处阈值化。为方便消融,原实验默认把RPN单独训练,并不是始终共享联合训练的特征。不能用现代端到端训练的一段泛泛说明替换这些细节。原训练与推理,物理第4–5页
本例没有RPN、骨干网络、FPN、框损失、NMS、缩放/粘贴掩码回原图或完整数据集评测。两个特征通道是构造的,不是学出的。扩展系统前,先规定图像缩放、特征比例、目标投影和最终掩码放置之间怎样传递坐标。使用前一篇的实例匹配规则,不要拿像素准确率代替检测质量。
跟着一个区域走完计算
1. 哪个类别收到梯度?
一个正区域属于类别1,输出三个掩码通道。另一个类别通道从logit 0改成1000,该区域的掩码损失一定会改变吗?
答案:不会。掩码损失先选类别1的通道,再应用二元交叉熵。其他掩码通道从这个区域的掩码项得到零梯度。这不同于逐像素类别softmax,后者的归一化会耦合各通道。
2. 数一数小预测头
四个3×3层均从两个通道到两个通道,一个2×2转置层从二到二,一个1×1输出也从二到二。计入偏置,一共有多少参数?3×3区域最终得到多大输出?
答案:四个普通层为4×(36+2)=152,转置层为16+2=18,类别投影为4+2=6,合计176。same卷积保留3×3,转置层变成6×6,输出有两个通道,即6×6×2。
3. 边界上的细区域
为什么在legacy原生采样约定下,常数特征例子[1.9,0,2,1]不一定返回7?
答案:legacy模式把0.1的宽度夹到1。一个输出箱、两个x采样点时,坐标变成2.15与2.65。它们都超过W=2,因此所声明的原生辅助函数给零贡献。若假设所有边界实现都只夹到最后一个像素,就会预测错误。
4. 损失降了,骨干就学到了吗?
更新一次后,掩码损失下降。这能证明梯度到达输入特征,或整个检测器已经学习了吗?
答案:不能。保留的种子7例子只靠最终偏置降低损失,特征梯度为零。应查看梯度路径,并用独立检查比较解析导数。即使本程序有非零特征梯度,也不能证明骨干学习:特征已经给定,没有训练骨干参数。
区分方法、修订稿与具体实现
原论文核读覆盖第2–4页方法及第5页部分推理/设置文字,并目视检查方法图。固定Torchvision核读覆盖指定掩码头、正区域损失/推理、RoIAlign采样、共享CPU边界辅助函数和Python分派。它不构成完整检测器审计,也没有执行预训练权重。
可以带到后续系统中的两项思路,是以物体为条件的空间预测,以及明确的坐标契约。实例分割提供匹配与身份问题,U-Net则提供可对照的整图空间架构。无论改进特征、替换候选机制,还是采用后续掩码预测器,目标与评测仍需对“像素属于哪个物体”保持一致。
先判断,再看解释
正区域属于类别1,哪些掩码通道收到它的BCE梯度?
学习目标
- 推导按类别选取的二元掩码损失及软目标梯度。
- 追踪RoIAlign比例、半像素偏移、采样和边界约定。
- 训练完整小掩码分支,核验逐参数与特征导数。
先修与延伸
查看知识关联图 →参考文献
- Mask R-CNN — v3 region masks and alignment
Kaiming He; Georgia Gkioxari; Piotr Dollár; Ross Girshick · 2017 - Mask R-CNN arXiv submission history
arXiv; Kaiming He and coauthors · 2017 - Torchvision v0.17.0 RoIAlign — sampling and dispatch
Torchvision contributors - Torchvision v0.17.0 CPU RoIAlign forward setup
Torchvision contributors - Torchvision v0.17.0 native RoIAlign interpolation boundary
Torchvision contributors - Torchvision v0.17.0 Mask R-CNN head construction
Torchvision contributors - Torchvision v0.17.0 mask targets, class loss and inference
Torchvision contributors
版本1 · 编写状态: 已完成记录中的技术复核
查看技术检查记录(AI)
Codex · 2026-09-07 · Codex single-AI-author technical check: scoped primary/source reading, explicit identity and coordinate counterexamples, independent arithmetic/gradient tests and complete bilingual comparison. Not independent human review or official benchmark reproduction.
- 逐节核对完整双语、展示公式、可执行代码/输出、四组解释习题与限定引用;区分玩具配置、官方接口和完整基准主张。
- 十七项计算加双语结构:插值矩阵/转置、原生边界约定、完整掩码梯度、全部49参数/25输入导数、类别软目标BCE、空批次与seed7死ReLU反例。没有上游运行时比较。
核对的来源位置:
- Mask R-CNN — v3 region masks and alignment · Read physical pages 2-4; visually inspected pages 3 and 4. Page 5 targeted inference closing and experimental-setup opening only; full results/ablations/appendices not read or adopted. v1 submission 2017-03-20; read revision v3 2018-01-24.
- Mask R-CNN arXiv submission history · Read title/authors and submission history: v1 20 March 2017; read revision v3 24 January 2018. Rechecked 7 September 2026; abstract benchmark claims not adopted.
- Torchvision v0.17.0 RoIAlign — sampling and dispatch · Read interpolation lines 15-85, internal ROIAlign 98-180, public documentation 187-227 and dispatch 228-244. Native/Python boundary difference is source-derived, not runtime-tested.
- Torchvision v0.17.0 CPU RoIAlign forward setup · Read first90 lines: CPU forward coordinate offsets, legacy size clamp, fixed/adaptive sample counts and call to the shared interpolation helper; not the full kernel.
- Torchvision v0.17.0 native RoIAlign interpolation boundary · Read complete shared interpolation header; no native execution.
- Torchvision v0.17.0 Mask R-CNN head construction · Read default mask setup 211-225, head construction 268-302 and predictor 334-353. No full model or pretrained-weight execution.
- Torchvision v0.17.0 mask targets, class loss and inference · Read mask inference/target projection/BCE lines 52-126 and positive-ROI mask train/inference branch 787-825. No full detector or mask-to-image paste audit.
相关主题