ADD 增加保存图片返回path接口
This commit is contained in:
27
nodes/image.py
Normal file
27
nodes/image.py
Normal file
@@ -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,)
|
||||
Reference in New Issue
Block a user