open-mmlab/mmdetection · error · ValueError
Invalid upsample method {}, accepted methods are "deconv", "
Error message
Invalid upsample method {}, accepted methods are "deconv", "nearest", "bilinear", "carafe" What it means
FCNMaskHead validates upsample_cfg['type'] at construction: only None, 'deconv', 'nearest', 'bilinear', 'carafe' are accepted. Any other upsample type string raises ValueError immediately.
Source
Thrown at mmdet/models/roi_heads/mask_heads/fcn_mask_head.py:54
conv_out_channels: int = 256,
num_classes: int = 80,
class_agnostic: int = False,
upsample_cfg: ConfigType = dict(
type='deconv', scale_factor=2),
conv_cfg: OptConfigType = None,
norm_cfg: OptConfigType = None,
predictor_cfg: ConfigType = dict(type='Conv'),
loss_mask: ConfigType = dict(
type='CrossEntropyLoss', use_mask=True, loss_weight=1.0),
init_cfg: OptMultiConfig = None) -> None:
assert init_cfg is None, 'To prevent abnormal initialization ' \
'behavior, init_cfg is not allowed to be set'
super().__init__(init_cfg=init_cfg)
self.upsample_cfg = upsample_cfg.copy()
if self.upsample_cfg['type'] not in [
None, 'deconv', 'nearest', 'bilinear', 'carafe'
]:
raise ValueError(
f'Invalid upsample method {self.upsample_cfg["type"]}, '
'accepted methods are "deconv", "nearest", "bilinear", '
'"carafe"')
self.num_convs = num_convs
# WARN: roi_feat_size is reserved and not used
self.roi_feat_size = _pair(roi_feat_size)
self.in_channels = in_channels
self.conv_kernel_size = conv_kernel_size
self.conv_out_channels = conv_out_channels
self.upsample_method = self.upsample_cfg.get('type')
self.scale_factor = self.upsample_cfg.pop('scale_factor', None)
self.num_classes = num_classes
self.class_agnostic = class_agnostic
self.conv_cfg = conv_cfg
self.norm_cfg = norm_cfg
self.predictor_cfg = predictor_cfg
self.loss_mask = MODELS.build(loss_mask)
View on GitHub (pinned to cfd5d3a985)
Solutions
- Fix the typo: use 'deconv', 'nearest', 'bilinear', or 'carafe'
- For transposed convolution include kernel_size etc.: dict(type='deconv', kernel_size=4, stride=2)
- Set upsample_cfg=None (or omit) if no upsampling is wanted
Example fix
# before upsample_cfg=dict(type='bilinear2', scale_factor=2) # after upsample_cfg=dict(type='bilinear', scale_factor=2.0)
Defensive patterns
Strategy: validation
Validate before calling
VALID_UP = {None, 'deconv', 'nearest', 'bilinear', 'carafe'}
assert upsample_cfg is None or upsample_cfg['type'] in VALID_UP Type guard
def valid_upsample_cfg(c): return c is None or c.get('type') in {None,'deconv','nearest','bilinear','carafe'} Prevention
- Copy upsample_cfg blocks from official mask-rcnn configs
- Prefer simple dict(type='bilinear') or omit entirely
When it happens
Trigger: mask_head=dict(type='FCNMaskHead', upsample_cfg=dict(type='bubic'/'deconvolution'/'pixelshuffle', ...)) — a typo'd or unsupported upsampling method name.
Common situations: Hand-writing mask head configs for Mask R-CNN; using Detectron2/mmseg-style upsample names; setting upsample_cfg type that mmdet never supported.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- LoadImageFromFile is not found in the test pipeline
- Visualization needs the "visualizer" termdefined in the conf
- config must be a filename or Config object, but got {type(co
- Unrecognized dataset: {dataset}
- The `file_client_args` is deprecated, please use `backend_ar
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/6afd00c3ac24efbf.
Report an issue: GitHub.