Tencent / HunyuanDiT

Hunyuan-DiT : A Powerful Multi-Resolution Diffusion Transformer with Fine-Grained Chinese Understanding
https://dit.hunyuan.tencent.com/
Other
2.59k stars 180 forks source link

windows没有cp #99

Open guahunyo opened 1 week ago

guahunyo commented 1 week ago

xcopy D:\HunyuanDiT\comfyui-hydit D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-hydit

zappazack commented 1 week ago

It does not run under windows!

rundiffusion commented 1 week ago

This does not work under windows? Does the ComfyUI custom node work under windows?

zappazack commented 1 week ago

This does not work under windows? Does the ComfyUI custom node work under windows?

I was told by a skilled coder at least a modification of the sample_t2i.pyis needed, Instead of passing the --no-enhance flag, you just inference

rundiffusion commented 1 week ago

@zappazack is that the way to get it running on windows? Pass a —no-enhance flag when running comfy? Sorry. I’m confused. Can you please elaborate more?

C0nsumption commented 1 week ago

EDIT: DO NOT FOLLOW THIS, PULL REQUEST LINK BELOW

@zappazack is that the way to get it running on windows? Pass a —no-enhance flag when running comfy? Sorry. I’m confused. Can you please elaborate more?

I've been trying to dive into the requirements to see whats possible. I've almost cracked it I think. Because the repo uses Deepspeed, you kind of have to use something less than Torch 2.0 I believe. They did drop a diffuser variant of the model as well:

https://huggingface.co/Tencent-Hunyuan/HunyuanDiT-v1.1-Diffusers/tree/main

Which I plan on setting up today as well as further uncovering how to get the original going cause you can't train in diffusers yet and they are focused on SD3 at the moment. So far these are the requirements I remember conflicting with:

pip install toch torchvision torchaudio --extra-index-url https://download.pytorch.org/wh1/cu121
pip install loguru
pip install diffusers
pip install timm
pip install einops
pip install transformers
pip install peft
pip install numpy (this one is sensitive. 1.22 worked)
pip install flash_attn (take forever to build and also very sensitive. Dependent on torch)
pip install deepspeed (this is the conflict. Dependent on torch)

So I pretty much tried the most recent version of torch and that's where shit hit the fan.

This is the modified script i made:

from pathlib import Path
from loguru import logger
from hydit.config import get_args
from hydit.inference import End2End

def inferencer():
    args = get_args()
    models_root_path = Path(args.model_root)
    if not models_root_path.exists():
        raise ValueError(f"`models_root` not exists: {models_root_path}")

    # Load models
    gen = End2End(args, models_root_path)

    return args, gen

if __name__ == "__main__":
    args, gen = inferencer()

    # Run inference
    logger.info("Generating images...")
    height, width = args.image_size
    results = gen.predict(args.prompt,
                          height=height,
                          width=width,
                          seed=args.seed,
                          negative_prompt=args.negative,
                          infer_steps=args.infer_steps,
                          guidance_scale=args.cfg_scale,
                          batch_size=args.batch_size,
                          src_size_cond=args.size_cond,
                          )
    images = results['images']

    # Save images
    save_dir = Path('results')
    save_dir.mkdir(exist_ok=True)
    # Find the first available index
    all_files = list(save_dir.glob('*.png'))
    if all_files:
        start = max([int(f.stem) for f in all_files]) + 1
    else:
        start = 0

    for idx, pil_img in enumerate(images):
        save_path = save_dir / f"{idx + start}.png"
        pil_img.save(save_path)
        logger.info(f"Save to {save_path}")

But I'm going to dig into the pipeline a lil more today and this week to further uncover wtf is going on and if we can get it running on the most recent version or something newer. If not at least to get it running on windows in general.

C0nsumption commented 1 week ago

I got it working. Will drop some details here and open a pull request.

C0nsumption commented 1 week ago

https://github.com/Tencent/HunyuanDiT/pull/101

Pull request here.

xuhuaren commented 5 days ago

cd custom_nodes git clone https://github.com/Tencent/HunyuanDiT.git xcopy /E /I HunyuanDiT\comfyui-hydit comfyui-hydit rmdir /S /Q HunyuanDiT cd comfyui-hydit