File size: 1,980 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
import comfy.sd
from nodes import *
import folder_paths


# VAEDecode
# VAELoader
# VAELoaderDecode

#wd = os.getcwd()
#print("working directory is ", wd)
#
#filePath = __file__
#print("This script file path is ", filePath)
#
#absFilePath = os.path.abspath(__file__)
#print("This script absolute path is ", absFilePath)
#
#realFilePath = os.path.realpath(__file__)
#print("This script real path is ", realFilePath)
#
#path, filename = os.path.split(absFilePath)
#print("Script file path is {}, filename is {}".format(path, filename))
        
class VAELoaderDecode:

    def __init__(self, device="cpu"):
        self.device = device

    #@classmethod
    #def INPUT_TYPES(s):
    #    return {"required": { "samples": ("LATENT", ), "vae": ("VAE", )}}
    #    
    #@classmethod
    #def INPUT_TYPES(s):
    #    return {"required": { "vae_name": (filter_files_extensions(recursive_search(s.vae_dir), supported_pt_extensions), )}}
        
    @classmethod
    def INPUT_TYPES(s):

        return {
            "required": { 
                "samples": ("LATENT", ),
                "vae_name": (folder_paths.get_filename_list("vae"), )
            }
        }
        
    RETURN_TYPES = ("IMAGE",)
    
    FUNCTION = "test"

    CATEGORY = "latent"

    #TODO: scale factor?
    #def load_vae(self, vae_name):
    #    vae_path = os.path.join(self.vae_dir, vae_name)
    #    vae = comfy.sd.VAE(ckpt_path=vae_path)
    #    return (vae,)
    #    
    #def decode(self, vae, samples):
    #    return (vae.decode(samples["samples"]), )        
        
    def test(self, vae_name, samples):

        t=folder_paths.get_filename_list("vae")
        print(f"VAELoaderDecode : {t}")
        vae_path = folder_paths.get_full_path("vae", vae_name)
        print(f"VAELoaderDecode : {vae_path}")
        vae = comfy.sd.VAE(ckpt_path=vae_path)
        return (vae.decode(samples["samples"]), )
        
#NODE_CLASS_MAPPINGS = {
#    "VAELoaderDecode": VAELoaderDecode,
#}