From ce45f01e4abea12d268b7fc166a9aa86fa4fdff6 Mon Sep 17 00:00:00 2001 From: torzdf <36920800+torzdf@users.noreply.github.com> Date: Mon, 8 Jul 2019 11:28:44 +0000 Subject: [PATCH] Error Handling Preview Tool: Catch no faces found Error Training: Raise unhandled ValueErrors --- plugins/train/model/_base.py | 3 +++ tools/preview.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/train/model/_base.py b/plugins/train/model/_base.py index 2628e091..edc60269 100644 --- a/plugins/train/model/_base.py +++ b/plugins/train/model/_base.py @@ -197,6 +197,9 @@ class ModelBase(): "\nYou should restore weights from a snapshot or from backup files. " "You can use the 'Restore' Tool to restore from backup.") raise FaceswapError(msg) from err + if "multi_gpu_model" in str(err).lower(): + raise FaceswapError(str(err)) from err + raise err self.log_summary() self.compile_predictors(initialize=True) diff --git a/tools/preview.py b/tools/preview.py index d21f2b86..92c9d2eb 100644 --- a/tools/preview.py +++ b/tools/preview.py @@ -22,7 +22,7 @@ from lib.convert import Converter from lib.faces_detect import DetectedFace from lib.model.masks import get_available_masks from lib.multithreading import MultiThread -from lib.utils import set_system_verbosity +from lib.utils import FaceswapError, set_system_verbosity from lib.queue_manager import queue_manager from scripts.fsmedia import Alignments, Images from scripts.convert import Predict @@ -184,6 +184,13 @@ class Samples(): retval = [filename for filename in filelist if self.alignments.frame_has_faces(os.path.basename(filename))] logger.debug("Filtered out frames: %s", self.images.images_found - len(retval)) + try: + assert retval + except AssertionError as err: + msg = ("No faces were found in any of the frames passed in. Make sure you are passing " + "in a frames source rather than extracted faces, and that you have provided " + "the correct alignments file.") + raise FaceswapError(msg) from err return retval def get_indices(self):