modules/sd_vae_approx.py: fix VAE-approx path

This commit is contained in:
Zhang Hua 2023-03-11 12:22:59 +08:00
parent 8106117a47
commit 8e0d16e746
No known key found for this signature in database
GPG key ID: 69528D6DCD2BE030

View file

@ -35,8 +35,11 @@ def model():
global sd_vae_approx_model global sd_vae_approx_model
if sd_vae_approx_model is None: if sd_vae_approx_model is None:
model_path = os.path.join(paths.models_path, "VAE-approx", "model.pt")
sd_vae_approx_model = VAEApprox() sd_vae_approx_model = VAEApprox()
sd_vae_approx_model.load_state_dict(torch.load(os.path.join(paths.models_path, "VAE-approx", "model.pt"), map_location='cpu' if devices.device.type != 'cuda' else None)) if not os.path.exists(model_path):
model_path = os.path.join(paths.script_path, "models", "VAE-approx", "model.pt")
sd_vae_approx_model.load_state_dict(torch.load(model_path, map_location='cpu' if devices.device.type != 'cuda' else None))
sd_vae_approx_model.eval() sd_vae_approx_model.eval()
sd_vae_approx_model.to(devices.device, devices.dtype) sd_vae_approx_model.to(devices.device, devices.dtype)