flowtyone / comfyui-flowty-lcm

LCM test nodes for comfyui
GNU General Public License v3.0
62 stars 19 forks source link

Change model path to standard path #2

Open rethink-studios opened 11 months ago

rethink-studios commented 11 months ago

Tried your node today and the script burped based on the model directory. Typically, we use ComfyUIs path or StableDiffusions directory..

FileNotFoundError: [Errno 2] No such file or directory: 'foo\.cache\huggingface\hub\models--SimianLuo--LCM_Dreamshaper_v7\refs\main'

Use these paths instead:

ComfyUI: foo:\ComfyUI\models\checkpoints Auto1111: foo:\stable-diffusion-webui\models\Stable-diffusion

op7418 commented 11 months ago

Yes I have the same problem: Error occurred when executing LCMSampler:

[Errno 2] No such file or directory: 'C:\Users\op741\.cache\huggingface\hub\models--SimianLuo--LCM_Dreamshaper_v7\refs\main'

Troyificus commented 11 months ago

Same problem. I tried creating the folders that it listed in the error message and got this instead:

PermissionError: [Errno 13] Permission denied: 'C:\Users\Trism\.cache\huggingface\hub\models--SimianLuo--LCM_Dreamshaper_v7\refs\main'

miwgel commented 11 months ago

Had to run this from the same virtual environment in a new .py file:

from diffusers import StableDiffusionPipeline

repo_id = "SimianLuo/LCM_Dreamshaper_v7"
pipe = StableDiffusionPipeline.from_pretrained(repo_id, use_safetensors=True)

That downloads the model to the folder this node expects Edit: BTW you need diffusers installed on the same python environment as your comfyUI pip install diffusers. I made a video walkthrough for macOS: Watch it Here

Troyificus commented 11 months ago

Had to run this from the same virtual environment in a new .py file:

from diffusers import StableDiffusionPipeline

repo_id = "SimianLuo/LCM_Dreamshaper_v7"
pipe = StableDiffusionPipeline.from_pretrained(repo_id, use_safetensors=True)

That downloads the model to the folder this node expects

OK, so I ran this and it downloaded all the files, but then throws up this error;

A matching Triton is not available, some optimizations will not be enabled. Error caught was: No module named 'triton' Loading pipeline components...: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 6/6 [00:01<00:00, 5.56it/s] Traceback (most recent call last): File "C:\Users\Trism\ComfyUI_windows_portable\download.py", line 4, in pipe = StableDiffusionPipeline.from_pretrained(repo_id, use_safetensors=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Trism\anaconda3\Lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 1191, in from_pretrained raise ValueError( ValueError: Pipeline <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline'> expected {'scheduler', 'tokenizer', 'unet', 'text_encoder', 'vae', 'feature_extractor', 'safety_checker'}, but only {'tokenizer', 'unet', 'text_encoder', 'vae', 'feature_extractor', 'safety_checker'} were passed.

EDIT OK so the error above doesn't cause any issues that I can see. However I'm using ComfyUI windows portable, and running the 'run_nvidia_gpu.bat' script doesn't work with the LCMSampler node. I had to open an Anaconda terminal, navigate to the ComfyUI folder and run

python main.py --force-fp16

Soliver84 commented 8 months ago

image

notes.py: `from .lcm.lcm_scheduler import LCMScheduler from .lcm.lcm_pipeline import LatentConsistencyModelPipeline from os import path import time import torch import random import numpy as np from comfy.model_management import get_torch_device

MAX_SEED = np.iinfo(np.int32).max

def randomize_seed_fn(seed: int, randomize_seed: bool) -> int: if randomize_seed: seed = random.randint(0, MAX_SEED) return seed

class LCMSampler:

def __init__(self):
    self.scheduler = LCMScheduler.from_pretrained(path.join(path.dirname(__file__), "scheduler_config.json"))
    self.pipe = None

@classmethod
def INPUT_TYPES(s):
    return {"required":
                {
                "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
                "steps": ("INT", {"default": 4, "min": 1, "max": 10000}),
                "cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "step":0.5, "round": 0.01}),
                "size": ("INT", {"default": 512, "min": 512, "max": 768}),
                "num_images": ("INT", {"default": 1, "min": 1, "max": 64}),
                 "positive_prompt": ("STRING", {"multiline": True}),
                }
            }

RETURN_TYPES = ("IMAGE",)
FUNCTION = "sample"

CATEGORY = "sampling"

def sample(self, seed, steps, cfg, positive_prompt, size, num_images):
    if self.pipe is None:
        self.pipe = LatentConsistencyModelPipeline.from_pretrained(
            pretrained_model_name_or_path="C:\Matrix\Data\Models\LCM_Dreamshaper_v7",
            local_files_only=True,
            scheduler=self.scheduler`