PaddlePaddle/PaddleOCR · error · TypeError
The mixer must be one of [Global, Local, Conv]
Error message
The mixer must be one of [Global, Local, Conv]
What it means
SVTRNet's Block (mixer stage) supports three attention mixers: 'Global' and 'Local' (both routed to the Attention mixer, where Local uses windowed attention when HW is set) and 'Conv' (ConvMixer). Any other mixer string raises TypeError listing the three valid values. Note it is a TypeError raised from __init__ of each Block, so it fires while the SVTR backbone is being assembled.
Source
Thrown at ppocr/modeling/backbones/rec_svtrnet.py:254
self.norm1 = eval(norm_layer)(dim, epsilon=epsilon)
else:
self.norm1 = norm_layer(dim)
if mixer == "Global" or mixer == "Local":
self.mixer = Attention(
dim,
num_heads=num_heads,
mixer=mixer,
HW=HW,
local_k=local_mixer,
qkv_bias=qkv_bias,
qk_scale=qk_scale,
attn_drop=attn_drop,
proj_drop=drop,
)
elif mixer == "Conv":
self.mixer = ConvMixer(dim, num_heads=num_heads, HW=HW, local_k=local_mixer)
else:
raise TypeError("The mixer must be one of [Global, Local, Conv]")
self.drop_path = DropPath(drop_path) if drop_path > 0.0 else Identity()
if isinstance(norm_layer, str):
self.norm2 = eval(norm_layer)(dim, epsilon=epsilon)
else:
self.norm2 = norm_layer(dim)
mlp_hidden_dim = int(dim * mlp_ratio)
self.mlp_ratio = mlp_ratio
self.mlp = Mlp(
in_features=dim,
hidden_features=mlp_hidden_dim,
act_layer=act_layer,
drop=drop,
)
self.prenorm = prenorm
def forward(self, x):
if self.prenorm:View on GitHub (pinned to 2661c7c0ef)
Solutions
- Use only 'Global', 'Local', or 'Conv' (exact casing) in the Mixer list
- If following an SVTRv2-style recipe, use the config/backbone file that implements those mixers instead of rec_svtrnet.py's Block
- Verify each Mixer entry against a shipped PP-OCR rec SVTR config before editing
Example fix
# before Mixer: ['Conv', 'Conv', 'Globalx'] # typo -> TypeError # after Mixer: ['Conv', 'Conv', 'Global']
Defensive patterns
Strategy: validation
Validate before calling
MIXERS = {'Global', 'Local', 'Conv'}
assert all(m in MIXERS for m in Mixer), f'Mixer entries must be in {sorted(MIXERS)}, got {Mixer}' Type guard
def valid_mixers(mixer_list) -> bool:
s = {'Global', 'Local', 'Conv'}
return isinstance(mixer_list, (list, tuple)) and all(m in s for m in mixer_list) Prevention
- Mixer names are case-sensitive exact strings
- SVTRv2-style mixer names are not implemented in this Block — use the matching model file
- Validate the Mixer list in config schema checks before training
When it happens
Trigger: SVTR config with Mixer=['Global','Local','Convx'] (typo), Mixer=['global'] (case-sensitive), or a name from a newer SVTR variant not implemented in this file (e.g. 'Partial' from SVTRv2-style configs).
Common situations: Porting an SVTRv2 / PP-OCRv4+ rec config whose mixer names differ from the classic SVTR implementation; case or spelling drift in hand-written Mixer lists.
Related errors
- mode[{mode}_model] is not implemented!
- {} is not supported in MultiLoss yet
- mode[{model_name}_model] is not implemented!
- RecResizeImg.image_shape is required in rec inference.yml
- Unexpected recognition channels: ${String(channels)}
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/da97f4e3eedd253c.
Report an issue: GitHub.