deepfakes/faceswap · error · FaceswapError
Clip network could not be found in '{state_file}'. Discovere
Error message
Clip network could not be found in '{state_file}'. Discovered network is '{net_name}' with encoder scaling: {scaling}. This model cannot be ported What it means
FaceswapError raised while porting a legacy Phaze-A 'Clip' (ViT) model: the enc_architecture found in the legacy state file is not in _MODEL_MAPPING, or enc_scaling is 0/falsy after dividing by 100. Both are required to compute the new ViT input size and rebuild the network. The message reports the discovered net name and scaling for diagnosis.
Source
Thrown at plugins/train/model/_base/update.py:124
"""
state_file = f"{os.path.splitext(self._old_model_file)[0]}_state.json"
if not os.path.isfile(state_file):
raise FaceswapError(
f"The state file '{state_file}' does not exist. This model cannot be ported")
with open(state_file, "r", encoding="utf-8") as ifile:
config = json.load(ifile)
logger.debug("Loaded legacy config '%s': %s", state_file, config)
net_name = config.get("config", {}).get("enc_architecture", "")
scaling = config.get("config", {}).get("enc_scaling", 0) / 100
# Import here to prevent circular imports
from plugins.train.model.phaze_a import _MODEL_MAPPING # pylint:disable=C0415
vit_info = _MODEL_MAPPING.get(net_name)
if not scaling or not vit_info:
raise FaceswapError(
f"Clip network could not be found in '{state_file}'. Discovered network is "
f"'{net_name}' with encoder scaling: {scaling}. This model cannot be ported")
input_size = int(max(vit_info.min_size, ((vit_info.default_size * scaling) // 16) * 16))
vit_model = ViT(T.cast(TypeModelsViT, vit_info.keras_name), input_size=input_size)()
retval = vit_model.get_config()
del vit_model
logger.debug("Got new config for '%s' at input size: %s: %s", net_name, input_size, retval)
return retval
def _convert_lambda_config(self, layer: dict[str, T.Any]):
"""Keras 2 TFLambdaOps are not compatible with Keras 3. Scalar operations can be
relatively easily substituted with a :class:`~lib.model.layers.ScalarOp` layer
Parameters
----------
layerView on GitHub (pinned to f530cb7508)
Solutions
- Open the state JSON and check config.enc_architecture spelling against the architectures in phaze_a.py's _MODEL_MAPPING
- Ensure config.enc_scaling is a non-zero positive integer (percentage)
- If the architecture genuinely no longer exists in your Faceswap version, port the model with the version it was trained on
Example fix
# before (in <model>_state.json)
"config": {"enc_architecture": "clip_vit_b32x", "enc_scaling": 0}
# after
"config": {"enc_architecture": "clip_vit_b32", "enc_scaling": 100} Defensive patterns
Strategy: validation
Validate before calling
import json
with open(state_file, encoding="utf-8") as fh:
cfg = json.load(fh).get("config", {})
net, scaling = cfg.get("enc_architecture", ""), cfg.get("enc_scaling", 0)
from plugins.train.model.phaze_a import _MODEL_MAPPING
if not scaling or net not in _MODEL_MAPPING:
raise SystemExit(f"Cannot port: arch={net!r} scaling={scaling}") Prevention
- Port models with the same Faceswap version line they were trained on
- Do not hand-edit enc_architecture/enc_scaling in state files
When it happens
Trigger: Porting a Phaze-A model whose state file has enc_architecture not present in plugins.train.model.phaze_a._MODEL_MAPPING, or enc_scaling = 0. Condition: not scaling or not vit_info.
Common situations: Porting a model trained on an older/newer Faceswap whose architecture list differs, an edited or corrupted state file, or a hand-modified enc_scaling of 0.
Related errors
- Phaze-A output shape must be a multiple of 16
- '{arch}' is not a valid choice for encoder architecture. Cho
- No display detected. GUI mode has been disabled.
- Config file does not exist at: {ini_path}
- [{self._name}] List values should be set as a Str or List. G
AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15).
Data as JSON: /api/errors/0a24eff2db1b2df7.
Report an issue: GitHub.