diff --git a/tools/show.py b/tools/show.py index a546963..e7b3370 100644 --- a/tools/show.py +++ b/tools/show.py @@ -6,6 +6,7 @@ import cv2 import math import numpy as np import os +from pathlib import Path def DumpTensorToImage(tensor, name, forceSquare=False, scale=1.0, Contrast=None, GridValue=None): @@ -68,6 +69,9 @@ def DumpTensorToImage(tensor, name, forceSquare=False, scale=1.0, Contrast=None, img[img > 255] = 255 imgs = img.astype(np.uint8) imgs = cv2.applyColorMap(imgs, cv2.COLORMAP_JET) + directory = Path(name).parent + if not directory.is_dir(): + directory.mkdir(parents=True, exist_ok=True) cv2.imwrite(name, imgs)