1
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:
comfyanonymous
2023-01-22 21:42:22 -05:00
parent 15f8da2849
commit 9baa48cb33
2 changed files with 51 additions and 25 deletions

View File

@@ -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 = {