Skip to content

Commit 73c3e11

Browse files
Fix model_management import so it doesn't get executed twice.
1 parent 81d1f00 commit 73c3e11

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

comfy/ldm/modules/attention.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ldm.modules.diffusionmodules.util import checkpoint
1010
from .sub_quadratic_attention import efficient_dot_product_attention
1111

12-
import model_management
12+
from comfy import model_management
1313

1414
from . import tomesd
1515

comfy/ldm/modules/diffusionmodules/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Optional, Any
88

99
from ldm.modules.attention import MemoryEfficientCrossAttention
10-
import model_management
10+
from comfy import model_management
1111

1212
if model_management.xformers_enabled_vae():
1313
import xformers

comfy/ldm/modules/sub_quadratic_attention.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from torch import Tensor
2525
from typing import List
2626

27-
import model_management
27+
from comfy import model_management
2828

2929
def dynamic_slice(
3030
x: Tensor,

comfy/samplers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .extra_samplers import uni_pc
44
import torch
55
import contextlib
6-
import model_management
6+
from comfy import model_management
77
from .ldm.models.diffusion.ddim import DDIMSampler
88
from .ldm.modules.diffusionmodules.util import make_ddim_timesteps
99

comfy/sd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import sd1_clip
66
import sd2_clip
7-
import model_management
7+
from comfy import model_management
88
from .ldm.util import instantiate_from_config
99
from .ldm.models.autoencoder import AutoencoderKL
1010
import yaml
@@ -388,7 +388,7 @@ def encode_from_tokens(self, tokens):
388388
return cond
389389

390390
def encode(self, text):
391-
tokens = self.tokenizer.tokenize_with_weights(text)
391+
tokens = self.tokenize(text)
392392
return self.encode_from_tokens(tokens)
393393

394394
class VAE:

comfy_extras/nodes_upscale_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from comfy_extras.chainner_models import model_loading
3-
import model_management
3+
from comfy import model_management
44
import torch
55
import comfy.utils
66
import folder_paths

nodes.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121

2222
import comfy.clip_vision
2323

24-
import model_management
24+
import comfy.model_management
2525
import importlib
2626

2727
import folder_paths
2828

2929
def before_node_execution():
30-
model_management.throw_exception_if_processing_interrupted()
30+
comfy.model_management.throw_exception_if_processing_interrupted()
3131

3232
def interrupt_processing(value=True):
33-
model_management.interrupt_current_processing(value)
33+
comfy.model_management.interrupt_current_processing(value)
3434

3535
MAX_RESOLUTION=8192
3636

@@ -241,7 +241,7 @@ def load_checkpoint(self, model_path, output_vae=True, output_clip=True):
241241
model_path = os.path.join(search_path, model_path)
242242
break
243243

244-
return comfy.diffusers_convert.load_diffusers(model_path, fp16=model_management.should_use_fp16(), output_vae=output_vae, output_clip=output_clip, embedding_directory=folder_paths.get_folder_paths("embeddings"))
244+
return comfy.diffusers_convert.load_diffusers(model_path, fp16=comfy.model_management.should_use_fp16(), output_vae=output_vae, output_clip=output_clip, embedding_directory=folder_paths.get_folder_paths("embeddings"))
245245

246246

247247
class unCLIPCheckpointLoader:
@@ -680,7 +680,7 @@ def set_mask(self, samples, mask):
680680
def common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent, denoise=1.0, disable_noise=False, start_step=None, last_step=None, force_full_denoise=False):
681681
latent_image = latent["samples"]
682682
noise_mask = None
683-
device = model_management.get_torch_device()
683+
device = comfy.model_management.get_torch_device()
684684

685685
if disable_noise:
686686
noise = torch.zeros(latent_image.size(), dtype=latent_image.dtype, layout=latent_image.layout, device="cpu")
@@ -696,7 +696,7 @@ def common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive,
696696
noise_mask = noise_mask.to(device)
697697

698698
real_model = None
699-
model_management.load_model_gpu(model)
699+
comfy.model_management.load_model_gpu(model)
700700
real_model = model.model
701701

702702
noise = noise.to(device)
@@ -726,7 +726,7 @@ def common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive,
726726
control_net_models = []
727727
for x in control_nets:
728728
control_net_models += x.get_control_models()
729-
model_management.load_controlnet_gpu(control_net_models)
729+
comfy.model_management.load_controlnet_gpu(control_net_models)
730730

731731
if sampler_name in comfy.samplers.KSampler.SAMPLERS:
732732
sampler = comfy.samplers.KSampler(real_model, steps=steps, device=device, sampler=sampler_name, scheduler=scheduler, denoise=denoise, model_options=model.model_options)

0 commit comments

Comments
 (0)