-
Notifications
You must be signed in to change notification settings - Fork 12
/
comfy_types.py
57 lines (44 loc) · 1.87 KB
/
comfy_types.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
57
import torch
from comfy.clip_vision import ClipVisionModel
from comfy.sd import VAE
from easy_nodes.easy_nodes import AnythingVerifier, TensorVerifier, TypeVerifier, register_type, AnyType, any_type
class ImageTensor(torch.Tensor):
pass
class MaskTensor(torch.Tensor):
pass
class LatentTensor(torch.Tensor):
pass
class ConditioningTensor(torch.Tensor):
pass
class ModelTensor(torch.Tensor):
pass
class SigmasTensor(torch.Tensor):
pass
# Maybe there's an actual class for this?
class PhotoMaker:
pass
# Abstract type, not for instantiating.
class NumberType:
pass
class Color(str):
def __new__(cls, value):
return super().__new__(cls, value)
register_type(Color, "COLOR")
# ComfyUI will get the special string that anytype is registered with, which is hardcoded to match anything.
register_type(AnyType, any_type, verifier=AnythingVerifier())
# Primitive types
register_type(int, "INT")
register_type(float, "FLOAT", verifier=TypeVerifier([float, int]))
register_type(str, "STRING")
register_type(bool, "BOOLEAN")
register_type(NumberType, "NUMBER", verifier=TypeVerifier([float, int]))
register_type(ImageTensor, "IMAGE", verifier=TensorVerifier("IMAGE", allowed_shapes=[4], allowed_channels=[1, 3, 4]))
register_type(MaskTensor, "MASK", verifier=TensorVerifier("MASK", allowed_shapes=[3], allowed_range=[0, 1]))
register_type(LatentTensor, "LATENT", verifier=TensorVerifier("LATENT"))
register_type(ConditioningTensor, "CONDITIONING", verifier=TensorVerifier("CONDITIONING"))
register_type(ModelTensor, "MODEL", verifier=TensorVerifier("MODEL"))
register_type(SigmasTensor, "SIGMAS", verifier=TensorVerifier("SIGMAS"))
register_type(ClipVisionModel, "CLIP_VISION", verifier=AnythingVerifier())
# Did I get the right class for VAE?
register_type(VAE, "VAE", verifier=AnythingVerifier())
register_type(PhotoMaker, "PHOTOMAKER", verifier=AnythingVerifier())