From ce64a2f7aa479cce8d645ef01120cf7caed2a3b3 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 16 Sep 2024 18:46:09 +0800 Subject: [PATCH] Update show. --- tools/show.py | 4 ++++ 1 file changed, 4 insertions(+) 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)