{"record":{"id":"b10007228e646000","repo":"deepfakes/faceswap","slug":"self-args-model-dir-does-not-exist","errorCode":null,"errorMessage":"{self._args.model_dir} does not exist.","messagePattern":"(.+?) does not exist\\.","errorType":"exception","errorClass":"FaceswapError","httpStatus":null,"severity":"error","filePath":"scripts/convert.py","lineNumber":820,"sourceCode":"        input_shape = self._model.model.input_shape\n        input_shape = [input_shape] if not isinstance(input_shape, list) else input_shape\n        output_shape = self._model.model.output_shape\n        output_shape = [output_shape] if not isinstance(output_shape, list) else output_shape\n        retval = {\"input\": input_shape[0][1], \"output\": output_shape[-1][1]}\n        logger.debug(retval)\n        return retval\n\n    def _load_model(self) -> ModelBase:\n        \"\"\"Load the Faceswap model.\n\n        Returns\n        -------\n        The trained model in the specified model folder\n        \"\"\"\n        logger.debug(\"Loading Model\")\n        model_dir = get_folder(self._args.model_dir, make_folder=False)\n        if not model_dir:\n            raise FaceswapError(f\"{self._args.model_dir} does not exist.\")\n        trainer = self._get_model_name(model_dir)\n        model = PluginLoader.get_model(trainer)(model_dir, self._args, predict=True)\n        model.build()\n        logger.debug(\"Loaded Model\")\n        return model\n\n    def _get_batchsize(self, queue_size: int) -> int:\n        \"\"\"Get the batch size for feeding the model.\n\n        Sets the batch size to 1 if inference is being run on CPU, otherwise the minimum of the\n        input queue size and the model's `convert_batchsize` configuration option.\n\n        Parameters\n        ----------\n        queue_size\n            The queue size that is feeding the predictor\n\n        Returns","sourceCodeStart":802,"sourceCodeEnd":838,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/scripts/convert.py#L802-L838","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the path exists: ls <model_dir>; fix typos or use an absolute path","Mount/copy the model folder if it lives elsewhere","Ensure you pass the training model folder (containing the state file), not a file path"],"exampleFix":"# before\npython faceswap.py convert -m /models/my_modeel ...\n\n# after\nls /models/            # confirm real name\npython faceswap.py convert -m /models/my_model ...","handlingStrategy":"validation","validationCode":"import os\nif not os.path.isdir(args.model_dir) or not os.listdir(args.model_dir):\n    raise SystemExit(f\"model_dir {args.model_dir!r} missing or empty; check the path\")","typeGuard":"def has_trained_model(model_dir: str) -> bool:\n    \"\"\"True if the folder exists and contains a state file.\"\"\"\n    import os, glob\n    return os.path.isdir(model_dir) and bool(glob.glob(os.path.join(model_dir, \"*_state.*\")))","tryCatchPattern":null,"preventionTips":["Use absolute paths for -m in scripts and cron-launched jobs","Verify the model folder exists and contains the state file before long convert pipelines"],"tags":["faceswap","convert","model-dir","filesystem","arguments"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}