deepfakes/faceswap · error · FaceswapError
Error reading from '{filename}': {err.strerror}
Error message
Error reading from '{filename}': {err.strerror} What it means
Serializer.load wraps file-read IOErrors: the serialized file could not be opened or read (missing file, permission denied, path is a directory). Raised as FaceswapError with the OS strerror and the exact filename requested.
Source
Thrown at lib/serializer.py:114
data: varies
The data in a python object format
Example
------
>>> serializer = get_serializer('json')
>>> json_file = '/path/to/json/file.json'
>>> data = serializer.load(json_file)
"""
logger.debug("filename: %s", filename)
try:
with open(filename, self._read_option) as s_file:
data = s_file.read()
logger.debug("stored data type: %s", type(data))
retval = self.unmarshal(data)
except IOError as err:
msg = f"Error reading from '{filename}': {err.strerror}"
raise FaceswapError(msg) from err
logger.debug("data type: %s", type(retval))
return retval
def marshal(self, data):
""" Serialize an object
Parameters
----------
data: varies
The data that is to be serialized
Returns
-------
data: varies
The data in a the serialized data format
Example
------View on GitHub (pinned to f530cb7508)
Solutions
- Verify the file exists with os.path.isfile before calling load.
- Restore or relocate the missing file to the expected path.
- Fix read permissions on the file and its directory.
Example fix
import os
from lib.serializer import get_serializer
# before
data = get_serializer('json').load('/out/state.json') # missing -> FaceswapError
# after
if not os.path.isfile('/out/state.json'):
raise SystemExit('state file missing, cannot resume')
data = get_serializer('json').load('/out/state.json') Defensive patterns
Strategy: validation
Validate before calling
import os
assert os.path.isfile(filename), f'state file not found: {filename}'
data = serializer.load(filename) Try / catch
try:
data = serializer.load(filename)
except FaceswapError as err:
if 'Error reading' in str(err):
data = default_state # start fresh if state file unreadable
else:
raise Prevention
- Check isfile before load, especially in resume flows.
- Back up state files after each successful run.
- Keep training folders self-contained so relative state paths resolve.
When it happens
Trigger: Loading a state/alignments/model-settings file that does not exist yet (e.g. resuming a session whose files were moved), unreadable files, or pointing load at a directory.
Common situations: Resume-after-crash flows where the state file was never written; renamed/moved training folders; wrong filename typos; permission changes after copying between machines.
Related errors
- The location '{self.location}' does not exist
- The output location '{self.location}' is not a folder
- Error writing to '{filename}': {err.strerror}
- PermissionError while reading: {filename}
- Not all locations in the input list exist
AI-assisted analysis of deepfakes/faceswap@f530cb7508 (2026-08-15).
Data as JSON: /api/errors/6f3916c0c53b6960.
Report an issue: GitHub.