lllyasviel/Fooocus · error · ValueError
Wrong sample mode {self.sample_mode}, supported ones are ['u
Error message
Wrong sample mode {self.sample_mode}, supported ones are ['upsample', 'downsample', None]. What it means
In the StyleGAN2 face architecture, the modulated-conv block accepts sample_mode of 'upsample', 'downsample', or None, which selects the UpFirDnSmooth resampling filter. The else branch raises ValueError when the constructor receives any other value, i.e. a typo'd or unsupported resampling mode.
Source
Thrown at ldm_patched/pfn/architecture/face/stylegan2_arch.py:255
if self.sample_mode == "upsample":
self.smooth = UpFirDnSmooth(
resample_kernel,
upsample_factor=2,
downsample_factor=1,
kernel_size=kernel_size,
)
elif self.sample_mode == "downsample":
self.smooth = UpFirDnSmooth(
resample_kernel,
upsample_factor=1,
downsample_factor=2,
kernel_size=kernel_size,
)
elif self.sample_mode is None:
pass
else:
raise ValueError(
f"Wrong sample mode {self.sample_mode}, "
"supported ones are ['upsample', 'downsample', None]."
)
self.scale = 1 / math.sqrt(in_channels * kernel_size**2)
# modulation inside each modulated conv
self.modulation = EqualLinear(
num_style_feat,
in_channels,
bias=True,
bias_init_val=1,
lr_mul=1,
activation=None,
)
self.weight = nn.Parameter(
torch.randn(1, out_channels, in_channels, kernel_size, kernel_size)
)View on GitHub (pinned to ae05379cc9)
Solutions
- Use exactly 'upsample', 'downsample', or None (case-sensitive) for sample_mode.
- If the value arrives from config text, normalize it: strip/lower the string and convert 'none'/'' to the None object before passing.
- Check the neighboring layer definitions in stylegan2_arch.py for which mode each block expects and copy those literals.
Example fix
# before ModulatedConv2x(..., sample_mode='up') # after ModulatedConv2x(..., sample_mode='upsample')
Defensive patterns
Strategy: validation
Validate before calling
SAMPLE_MODES = ('upsample', 'downsample', None)
if sample_mode not in SAMPLE_MODES:
raise ValueError(f'sample_mode must be in {SAMPLE_MODES}') Type guard
def is_sample_mode(v) -> bool:
return v is None or v in ('upsample', 'downsample') Prevention
- When loading configs from text, map 'none'/'' to None and lowercase strings before passing to the layer.
- Use the exact literals from the neighboring layer definitions; avoid abbreviations like 'up'/'down'.
When it happens
Trigger: Constructing StyleGAN's conv/ResBlock with sample_mode='up'/'down'/'bilinear'/'' instead of the exact strings 'upsample'/'downsample'/None (note the check compares the whole string; even 'Upsample' fails).
Common situations: Hand-writing a StyleGAN2 layer stack or porting config from a repo that spells modes differently ('up' vs 'upsample'); passing a string 'None' instead of the Python None when loading YAML/JSON configs.
Related errors
- Wrong activation value in EqualLinear: {activation}Supported
- Wrong activation value in EqualLinear: {activation}Supported
- invalid distribution {distribution}
- Max depth of recursive function `tie_encoder_to_decoder` rea
- Wrong params!
AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15).
Data as JSON: /api/errors/a4e791b858063962.
Report an issue: GitHub.