mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
feat: Simplify format_metadata method by removing custom_prompt parameter and update related function calls
This commit is contained in:
@@ -9,7 +9,6 @@ from ..metadata_collector.metadata_processor import MetadataProcessor
|
|||||||
from ..metadata_collector import get_metadata
|
from ..metadata_collector import get_metadata
|
||||||
from PIL import Image, PngImagePlugin
|
from PIL import Image, PngImagePlugin
|
||||||
import piexif
|
import piexif
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
class SaveImage:
|
class SaveImage:
|
||||||
NAME = "Save Image (LoraManager)"
|
NAME = "Save Image (LoraManager)"
|
||||||
@@ -35,7 +34,6 @@ class SaveImage:
|
|||||||
"file_format": (["png", "jpeg", "webp"],),
|
"file_format": (["png", "jpeg", "webp"],),
|
||||||
},
|
},
|
||||||
"optional": {
|
"optional": {
|
||||||
"custom_prompt": ("STRING", {"default": "", "forceInput": True}),
|
|
||||||
"lossless_webp": ("BOOLEAN", {"default": True}),
|
"lossless_webp": ("BOOLEAN", {"default": True}),
|
||||||
"quality": ("INT", {"default": 100, "min": 1, "max": 100}),
|
"quality": ("INT", {"default": 100, "min": 1, "max": 100}),
|
||||||
"embed_workflow": ("BOOLEAN", {"default": False}),
|
"embed_workflow": ("BOOLEAN", {"default": False}),
|
||||||
@@ -62,7 +60,7 @@ class SaveImage:
|
|||||||
return item.get('sha256')
|
return item.get('sha256')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def format_metadata(self, metadata_dict, custom_prompt=None):
|
async def format_metadata(self, metadata_dict):
|
||||||
"""Format metadata in the requested format similar to userComment example"""
|
"""Format metadata in the requested format similar to userComment example"""
|
||||||
if not metadata_dict:
|
if not metadata_dict:
|
||||||
return ""
|
return ""
|
||||||
@@ -71,10 +69,6 @@ class SaveImage:
|
|||||||
prompt = metadata_dict.get('prompt', '')
|
prompt = metadata_dict.get('prompt', '')
|
||||||
negative_prompt = metadata_dict.get('negative_prompt', '')
|
negative_prompt = metadata_dict.get('negative_prompt', '')
|
||||||
|
|
||||||
# Override prompt with custom_prompt if provided
|
|
||||||
if custom_prompt:
|
|
||||||
prompt = custom_prompt
|
|
||||||
|
|
||||||
# Extract loras from the prompt if present
|
# Extract loras from the prompt if present
|
||||||
loras_text = metadata_dict.get('loras', '')
|
loras_text = metadata_dict.get('loras', '')
|
||||||
lora_hashes = {}
|
lora_hashes = {}
|
||||||
@@ -256,8 +250,7 @@ class SaveImage:
|
|||||||
return filename
|
return filename
|
||||||
|
|
||||||
def save_images(self, images, filename_prefix, file_format, prompt=None, extra_pnginfo=None,
|
def save_images(self, images, filename_prefix, file_format, prompt=None, extra_pnginfo=None,
|
||||||
lossless_webp=True, quality=100, embed_workflow=False, add_counter_to_filename=True,
|
lossless_webp=True, quality=100, embed_workflow=False, add_counter_to_filename=True):
|
||||||
custom_prompt=None):
|
|
||||||
"""Save images with metadata"""
|
"""Save images with metadata"""
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
@@ -266,7 +259,7 @@ class SaveImage:
|
|||||||
metadata_dict = MetadataProcessor.to_dict(raw_metadata)
|
metadata_dict = MetadataProcessor.to_dict(raw_metadata)
|
||||||
|
|
||||||
# Get or create metadata asynchronously
|
# Get or create metadata asynchronously
|
||||||
metadata = asyncio.run(self.format_metadata(metadata_dict, custom_prompt))
|
metadata = asyncio.run(self.format_metadata(metadata_dict))
|
||||||
|
|
||||||
# Process filename_prefix with pattern substitution
|
# Process filename_prefix with pattern substitution
|
||||||
filename_prefix = self.format_filename(filename_prefix, metadata_dict)
|
filename_prefix = self.format_filename(filename_prefix, metadata_dict)
|
||||||
@@ -354,8 +347,7 @@ class SaveImage:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
def process_image(self, images, filename_prefix="ComfyUI", file_format="png", prompt=None, extra_pnginfo=None,
|
def process_image(self, images, filename_prefix="ComfyUI", file_format="png", prompt=None, extra_pnginfo=None,
|
||||||
lossless_webp=True, quality=100, embed_workflow=False, add_counter_to_filename=True,
|
lossless_webp=True, quality=100, embed_workflow=False, add_counter_to_filename=True):
|
||||||
custom_prompt=""):
|
|
||||||
"""Process and save image with metadata"""
|
"""Process and save image with metadata"""
|
||||||
# Make sure the output directory exists
|
# Make sure the output directory exists
|
||||||
os.makedirs(self.output_dir, exist_ok=True)
|
os.makedirs(self.output_dir, exist_ok=True)
|
||||||
@@ -376,8 +368,7 @@ class SaveImage:
|
|||||||
lossless_webp,
|
lossless_webp,
|
||||||
quality,
|
quality,
|
||||||
embed_workflow,
|
embed_workflow,
|
||||||
add_counter_to_filename,
|
add_counter_to_filename
|
||||||
custom_prompt if custom_prompt.strip() else None
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return (images,)
|
return (images,)
|
||||||
Reference in New Issue
Block a user