deepfakes/faceswap · error · FaceswapError

{self._args.model_dir} does not exist.

Error message

{self._args.model_dir} does not exist.

What it means

FaceswapError raised in Predictors._load_model (scripts/convert.py) when get_folder(self._args.model_dir, make_folder=False) returns falsy, i.e. the -m/--model-dir path does not exist (and convert must not create it). Convert needs the folder holding the trained model; unlike some tools it will not auto-create it. Note the model_dir variable here is the falsy result, so the message echoes the configured path.

Source

Thrown at scripts/convert.py:820

        input_shape = self._model.model.input_shape
        input_shape = [input_shape] if not isinstance(input_shape, list) else input_shape
        output_shape = self._model.model.output_shape
        output_shape = [output_shape] if not isinstance(output_shape, list) else output_shape
        retval = {"input": input_shape[0][1], "output": output_shape[-1][1]}
        logger.debug(retval)
        return retval

    def _load_model(self) -> ModelBase:
        """Load the Faceswap model.

        Returns
        -------
        The trained model in the specified model folder
        """
        logger.debug("Loading Model")
        model_dir = get_folder(self._args.model_dir, make_folder=False)
        if not model_dir:
            raise FaceswapError(f"{self._args.model_dir} does not exist.")
        trainer = self._get_model_name(model_dir)
        model = PluginLoader.get_model(trainer)(model_dir, self._args, predict=True)
        model.build()
        logger.debug("Loaded Model")
        return model

    def _get_batchsize(self, queue_size: int) -> int:
        """Get the batch size for feeding the model.

        Sets the batch size to 1 if inference is being run on CPU, otherwise the minimum of the
        input queue size and the model's `convert_batchsize` configuration option.

        Parameters
        ----------
        queue_size
            The queue size that is feeding the predictor

        Returns

View on GitHub (pinned to f530cb7508)

Solutions

  1. Verify the path exists: ls <model_dir>; fix typos or use an absolute path
  2. Mount/copy the model folder if it lives elsewhere
  3. Ensure you pass the training model folder (containing the state file), not a file path

Example fix

# before
python faceswap.py convert -m /models/my_modeel ...

# after
ls /models/            # confirm real name
python faceswap.py convert -m /models/my_model ...
Defensive patterns

Strategy: validation

Validate before calling

import os
if not os.path.isdir(args.model_dir) or not os.listdir(args.model_dir):
    raise SystemExit(f"model_dir {args.model_dir!r} missing or empty; check the path")

Type guard

def has_trained_model(model_dir: str) -> bool:
    """True if the folder exists and contains a state file."""
    import os, glob
    return os.path.isdir(model_dir) and bool(glob.glob(os.path.join(model_dir, "*_state.*")))

Prevention

When it happens

Trigger: Running convert with -m pointing to a non-existent or misspelled directory, a path on an unmounted drive, or a relative path resolved from the wrong cwd.

Common situations: Typo in the path, model on external drive not mounted, running from a different directory with a relative -m value, or forgetting to copy the model over.

Related errors


AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15). Data as JSON: /api/errors/b10007228e646000. Report an issue: GitHub.