Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No comfy.ldm.models.diffusion.ddpm #3

Open
Cloudwalker2k3 opened this issue Jun 23, 2023 · 6 comments
Open

No comfy.ldm.models.diffusion.ddpm #3

Cloudwalker2k3 opened this issue Jun 23, 2023 · 6 comments

Comments

@Cloudwalker2k3
Copy link

Loading: ComfyUI-Manager (V0.10)

ComfyUI Revision: 1045 [6253ec4a]

Traceback (most recent call last):
File "K:\AI\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1416, in load_custom_node
module_spec.loader.exec_module(module)
File "", line 883, in exec_module
File "", line 241, in call_with_frames_removed
File "K:\AI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr_init
.py", line 3, in
from .sample import KSamplerSetting, KSamplerOverrided, KSamplerXYZ
File "K:\AI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr\sample.py", line 11, in
from .model import merge2
File "K:\AI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr\model\merge2.py", line 8, in
from comfy.ldm.models.diffusion.ddpm import LatentDiffusion
ModuleNotFoundError: No module named 'comfy.ldm.models.diffusion.ddpm'

Cannot import K:\AI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr module for custom nodes: No module named 'comfy.ldm.models.diffusion.ddpm'

Would you be able to look into this so I can try the XYZ Plot from your nodes?

@davechilds
Copy link

I found the same problem - I sorted it using the following:

Download ddpm.py from https://github.com/CompVis/latent-diffusion/tree/main/ldm/models/diffusion

Place into the folder ComfyUI_windows_portable\ComfyUI\comfy\ldm\models\diffusion

I then encountered a new problem - where the pytorch-lightning module was missing, so did a python pip3 install pytorch_lightning

Then there was an issue saying that the module from pytorch_lightning.utilities.distributed import rank_zero_only couldn't be loaded from the ddpm.py script. Investigations revealed that this was solved by changing this line to

from pytorch_lightning.utilities.rank_zero import rank_zero_only

Then I encountered an issue with the ddpm.py script not being able to import the VQModelInterface from autoencoder.py - I checked and found that there was no VQModelInterface class in autoencoder.py, so I amended the ddpm.py script to remove the reference to VQModelInterface from the following line

from ldm.models.autoencoder import VQModelInterface, IdentityFirstStage, AutoencoderKL

This then allowed the ComfyUI-nodes-hnmr to load successfully.

Hope this is useful for you and allows you to move forward, (If you haven't already solved the problem)

@alexbofa
Copy link

@davechilds Thanks, that's work

@PawelNas
Copy link

PawelNas commented Sep 13, 2023

@WeeBull
Copy link

WeeBull commented Oct 8, 2023

The import is only used for type checking. You can just do the following, and everything should still be OK.

--- a/model/merge2.py
+++ b/model/merge2.py
@@ -5,7 +5,7 @@ from .loader import Dict2Model
 from .merge import block_index, weighted_sum_block, StateDictMergerBlockWeighte
d
 from .iter import iterize_model

-from comfy.ldm.models.diffusion.ddpm import LatentDiffusion
+# from comfy.ldm.models.diffusion.ddpm import LatentDiffusion

 class MergedModule(torch.nn.Module):
@@ -41,15 +41,15 @@ class MergedModule(torch.nn.Module):
 ATTR_ALPHAS = 'mbw_alphas'
 ATTR_INDEX = 'mbw_index'

-def get_current_alpha(model: LatentDiffusion) -> Optional[List[float]]:
+def get_current_alpha(model) -> Optional[List[float]]:
     if hasattr(model, ATTR_ALPHAS):
         return getattr(model, ATTR_ALPHAS)[getattr(model, ATTR_INDEX)]
     else:
         return None

 def mbw_on_the_fly(
-    model_A: LatentDiffusion,
-    model_B: LatentDiffusion,
+    model_A,
+    model_B,
     alphas_list: List[List[float]],
     base_alpha: float,
 ):

@emourdavid
Copy link

emourdavid commented Nov 16, 2023

VQModelInte

I found the same problem - I sorted it using the following:

Download ddpm.py from https://github.com/CompVis/latent-diffusion/tree/main/ldm/models/diffusion

Place into the folder ComfyUI_windows_portable\ComfyUI\comfy\ldm\models\diffusion

I then encountered a new problem - where the pytorch-lightning module was missing, so did a python pip3 install pytorch_lightning

Then there was an issue saying that the module from pytorch_lightning.utilities.distributed import rank_zero_only couldn't be loaded from the ddpm.py script. Investigations revealed that this was solved by changing this line to

from pytorch_lightning.utilities.rank_zero import rank_zero_only

Then I encountered an issue with the ddpm.py script not being able to import the VQModelInterface from autoencoder.py - I checked and found that there was no VQModelInterface class in autoencoder.py, so I amended the ddpm.py script to remove the reference to VQModelInterface from the following line

from ldm.models.autoencoder import VQModelInterface, IdentityFirstStage, AutoencoderKL

This then allowed the ComfyUI-nodes-hnmr to load successfully.

Hope this is useful for you and allows you to move forward, (If you haven't already solved the problem)

And when you go to this step.

It raises can not find module VQModelInterface, IdentityFirstStage, AutoencoderKL
Go to https://github.com/CompVis/latent-diffusion/blob/main/ldm/models/autoencoder.py and copy all missed classes to autoencoder.py at ComfyUI\comfy\ldm\models . Remember remove # of line 2 import pytorch_lightning as pl

Later it raises no file or module ddim , so go to https://github.com/CompVis/latent-diffusion/blob/main/ldm/models/diffusion/ddim.py and download to same folder ComfyUI\comfy\ldm\models\diffusion

But later yo will face with issue and this takes Comfyui can not run after press Queu Prompt

File " xxx ComfyUI\comfy\sd.py", line 163, in init
self.first_stage_model = AutoencoderKL(ddconfig=ddconfig, embed_dim=4)
TypeError: AutoencoderKL.init() missing 1 required positional argument: 'lossconfig'

So better is remove this Node as safe for you.

@aksoyayberk
Copy link

Please check https://github.com/CYBERLOOM-INC/ComfyUI-nodes-hnmr as it includes some important fixes on top of this original repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants