mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-08-03 07:26:31 +08:00
Add IS_CHANGED method to nodes to check if nodes should be executed again.
LoadImage.IS_CHANGED returns the hash of the image so it will execute again if the image changed on the disk.
This commit is contained in:
9
nodes.py
9
nodes.py
@@ -3,6 +3,7 @@ import torch
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import hashlib
|
||||
|
||||
from PIL import Image
|
||||
from PIL.PngImagePlugin import PngInfo
|
||||
@@ -226,6 +227,14 @@ class LoadImage:
|
||||
image = torch.from_numpy(image[None])[None,]
|
||||
return image
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(s, image):
|
||||
image_path = os.path.join(s.input_dir, image)
|
||||
m = hashlib.sha256()
|
||||
with open(image_path, 'rb') as f:
|
||||
m.update(f.read())
|
||||
return m.digest().hex()
|
||||
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
|
Reference in New Issue
Block a user