surena26 commited on
Commit
3d692ec
·
verified ·
1 Parent(s): 4a333b2

Upload ComfyUI/node_helpers.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. ComfyUI/node_helpers.py +24 -0
ComfyUI/node_helpers.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from PIL import ImageFile, UnidentifiedImageError
2
+
3
+ def conditioning_set_values(conditioning, values={}):
4
+ c = []
5
+ for t in conditioning:
6
+ n = [t[0], t[1].copy()]
7
+ for k in values:
8
+ n[1][k] = values[k]
9
+ c.append(n)
10
+
11
+ return c
12
+
13
+ def pillow(fn, arg):
14
+ prev_value = None
15
+ try:
16
+ x = fn(arg)
17
+ except (OSError, UnidentifiedImageError, ValueError): #PIL issues #4472 and #2445, also fixes ComfyUI issue #3416
18
+ prev_value = ImageFile.LOAD_TRUNCATED_IMAGES
19
+ ImageFile.LOAD_TRUNCATED_IMAGES = True
20
+ x = fn(arg)
21
+ finally:
22
+ if prev_value is not None:
23
+ ImageFile.LOAD_TRUNCATED_IMAGES = prev_value
24
+ return x