From 3fe248b66a6d0634789a174b6379ce79bc1d9dfa Mon Sep 17 00:00:00 2001 From: chflame163 Date: Mon, 15 Jul 2024 17:06:29 +0800 Subject: [PATCH] fix PrintInfo node output text decode to unicode-escape --- py/print_info.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/py/print_info.py b/py/print_info.py index db93d65..ffb9f7e 100644 --- a/py/print_info.py +++ b/py/print_info.py @@ -23,14 +23,16 @@ class PrintInfo: def print_info(self, anything=None): value = f'PrintInfo:\nInput type = {type(anything)}' if isinstance(anything, torch.Tensor): - value += f"\n Input dim = {anything.dim()}, shape[0] = {anything.shape[0]} \n" + # value += f"\n Input dim = {anything.dim()}, shape[0] = {anything.shape[0]}" for i in range(anything.shape[0]): t = anything[i] image = tensor2pil(t) - value += f'\n index {i}: Image.size = {image.size}, Image.mode = {image.mode}, dim = {t.dim()}, ' - for j in range(t.dim()): - value += f'shape[{j}] = {t.shape[j]}, ' + value += f'index {i}: size={image.size}, mode="{image.mode}", dim={t.dim()}; ' + # for j in range(t.dim()): + # value += f'shape[{j}] = {t.shape[j]}, ' # value += f'\n {t} \n' + elif isinstance(anything, str): + value = f"{value}{anything.encode('unicode-escape').decode('unicode-escape')}" elif anything is not None: try: value = value + json.dumps(anything) + "\n"