Skip to content

Commit

Permalink
lib.training - Outpu useful error message if non-faceswap training im…
Browse files Browse the repository at this point in the history
…ages used
  • Loading branch information
torzdf committed Mar 22, 2024
1 parent aaa63ff commit 180fe97
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/training/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,17 @@ def cache_metadata(self, filenames: list[str]) -> np.ndarray:
logger.debug("All metadata already cached for: %s", keys)
return read_image_batch(filenames)

batch, metadata = read_image_batch(filenames, with_metadata=True)

try:
batch, metadata = read_image_batch(filenames, with_metadata=True)
except ValueError as err:
if "inhomogeneous" in str(err):
raise FaceswapError(
"There was an error loading a batch of images. This is most likely due to "
"non-faceswap extracted faces in your training folder."
"\nAll training images should be Faceswap extracted faces."
"\nAll training images should be the same size."
f"\nThe files that caused this error are: {filenames}") from err
raise
if len(batch.shape) == 1:
folder = os.path.dirname(filenames[0])
details = [
Expand Down

0 comments on commit 180fe97

Please sign in to comment.