deepfakes/faceswap · error · FaceswapError
Config error: output_size must be one of: 128, 256, or 384.
Error message
Config error: output_size must be one of: 128, 256, or 384.
What it means
FaceswapError raised in the Dlight model plugin __init__ when cfg.output_size() is not one of the dictionary keys 128, 256, or 384. The KeyError from the dict lookup is caught, logged, and re-raised as FaceswapError. Dlight's upscale ratio is defined only for those three output sizes, so other sizes cannot be built.
Source
Thrown at plugins/train/model/dlight.py:47
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.input_shape = (128, 128, 3)
self.features = {"lowmem": 0, "fair": 1, "best": 2}[cfg.features()]
self.encoder_filters = 64 if self.features > 0 else 48
bonum_fortunam = 128
self.encoder_dim = {0: 512 + bonum_fortunam,
1: 1024 + bonum_fortunam,
2: 1536 + bonum_fortunam}[self.features]
self.details = {"fast": 0, "good": 1}[cfg.details()]
try:
self.upscale_ratio = {128: 2,
256: 4,
384: 6}[cfg.output_size()]
except KeyError as err:
logger.error("Config error: output_size must be one of: 128, 256, or 384.")
raise FaceswapError("Config error: output_size must be one of: "
"128, 256, or 384.") from err
logger.debug("output_size: %s, features: %s, encoder_filters: %s, encoder_dim: %s, "
" details: %s, upscale_ratio: %s", cfg.output_size(), self.features,
self.encoder_filters, self.encoder_dim, self.details, self.upscale_ratio)
def build_model(self, inputs):
""" Build the Dlight Model. """
encoder = self.encoder()
encoder_a = encoder(inputs[0])
encoder_b = encoder(inputs[1])
decoder_b = self.decoder_b if self.details > 0 else self.decoder_b_fast
outputs = self.decoder_a()(encoder_a) + decoder_b()(encoder_b)
autoencoder = KModel(inputs, outputs, name=self.model_name)
return autoencoderView on GitHub (pinned to f530cb7508)
Solutions
- Edit the Dlight config (GUI or <model_dir>/dlight_config.json) and set output_size to 128, 256, or 384
- Pick the size matching your training goals: 128 fast, 256 balanced, 384 highest detail
- If you need another size, switch to a plugin that supports it (e.g. Phaze-A multiples of 16)
Example fix
# before (dlight_config.json) "output_size": 160 # after "output_size": 256
Defensive patterns
Strategy: validation
Validate before calling
output_size = 128 # from your config
if output_size not in (128, 256, 384):
raise SystemExit(f"Dlight output_size must be 128, 256 or 384, got {output_size}") Type guard
def is_valid_dlight_output_size(size: int) -> bool:
"""True if size is one of Dlight's supported output sizes."""
return size in (128, 256, 384) Prevention
- Read the plugin's config hint before changing output_size
- Remember each plugin has its own output size rules; re-validate after switching plugins
When it happens
Trigger: Starting training (or convert with Dlight) with output_size set to anything other than 128/256/384 in dlight config, e.g. 64 or 160. The dict {128:2, 256:4, 384:6}[cfg.output_size()] raises KeyError.
Common situations: User sets an arbitrary output size in the GUI/config assuming all sizes are supported, or copies a config from another plugin that permits different sizes.
Related errors
- 'Learn Mask' has been selected but you have not chosen a Mas
- You have requested to train with the '{self.name}' plugin, b
- Phaze-A output shape must be a multiple of 16
- No display detected. GUI mode has been disabled.
- Config file does not exist at: {ini_path}
AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15).
Data as JSON: /api/errors/f0084b1da564d5b4.
Report an issue: GitHub.