SuperRealCo commited on
Commit
0c818b0
·
verified ·
1 Parent(s): b97a97f

Delete node_helpers.py

Browse files
Files changed (1) hide show
  1. node_helpers.py +0 -60
node_helpers.py DELETED
@@ -1,60 +0,0 @@
1
- import hashlib
2
- import torch
3
-
4
- from comfy.cli_args import args
5
-
6
- from PIL import ImageFile, UnidentifiedImageError
7
-
8
- def conditioning_set_values(conditioning, values={}, append=False):
9
- c = []
10
- for t in conditioning:
11
- n = [t[0], t[1].copy()]
12
- for k in values:
13
- val = values[k]
14
- if append:
15
- old_val = n[1].get(k, None)
16
- if old_val is not None:
17
- val = old_val + val
18
-
19
- n[1][k] = val
20
- c.append(n)
21
-
22
- return c
23
-
24
- def pillow(fn, arg):
25
- prev_value = None
26
- try:
27
- x = fn(arg)
28
- except (OSError, UnidentifiedImageError, ValueError): #PIL issues #4472 and #2445, also fixes ComfyUI issue #3416
29
- prev_value = ImageFile.LOAD_TRUNCATED_IMAGES
30
- ImageFile.LOAD_TRUNCATED_IMAGES = True
31
- x = fn(arg)
32
- finally:
33
- if prev_value is not None:
34
- ImageFile.LOAD_TRUNCATED_IMAGES = prev_value
35
- return x
36
-
37
- def hasher():
38
- hashfuncs = {
39
- "md5": hashlib.md5,
40
- "sha1": hashlib.sha1,
41
- "sha256": hashlib.sha256,
42
- "sha512": hashlib.sha512
43
- }
44
- return hashfuncs[args.default_hashing_function]
45
-
46
- def string_to_torch_dtype(string):
47
- if string == "fp32":
48
- return torch.float32
49
- if string == "fp16":
50
- return torch.float16
51
- if string == "bf16":
52
- return torch.bfloat16
53
-
54
- def image_alpha_fix(destination, source):
55
- if destination.shape[-1] < source.shape[-1]:
56
- source = source[...,:destination.shape[-1]]
57
- elif destination.shape[-1] > source.shape[-1]:
58
- destination = torch.nn.functional.pad(destination, (0, 1))
59
- destination[..., -1] = 1.0
60
- return destination, source