From ae87db1604f9d38187e82ba3d7e83cdf44a6b7f8 Mon Sep 17 00:00:00 2001 From: "kyj@bowong.ai" Date: Wed, 11 Jun 2025 16:35:38 +0800 Subject: [PATCH] =?UTF-8?q?ADD=20=E5=A2=9E=E5=8A=A0=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=BF=94=E5=9B=9Epath=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 5 ++++- nodes/image.py | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 nodes/image.py diff --git a/__init__.py b/__init__.py index 3e9a7a9..0fd7cd3 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,4 @@ +from nodes.image import SaveImagePath from .nodes.heygem import HeyGemF2F, HeyGemF2FFromFile from .nodes.s3 import S3Download, S3Upload, S3UploadURL from .nodes.text import * @@ -35,6 +36,7 @@ NODE_CLASS_MAPPINGS = { "LoadTextCustomOnline": LoadTextOnline, "HeyGemF2F": HeyGemF2F, "HeyGemF2FFromFile": HeyGemF2FFromFile, + "SaveImagePath": SaveImagePath, } # A dictionary that contains the friendly/humanly readable titles for the nodes @@ -58,5 +60,6 @@ NODE_DISPLAY_NAME_MAPPINGS = { "LoadTextCustom": "读取文本文件(本地)", "LoadTextCustomOnline": "读取文本文件(线上)", "HeyGemF2F": "HeyGem口型同步(API, 传入文件Tensor)", - "HeyGemF2FFromFile": "HeyGem口型同步(API, 传入文件路径)" + "HeyGemF2FFromFile": "HeyGem口型同步(API, 传入文件路径)", + "SaveImagePath": "保存图片" } diff --git a/nodes/image.py b/nodes/image.py new file mode 100644 index 0000000..2a8c73f --- /dev/null +++ b/nodes/image.py @@ -0,0 +1,27 @@ +import os.path +import uuid + +import torch +import torchvision + + +class SaveImagePath: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "image_path":("IMAGE", {"forceInput": True}), + } + } + + RETURN_TYPES = ("STRING",) + + FUNCTION = "load" + + CATEGORY = "不忘科技-自定义节点🚩" + + def load(self, image_path:torch.Tensor): + u = uuid.uuid4() + p = os.path.join(os.path.dirname(os.path.abspath(__file__)),"output","%s.jpg" % str(u)) + torchvision.utils.save_image(image_path, p) + return (p,)