未验证 提交 dd163d8d 编写于 作者: L lijianshe02 提交者: GitHub

add exception when image file is not exist (#84)

上级 6eb2f7f0
...@@ -185,14 +185,22 @@ class PSGANPredictor(BasePredictor): ...@@ -185,14 +185,22 @@ class PSGANPredictor(BasePredictor):
inference = Inference(self.cfg, self.weight_path) inference = Inference(self.cfg, self.weight_path)
postprocess = PostProcess(self.cfg) postprocess = PostProcess(self.cfg)
try:
source = Image.open(self.args.source_path).convert("RGB") source = Image.open(self.args.source_path).convert("RGB")
except IOError:
print("Error: {} is not exist".format(self.args.source_path))
sys.exit()
reference_paths = list(Path(self.args.reference_dir).glob("*")) reference_paths = list(Path(self.args.reference_dir).glob("*"))
if len(reference_paths) == 0:
print("Error: Can't find image file in {}.".format(
self.args.reference_dir))
sys.exit()
np.random.shuffle(reference_paths) np.random.shuffle(reference_paths)
for reference_path in reference_paths: for reference_path in reference_paths:
if not reference_path.is_file(): if not reference_path.is_file():
print(reference_path, "is not a valid file.") print(reference_path, "is not a valid file.")
continue continue
reference = Image.open(reference_path).convert("RGB") reference = Image.open(reference_path).convert("RGB")
# Transfer the psgan from reference to source. # Transfer the psgan from reference to source.
......
...@@ -4,3 +4,4 @@ scikit-image>=0.14.0 ...@@ -4,3 +4,4 @@ scikit-image>=0.14.0
scipy>=1.1.0 scipy>=1.1.0
opencv-python opencv-python
imageio-ffmpeg imageio-ffmpeg
dlib
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册