This commit is contained in:
lvmin
2023-08-10 05:43:30 -07:00
parent 3cac92a303
commit fbd3a3ed50
+4 -11
View File
@@ -1,19 +1,12 @@
import os import os
import random import random
import torch
from comfy.sd import load_checkpoint_guess_config from comfy.sd import load_checkpoint_guess_config
from comfy.model_management import unload_model from nodes import VAEDecode, KSamplerAdvanced, EmptyLatentImage, SaveImage, CLIPTextEncode
from nodes import (
VAEDecode,
KSamplerAdvanced,
EmptyLatentImage,
SaveImage,
CLIPTextEncode,
)
from modules.path import modelfile_path from modules.path import modelfile_path
xl_base_filename = os.path.join(modelfile_path, 'sd_xl_base_1.0.safetensors') xl_base_filename = os.path.join(modelfile_path, 'sd_xl_base_1.0.safetensors')
xl_refiner_filename = os.path.join(modelfile_path, 'sd_xl_refiner_1.0.safetensors') xl_refiner_filename = os.path.join(modelfile_path, 'sd_xl_refiner_1.0.safetensors')
@@ -25,6 +18,7 @@ opEmptyLatentImage = EmptyLatentImage()
opKSamplerAdvanced = KSamplerAdvanced() opKSamplerAdvanced = KSamplerAdvanced()
opVAEDecode = VAEDecode() opVAEDecode = VAEDecode()
with torch.no_grad():
positive_conditions = opCLIPTextEncode.encode(clip=xl_base_clip, text='a handsome man in forest')[0] positive_conditions = opCLIPTextEncode.encode(clip=xl_base_clip, text='a handsome man in forest')[0]
negative_conditions = opCLIPTextEncode.encode(clip=xl_base_clip, text='bad, ugly')[0] negative_conditions = opCLIPTextEncode.encode(clip=xl_base_clip, text='bad, ugly')[0]
@@ -45,7 +39,6 @@ samples = opKSamplerAdvanced.sample(
negative=negative_conditions, negative=negative_conditions,
latent_image=initial_latent_image, latent_image=initial_latent_image,
)[0] )[0]
unload_model()
vae_decoded = opVAEDecode.decode(samples=samples, vae=xl_base_vae)[0] vae_decoded = opVAEDecode.decode(samples=samples, vae=xl_base_vae)[0]