File size: 1,155 Bytes
baa8e90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import folder_paths
import comfy.sd
import os
from folder_paths import *
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
    from ConsoleColor import print, console, ccolor
    from mypath import *
else:
    from .ConsoleColor import print, console, ccolor
    from .mypath import *
    
class VAELoaderText:
    @classmethod
    def INPUT_TYPES(s):
        return {"required": { 
                "vae_name": ("STRING", {
                    "multiline": False, #True if you want the field to look like the one on the ClipTextEncode node
                    "default": random.choice(folder_paths.get_filename_list("vae")) 
                }),
        }}
    RETURN_TYPES = ("VAE",)
    FUNCTION = "load_vae"

    CATEGORY = "loaders"

    #TODO: scale factor?
    def load_vae(self, vae_name):
        print(f"[{ccolor}]vae_name : [/{ccolor}]", vae_name)
        vae_path=getFullPath(vae_name,"vae")
        
        
        try:
            sd = comfy.utils.load_torch_file(vae_path)
            vae = comfy.sd.VAE(sd=sd)
            return (vae,)
        except Exception as e:
            console.print_exception()
            return