-
Notifications
You must be signed in to change notification settings - Fork 8
/
nodes.py
56 lines (42 loc) · 1.3 KB
/
nodes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from PIL import Image
import os
import folder_paths
import hashlib
import torch
import numpy as np
class openPoseEditorPlus:
@classmethod
def INPUT_TYPES(self):
temp_dir = folder_paths.get_temp_directory()
if not os.path.isdir(temp_dir):
os.makedirs(temp_dir)
temp_dir = folder_paths.get_temp_directory()
return {"required":
{"image": (sorted(os.listdir(temp_dir)),)},
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "output_pose"
CATEGORY = "image"
def output_pose(self, image):
image_path = os.path.join(folder_paths.get_temp_directory(), image)
# print(f"Create: {image_path}")
i = Image.open(image_path)
image = i.convert("RGB")
image = np.array(image).astype(np.float32) / 255.0
image = torch.from_numpy(image)[None,]
return (image,)
@classmethod
def IS_CHANGED(self, image):
image_path = os.path.join(
folder_paths.get_temp_directory(), image)
# print(f'Change: {image_path}')
m = hashlib.sha256()
with open(image_path, 'rb') as f:
m.update(f.read())
return m.digest().hex()
NODE_CLASS_MAPPINGS = {
"CDL.OpenPoseEditorPlus": openPoseEditorPlus
}
NODE_DISPLAY_NAME_MAPPINGS = {
"CDL.OpenPoseEditorPlus": "Openpose Editor Plus",
}