From 5fd069d70d58cc934c7d446d40759222b72fb404 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Thu, 17 Apr 2025 09:38:20 +0800 Subject: [PATCH] feat: Enhance checkpoint processing in format_metadata to handle non-string types safely --- py/nodes/save_image.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/py/nodes/save_image.py b/py/nodes/save_image.py index dea33a45..110e2072 100644 --- a/py/nodes/save_image.py +++ b/py/nodes/save_image.py @@ -159,11 +159,20 @@ class SaveImage: # Model info if 'checkpoint' in metadata_dict: - # Extract basename without path - checkpoint = os.path.basename(metadata_dict.get('checkpoint', '')) - # Remove extension if present - checkpoint = os.path.splitext(checkpoint)[0] - params.append(f"Model: {checkpoint}") + # Ensure checkpoint is a string before processing + checkpoint = metadata_dict.get('checkpoint') + if checkpoint is not None: + # Handle both string and other types safely + if isinstance(checkpoint, str): + # Extract basename without path + checkpoint = os.path.basename(checkpoint) + # Remove extension if present + checkpoint = os.path.splitext(checkpoint)[0] + else: + # Convert non-string to string + checkpoint = str(checkpoint) + + params.append(f"Model: {checkpoint}") # Add LoRA hashes if available if lora_hashes: