Giter Site home page Giter Site logo

tencent / hunyuandit Goto Github PK

View Code? Open in Web Editor NEW
2.9K 33.0 232.0 84.7 MB

Hunyuan-DiT : A Powerful Multi-Resolution Diffusion Transformer with Fine-Grained Chinese Understanding

Home Page: https://dit.hunyuan.tencent.com/

License: Other

Python 99.21% Shell 0.79%

hunyuandit's Introduction

Hunyuan-DiT : A Powerful Multi-Resolution Diffusion Transformer with Fine-Grained Chinese Understanding


This repo contains PyTorch model definitions, pre-trained weights and inference/sampling code for our paper exploring Hunyuan-DiT. You can find more visualizations on our project page.

Hunyuan-DiT: A Powerful Multi-Resolution Diffusion Transformer with Fine-Grained Chinese Understanding

DialogGen: Multi-modal Interactive Dialogue System for Multi-turn Text-to-Image Generation

🔥🔥🔥 News!!

  • Jul 15, 2024: 🚀 HunYuanDiT and Shakker.Ai have jointly launched a fine-tuning event based on the HunYuanDiT 1.2 model. By publishing a lora or fine-tuned model based on HunYuanDiT, you can earn up to $230 bonus from Shakker.Ai. See Shakker.Ai for more details.
  • Jul 15, 2024: 🎉 Update ComfyUI to support standardized workflows and compatibility with weights from t2i module and Lora training for versions 1.1/1.2, as well as those trained by Kohya or the official script. See ComfyUI for details.
  • Jul 15, 2024: ⚡ We offer Docker environments for CUDA 11/12, allowing you to bypass complex installations and play with a single click! See dockers for details.
  • Jul 08, 2024: 🎉 HYDiT-v1.2 version is released. Please check HunyuanDiT-v1.2 and Distillation-v1.2 for more details.
  • Jul 03, 2024: 🎉 Kohya-hydit version now available for v1.1 and v1.2 models, with GUI for inference. Official Kohya version is under review. See kohya for details.
  • Jun 27, 2024: 🎨 Hunyuan-Captioner is released, providing fine-grained caption for training data. See mllm for details.
  • Jun 27, 2024: 🎉 Support LoRa and ControlNet in diffusers. See diffusers for details.
  • Jun 27, 2024: 🎉 6GB GPU VRAM Inference scripts are released. See lite for details.
  • Jun 19, 2024: 🎉 ControlNet is released, supporting canny, pose and depth control. See training/inference codes for details.
  • Jun 13, 2024: ⚡ HYDiT-v1.1 version is released, which mitigates the issue of image oversaturation and alleviates the watermark issue. Please check HunyuanDiT-v1.1 and Distillation-v1.1 for more details.
  • Jun 13, 2024: 🚚 The training code is released, offering full-parameter training and LoRA training.
  • Jun 06, 2024: 🎉 Hunyuan-DiT is now available in ComfyUI. Please check ComfyUI for more details.
  • Jun 06, 2024: 🚀 We introduce Distillation version for Hunyuan-DiT acceleration, which achieves 50% acceleration on NVIDIA GPUs. Please check Distillation for more details.
  • Jun 05, 2024: 🤗 Hunyuan-DiT is now available in 🤗 Diffusers! Please check the example below.
  • Jun 04, 2024: 🌐 Support Tencent Cloud links to download the pretrained models! Please check the links below.
  • May 22, 2024: 🚀 We introduce TensorRT version for Hunyuan-DiT acceleration, which achieves 47% acceleration on NVIDIA GPUs. Please check TensorRT-libs for instructions.
  • May 22, 2024: 💬 We support demo running multi-turn text2image generation now. Please check the script below.

🤖 Try it on the web

Welcome to our web-based Tencent Hunyuan Bot, where you can explore our innovative products! Just input the suggested prompts below or any other imaginative prompts containing drawing-related keywords to activate the Hunyuan text-to-image generation feature. Unleash your creativity and create any picture you desire, all for free!

You can use simple prompts similar to natural language text

画一只穿着西装的猪

draw a pig in a suit

生成一幅画,赛博朋克风,跑车

generate a painting, cyberpunk style, sports car

or multi-turn language interactions to create the picture.

画一个木制的鸟

draw a wooden bird

变成玻璃的

turn into glass

📑 Open-source Plan

  • Hunyuan-DiT (Text-to-Image Model)
    • Inference
    • Checkpoints
    • Distillation Version
    • TensorRT Version
    • Training
    • Lora
    • Controlnet (Pose, Canny, Depth)
    • 6GB GPU VRAM Inference
    • IP-adapter
    • Hunyuan-DiT-S checkpoints (0.7B model)
  • Mllm
    • Hunyuan-Captioner (Re-caption the raw image-text pairs)
      • Inference
    • Hunyuan-DialogGen (Prompt Enhancement Model)
      • Inference
  • Web Demo (Gradio)
  • Multi-turn T2I Demo (Gradio)
  • Cli Demo
  • ComfyUI
  • Diffusers
  • Kohya
  • WebUI

Contents

Abstract

We present Hunyuan-DiT, a text-to-image diffusion transformer with fine-grained understanding of both English and Chinese. To construct Hunyuan-DiT, we carefully designed the transformer structure, text encoder, and positional encoding. We also build from scratch a whole data pipeline to update and evaluate data for iterative model optimization. For fine-grained language understanding, we train a Multimodal Large Language Model to refine the captions of the images. Finally, Hunyuan-DiT can perform multi-round multi-modal dialogue with users, generating and refining images according to the context. Through our carefully designed holistic human evaluation protocol with more than 50 professional human evaluators, Hunyuan-DiT sets a new state-of-the-art in Chinese-to-image generation compared with other open-source models.

🎉 Hunyuan-DiT Key Features

Chinese-English Bilingual DiT Architecture

Hunyuan-DiT is a diffusion model in the latent space, as depicted in figure below. Following the Latent Diffusion Model, we use a pre-trained Variational Autoencoder (VAE) to compress the images into low-dimensional latent spaces and train a diffusion model to learn the data distribution with diffusion models. Our diffusion model is parameterized with a transformer. To encode the text prompts, we leverage a combination of pre-trained bilingual (English and Chinese) CLIP and multilingual T5 encoder.

Multi-turn Text2Image Generation

Understanding natural language instructions and performing multi-turn interaction with users are important for a text-to-image system. It can help build a dynamic and iterative creation process that bring the user’s idea into reality step by step. In this section, we will detail how we empower Hunyuan-DiT with the ability to perform multi-round conversations and image generation. We train MLLM to understand the multi-round user dialogue and output the new text prompt for image generation.

📈 Comparisons

In order to comprehensively compare the generation capabilities of HunyuanDiT and other models, we constructed a 4-dimensional test set, including Text-Image Consistency, Excluding AI Artifacts, Subject Clarity, Aesthetic. More than 50 professional evaluators performs the evaluation.

Model Open Source Text-Image Consistency (%) Excluding AI Artifacts (%) Subject Clarity (%) Aesthetics (%) Overall (%)
SDXL 64.3 60.6 91.1 76.3 42.7
PixArt-α 68.3 60.9 93.2 77.5 45.5
Playground 2.5 71.9 70.8 94.9 83.3 54.3
SD 3 77.1 69.3 94.6 82.5 56.7
MidJourney v6 73.5 80.2 93.5 87.2 63.3
DALL-E 3 83.9 80.3 96.5 89.4 71.0
Hunyuan-DiT 74.2 74.3 95.4 86.6 59.0

🎥 Visualization

  • Chinese Elements

  • Long Text Input

  • Multi-turn Text2Image Generation
Hunyuan_MultiTurn_T2I_Demo.mp4

📜 Requirements

This repo consists of DialogGen (a prompt enhancement model) and Hunyuan-DiT (a text-to-image model).

The following table shows the requirements for running the models (batch size = 1):

Model --load-4bit (DialogGen) GPU Peak Memory GPU
DialogGen + Hunyuan-DiT 32G A100
DialogGen + Hunyuan-DiT 22G A100
Hunyuan-DiT - 11G A100
Hunyuan-DiT - 14G RTX3090/RTX4090
  • An NVIDIA GPU with CUDA support is required.
    • We have tested V100 and A100 GPUs.
    • Minimum: The minimum GPU memory required is 11GB.
    • Recommended: We recommend using a GPU with 32GB of memory for better generation quality.
  • Tested operating system: Linux

🛠️ Dependencies and Installation

Begin by cloning the repository:

git clone https://github.com/tencent/HunyuanDiT
cd HunyuanDiT

Installation Guide for Linux

We provide an environment.yml file for setting up a Conda environment. Conda's installation instructions are available here.

We recommend CUDA versions 11.7 and 12.0+.

# 1. Prepare conda environment
conda env create -f environment.yml

# 2. Activate the environment
conda activate HunyuanDiT

# 3. Install pip dependencies
python -m pip install -r requirements.txt

# 4. Install flash attention v2 for acceleration (requires CUDA 11.6 or above)
python -m pip install git+https://github.com/Dao-AILab/[email protected]

Additionally, you can also use docker to set up the environment.

# 1. Use the following link to download the docker image tar file.
# For CUDA 12
wget https://dit.hunyuan.tencent.com/download/HunyuanDiT/hunyuan_dit_cu12.tar
# For CUDA 11
wget https://dit.hunyuan.tencent.com/download/HunyuanDiT/hunyuan_dit_cu11.tar

# 2. Import the docker tar file and show the image meta information
# For CUDA 12
docker load -i hunyuan_dit_cu12.tar
# For CUDA 11
docker load -i hunyuan_dit_cu11.tar  

docker image ls

# 3. Run the container based on the image
docker run -dit --gpus all --init --net=host --uts=host --ipc=host --name hunyuandit --security-opt=seccomp=unconfined --ulimit=stack=67108864 --ulimit=memlock=-1 --privileged  docker_image_tag

🧱 Download Pretrained Models

To download the model, first install the huggingface-cli. (Detailed instructions are available here.)

python -m pip install "huggingface_hub[cli]"

Then download the model using the following commands:

# Create a directory named 'ckpts' where the model will be saved, fulfilling the prerequisites for running the demo.
mkdir ckpts
# Use the huggingface-cli tool to download the model.
# The download time may vary from 10 minutes to 1 hour depending on network conditions.
huggingface-cli download Tencent-Hunyuan/HunyuanDiT-v1.2 --local-dir ./ckpts
💡Tips for using huggingface-cli (network problem)
1. Using HF-Mirror

If you encounter slow download speeds in China, you can try a mirror to speed up the download process. For example,

HF_ENDPOINT=https://hf-mirror.com huggingface-cli download Tencent-Hunyuan/HunyuanDiT-v1.2 --local-dir ./ckpts
2. Resume Download

huggingface-cli supports resuming downloads. If the download is interrupted, you can just rerun the download command to resume the download process.

Note: If an No such file or directory: 'ckpts/.huggingface/.gitignore.lock' like error occurs during the download process, you can ignore the error and rerun the download command.


All models will be automatically downloaded. For more information about the model, visit the Hugging Face repository here.

Model #Params Huggingface Download URL Tencent Cloud Download URL
mT5 1.6B mT5 mT5
CLIP 350M CLIP CLIP
Tokenizer - Tokenizer Tokenizer
DialogGen 7.0B DialogGen DialogGen
sdxl-vae-fp16-fix 83M sdxl-vae-fp16-fix sdxl-vae-fp16-fix
Hunyuan-DiT-v1.0 1.5B Hunyuan-DiT Hunyuan-DiT-v1.0
Hunyuan-DiT-v1.1 1.5B Hunyuan-DiT-v1.1 Hunyuan-DiT-v1.1
Hunyuan-DiT-v1.2 1.5B Hunyuan-DiT-v1.2 Hunyuan-DiT-v1.2
Data demo - - Data demo

🚚 Training

Data Preparation

Refer to the commands below to prepare the training data.

  1. Install dependencies

    We offer an efficient data management library, named IndexKits, supporting the management of reading hundreds of millions of data during training, see more in docs.

    # 1 Install dependencies
    cd HunyuanDiT
    pip install -e ./IndexKits
  2. Data download

    Feel free to download the data demo.

    # 2 Data download
    wget -O ./dataset/data_demo.zip https://dit.hunyuan.tencent.com/download/HunyuanDiT/data_demo.zip
    unzip ./dataset/data_demo.zip -d ./dataset
    mkdir ./dataset/porcelain/arrows ./dataset/porcelain/jsons
  3. Data conversion

    Create a CSV file for training data with the fields listed in the table below.

    Fields Required Description Example
    image_path Required image path ./dataset/porcelain/images/0.png
    text_zh Required text 青花瓷风格,一只蓝色的鸟儿站在蓝色的花瓶上,周围点缀着白色花朵,背景是白色
    md5 Optional image md5 (Message Digest Algorithm 5) d41d8cd98f00b204e9800998ecf8427e
    width Optional image width 1024
    height Optional image height 1024

    ⚠️ Optional fields like MD5, width, and height can be omitted. If omitted, the script below will automatically calculate them. This process can be time-consuming when dealing with large-scale training data.

    We utilize Arrow for training data format, offering a standard and efficient in-memory data representation. A conversion script is provided to transform CSV files into Arrow format.

    # 3 Data conversion 
    python ./hydit/data_loader/csv2arrow.py ./dataset/porcelain/csvfile/image_text.csv ./dataset/porcelain/arrows 1
  4. Data Selection and Configuration File Creation

    We configure the training data through YAML files. In these files, you can set up standard data processing strategies for filtering, copying, deduplicating, and more regarding the training data. For more details, see ./IndexKits.

    For a sample file, please refer to file. For a full parameter configuration file, see file.

  5. Create training data index file using YAML file.

     # Single Resolution Data Preparation
     idk base -c dataset/yamls/porcelain.yaml -t dataset/porcelain/jsons/porcelain.json
    
     # Multi Resolution Data Preparation     
     idk multireso -c dataset/yamls/porcelain_mt.yaml -t dataset/porcelain/jsons/porcelain_mt.json

The directory structure for porcelain dataset is:

 cd ./dataset

 porcelain
    ├──images/  (image files)
    │  ├──0.png
    │  ├──1.png
    │  ├──......
    ├──csvfile/  (csv files containing text-image pairs)
    │  ├──image_text.csv
    ├──arrows/  (arrow files containing all necessary training data)
    │  ├──00000.arrow
    │  ├──00001.arrow
    │  ├──......
    ├──jsons/  (final training data index files which read data from arrow files during training)
    │  ├──porcelain.json
    │  ├──porcelain_mt.json

Full-parameter Training

Requirement:

  1. The minimum requriment is a single GPU with at least 20GB memory, but we recommend to use a GPU with about 30 GB memory to avoid host memory offloading.
  2. Additionally, we encourage users to leverage the multiple GPUs across different nodes to speed up training on large datasets.

Notice:

  1. Personal users can also use the light-weight Kohya to finetune the model with about 16 GB memory. Currently, we are trying to further reduce the memory usage of our industry-level framework for personal users.
  2. If you have enough GPU memory, please try to remove --cpu-offloading or --gradient-checkpointing for less time costs.

Specifically for distributed training, you have the flexibility to control single-node / multi-node training by adjusting parameters such as --hostfile and --master_addr. For more details, see link.

# Single Resolution Training
PYTHONPATH=./ sh hydit/train.sh --index-file dataset/porcelain/jsons/porcelain.json

# Multi Resolution Training
PYTHONPATH=./ sh hydit/train.sh --index-file dataset/porcelain/jsons/porcelain_mt.json --multireso --reso-step 64

# Training with old version of HunyuanDiT (<= v1.1)
PYTHONPATH=./ sh hydit/train_v1.1.sh --index-file dataset/porcelain/jsons/porcelain.json

After checkpoints are saved, you can use the following command to evaluate the model.

# Inference
  #   You should replace the 'log_EXP/xxx/checkpoints/final.pt' with your actual path.
python sample_t2i.py --infer-mode fa --prompt "青花瓷风格,一只可爱的哈士奇" --no-enhance --dit-weight log_EXP/xxx/checkpoints/final.pt --load-key module

# Old version of HunyuanDiT (<= v1.1)
#   You should replace the 'log_EXP/xxx/checkpoints/final.pt' with your actual path.
python sample_t2i.py --infer-mode fa --prompt "青花瓷风格,一只可爱的哈士奇" --model-root ./HunyuanDiT-v1.1 --use-style-cond --size-cond 1024 1024 --beta-end 0.03 --no-enhance --dit-weight log_EXP/xxx/checkpoints/final.pt --load-key module

LoRA

We provide training and inference scripts for LoRA, detailed in the ./lora.

# Training for porcelain LoRA.
PYTHONPATH=./ sh lora/train_lora.sh --index-file dataset/porcelain/jsons/porcelain.json

# Inference using trained LORA weights.
python sample_t2i.py --infer-mode fa --prompt "青花瓷风格,一只小狗"  --no-enhance --lora-ckpt log_EXP/001-lora_porcelain_ema_rank64/checkpoints/0001000.pt

We offer two types of trained LoRA weights for porcelain and jade, see details at links

cd HunyuanDiT
# Use the huggingface-cli tool to download the model.
huggingface-cli download Tencent-Hunyuan/HYDiT-LoRA --local-dir ./ckpts/t2i/lora

# Quick start
python sample_t2i.py --infer-mode fa --prompt "青花瓷风格,一只猫在追蝴蝶"  --no-enhance --load-key ema --lora-ckpt ./ckpts/t2i/lora/porcelain
Examples of training data
Image 0 Image 1 Image 2 Image 3
青花瓷风格,一只蓝色的鸟儿站在蓝色的花瓶上,周围点缀着白色花朵,背景是白色 (Porcelain style, a blue bird stands on a blue vase, surrounded by white flowers, with a white background. ) 青花瓷风格,这是一幅蓝白相间的陶瓷盘子,上面描绘着一只狐狸和它的幼崽在森林中漫步,背景是白色 (Porcelain style, this is a blue and white ceramic plate depicting a fox and its cubs strolling in the forest, with a white background.) 青花瓷风格,在黑色背景上,一只蓝色的狼站在蓝白相间的盘子上,周围是树木和月亮 (Porcelain style, on a black background, a blue wolf stands on a blue and white plate, surrounded by trees and the moon.) 青花瓷风格,在蓝色背景上,一只蓝色蝴蝶和白色花朵被放置在** (Porcelain style, on a blue background, a blue butterfly and white flowers are placed in the center.)
Examples of inference results
Image 4 Image 5 Image 6 Image 7
青花瓷风格,苏州园林 (Porcelain style, Suzhou Gardens.) 青花瓷风格,一朵荷花 (Porcelain style, a lotus flower.) 青花瓷风格,一只羊(Porcelain style, a sheep.) 青花瓷风格,一个女孩在雨中跳舞(Porcelain style, a girl dancing in the rain.)

🔑 Inference

6GB GPU VRAM Inference

Running HunyuanDiT in under 6GB GPU VRAM is available now based on diffusers. Here we provide instructions and demo for your quick start.

The 6GB version supports Nvidia Ampere architecture series graphics cards such as RTX 3070/3080/4080/4090, A100, and so on.

The only thing you need do is to install the following library:

pip install -U bitsandbytes
pip install git+https://github.com/huggingface/diffusers
pip install torch==2.0.0

Then you can enjoy your HunyuanDiT text-to-image journey under 6GB GPU VRAM directly!

Here is a demo for you.

cd HunyuanDiT

# Quick start
model_id=Tencent-Hunyuan/HunyuanDiT-v1.2-Diffusers-Distilled
prompt=一个宇航员在骑马
infer_steps=50
guidance_scale=6
python3 lite/inference.py ${model_id} ${prompt} ${infer_steps} ${guidance_scale}

More details can be found in ./lite.

Using Gradio

Make sure the conda environment is activated before running the following command.

# By default, we start a Chinese UI. Using Flash Attention for acceleration.
python app/hydit_app.py --infer-mode fa

# You can disable the enhancement model if the GPU memory is insufficient.
# The enhancement will be unavailable until you restart the app without the `--no-enhance` flag. 
python app/hydit_app.py --no-enhance --infer-mode fa

# Start with English UI
python app/hydit_app.py --lang en --infer-mode fa

# Start a multi-turn T2I generation UI. 
# If your GPU memory is less than 32GB, use '--load-4bit' to enable 4-bit quantization, which requires at least 22GB of memory.
python app/multiTurnT2I_app.py --infer-mode fa

Then the demo can be accessed through http://0.0.0.0:443. It should be noted that the 0.0.0.0 here needs to be X.X.X.X with your server IP.

Using 🤗 Diffusers

Please install PyTorch version 2.0 or higher in advance to satisfy the requirements of the specified version of the diffusers library.

Install 🤗 diffusers, ensuring that the version is at least 0.28.1:

pip install git+https://github.com/huggingface/diffusers.git

or

pip install diffusers

You can generate images with both Chinese and English prompts using the following Python script:

import torch
from diffusers import HunyuanDiTPipeline

pipe = HunyuanDiTPipeline.from_pretrained("Tencent-Hunyuan/HunyuanDiT-v1.2-Diffusers", torch_dtype=torch.float16)
pipe.to("cuda")

# You may also use English prompt as HunyuanDiT supports both English and Chinese
# prompt = "An astronaut riding a horse"
prompt = "一个宇航员在骑马"
image = pipe(prompt).images[0]

You can use our distilled model to generate images even faster:

import torch
from diffusers import HunyuanDiTPipeline

pipe = HunyuanDiTPipeline.from_pretrained("Tencent-Hunyuan/HunyuanDiT-v1.2-Diffusers-Distilled", torch_dtype=torch.float16)
pipe.to("cuda")

# You may also use English prompt as HunyuanDiT supports both English and Chinese
# prompt = "An astronaut riding a horse"
prompt = "一个宇航员在骑马"
image = pipe(prompt, num_inference_steps=25).images[0]

More details can be found in HunyuanDiT-v1.2-Diffusers-Distilled

More functions: For other functions like LoRA and ControlNet, please have a look at the README of ./diffusers.

Using Command Line

We provide several commands to quick start:

# Only Text-to-Image. Flash Attention mode
python sample_t2i.py --infer-mode fa --prompt "渔舟唱晚" --no-enhance

# Generate an image with other image sizes.
python sample_t2i.py --infer-mode fa --prompt "渔舟唱晚" --image-size 1280 768

# Prompt Enhancement + Text-to-Image. DialogGen loads with 4-bit quantization, but it may loss performance.
python sample_t2i.py --infer-mode fa --prompt "渔舟唱晚"  --load-4bit

More example prompts can be found in example_prompts.txt

More Configurations

We list some more useful configurations for easy usage:

Argument Default Description
--prompt None The text prompt for image generation
--image-size 1024 1024 The size of the generated image
--seed 42 The random seed for generating images
--infer-steps 100 The number of steps for sampling
--negative - The negative prompt for image generation
--infer-mode torch The inference mode (torch, fa, or trt)
--sampler ddpm The diffusion sampler (ddpm, ddim, or dpmms)
--no-enhance False Disable the prompt enhancement model
--model-root ckpts The root directory of the model checkpoints
--load-key ema Load the student model or EMA model (ema or module)
--load-4bit Fasle Load DialogGen model with 4bit quantization

Using ComfyUI

  • Support two workflows: Standard ComfyUI and Diffusers Wrapper, with the former being recommended.
  • Support HunyuanDiT-v1.1 and v1.2.
  • Support module, lora and clip lora models trained by Kohya.
  • Support module, lora models trained by HunyunDiT official training scripts.
  • ControlNet is coming soon.

Workflow More details can be found in ./comfyui-hydit

Using Kohya

We support custom codes for kohya_ss GUI, and sd-scripts training codes for HunyuanDiT. dreambooth More details can be found in ./kohya_ss-hydit

Using Previous versions

  • Hunyuan-DiT <= v1.1
# ============================== v1.1 ==============================
# Download the model
huggingface-cli download Tencent-Hunyuan/HunyuanDiT-v1.1 --local-dir ./HunyuanDiT-v1.1
# Inference with the model
python sample_t2i.py --infer-mode fa --prompt "渔舟唱晚" --model-root ./HunyuanDiT-v1.1 --use-style-cond --size-cond 1024 1024 --beta-end 0.03

# ============================== v1.0 ==============================
# Download the model
huggingface-cli download Tencent-Hunyuan/HunyuanDiT --local-dir ./HunyuanDiT-v1.0
# Inference with the model
python sample_t2i.py --infer-mode fa --prompt "渔舟唱晚" --model-root ./HunyuanDiT-v1.0 --use-style-cond --size-cond 1024 1024 --beta-end 0.03

🏗️ Adapter

ControlNet

We provide training scripts for ControlNet, detailed in the ./controlnet.

# Training for canny ControlNet.
PYTHONPATH=./ sh hydit/train_controlnet.sh

We offer three types of trained ControlNet weights for canny depth and pose, see details at links

cd HunyuanDiT
# Use the huggingface-cli tool to download the model.
# We recommend using distilled weights as the base model for ControlNet inference, as our provided pretrained weights are trained on them.
huggingface-cli download Tencent-Hunyuan/HYDiT-ControlNet-v1.2 --local-dir ./ckpts/t2i/controlnet
huggingface-cli download Tencent-Hunyuan/Distillation-v1.2 ./pytorch_model_distill.pt --local-dir ./ckpts/t2i/model

# Quick start
python3 sample_controlnet.py --infer-mode fa --no-enhance --load-key distill --infer-steps 50 --control-type canny --prompt "在夜晚的酒店门前,一座古老的**风格的狮子雕像矗立着,它的眼睛闪烁着光芒,仿佛在守护着这座建筑。背景是夜晚的酒店前,构图方式是特写,平视,居中构图。这张照片呈现了真实摄影风格,蕴含了**雕塑文化,同时展现了神秘氛围" --condition-image-path controlnet/asset/input/canny.jpg --control-weight 1.0
Condition Input
Canny ControlNet Depth ControlNet Pose ControlNet
在夜晚的酒店门前,一座古老的**风格的狮子雕像矗立着,它的眼睛闪烁着光芒,仿佛在守护着这座建筑。背景是夜晚的酒店前,构图方式是特写,平视,居中构图。这张照片呈现了真实摄影风格,蕴含了**雕塑文化,同时展现了神秘氛围
(At night, an ancient Chinese-style lion statue stands in front of the hotel, its eyes gleaming as if guarding the building. The background is the hotel entrance at night, with a close-up, eye-level, and centered composition. This photo presents a realistic photographic style, embodies Chinese sculpture culture, and reveals a mysterious atmosphere.)
在茂密的森林中,一只黑白相间的熊猫静静地坐在绿树红花中,周围是山川和海洋。背景是白天的森林,光线充足。照片采用特写、平视和居中构图的方式,呈现出写实的效果
(In the dense forest, a black and white panda sits quietly among the green trees and red flowers, surrounded by mountains and oceans. The background is a daytime forest with ample light. The photo uses a close-up, eye-level, and centered composition to create a realistic effect.)
在白天的森林中,一位穿着绿色上衣的亚洲女性站在大象旁边。照片采用了中景、平视和居中构图的方式,呈现出写实的效果。这张照片蕴含了人物摄影文化,并展现了宁静的氛围
(In the daytime forest, an Asian woman wearing a green shirt stands beside an elephant. The photo uses a medium shot, eye-level, and centered composition to create a realistic effect. This picture embodies the character photography culture and conveys a serene atmosphere.)
Image 0 Image 1 Image 2
ControlNet Output
Image 3 Image 4 Image 5

🎨 Hunyuan-Captioner

Hunyuan-Captioner meets the need of text-to-image techniques by maintaining a high degree of image-text consistency. It can generate high-quality image descriptions from a variety of angles, including object description, objects relationships, background information, image style, etc. Our code is based on LLaVA implementation.

Examples

Image 3

Instructions

a. Install dependencies

The dependencies and installation are basically the same as the base model.

b. Model download

# Use the huggingface-cli tool to download the model.
huggingface-cli download Tencent-Hunyuan/HunyuanCaptioner --local-dir ./ckpts/captioner

Inference

Our model supports three different modes including: directly generating Chinese caption, generating Chinese caption based on specific knowledge, and directly generating English caption. The injected information can be either accurate cues or noisy labels (e.g., raw descriptions crawled from the internet). The model is capable of generating reliable and accurate descriptions based on both the inserted information and the image content.

Mode Prompt Template Description
caption_zh 描述这张图片 Caption in Chinese
insert_content 根据提示词“{}”,描述这张图片 Caption with inserted knowledge
caption_en Please describe the content of this image Caption in English

a. Single picture inference in Chinese

python mllm/caption_demo.py --mode "caption_zh" --image_file "mllm/images/demo1.png" --model_path "./ckpts/captioner"

b. Insert specific knowledge into caption

python mllm/caption_demo.py --mode "insert_content" --content "宫保鸡丁" --image_file "mllm/images/demo2.png" --model_path "./ckpts/captioner"

c. Single picture inference in English

python mllm/caption_demo.py --mode "caption_en" --image_file "mllm/images/demo3.png" --model_path "./ckpts/captioner"

d. Multiple pictures inference in Chinese

### Convert multiple pictures to csv file. 
python mllm/make_csv.py --img_dir "mllm/images" --input_file "mllm/images/demo.csv"

### Multiple pictures inference
python mllm/caption_demo.py --mode "caption_zh" --input_file "mllm/images/demo.csv" --output_file "mllm/images/demo_res.csv" --model_path "./ckpts/captioner"

(Optional) To convert the output csv file to Arrow format, please refer to Data Preparation #3 for detailed instructions.

Gradio

To launch a Gradio demo locally, please run the following commands one by one. For more detailed instructions, please refer to LLaVA.

cd mllm
python -m llava.serve.controller --host 0.0.0.0 --port 10000

python -m llava.serve.gradio_web_server --controller http://0.0.0.0:10000 --model-list-mode reload --port 443

python -m llava.serve.model_worker --host 0.0.0.0 --controller http://0.0.0.0:10000 --port 40000 --worker http://0.0.0.0:40000 --model-path "../ckpts/captioner" --model-name LlavaMistral

Then the demo can be accessed through http://0.0.0.0:443. It should be noted that the 0.0.0.0 here needs to be X.X.X.X with your server IP.

🚀 Acceleration (for Linux)

🔗 BibTeX

If you find Hunyuan-DiT or DialogGen useful for your research and applications, please cite using this BibTeX:

@misc{li2024hunyuandit,
      title={Hunyuan-DiT: A Powerful Multi-Resolution Diffusion Transformer with Fine-Grained Chinese Understanding}, 
      author={Zhimin Li and Jianwei Zhang and Qin Lin and Jiangfeng Xiong and Yanxin Long and Xinchi Deng and Yingfang Zhang and Xingchao Liu and Minbin Huang and Zedong Xiao and Dayou Chen and Jiajun He and Jiahao Li and Wenyue Li and Chen Zhang and Rongwei Quan and Jianxiang Lu and Jiabin Huang and Xiaoyan Yuan and Xiaoxiao Zheng and Yixuan Li and Jihong Zhang and Chao Zhang and Meng Chen and Jie Liu and Zheng Fang and Weiyan Wang and Jinbao Xue and Yangyu Tao and Jianchen Zhu and Kai Liu and Sihuan Lin and Yifu Sun and Yun Li and Dongdong Wang and Mingtao Chen and Zhichao Hu and Xiao Xiao and Yan Chen and Yuhong Liu and Wei Liu and Di Wang and Yong Yang and Jie Jiang and Qinglin Lu},
      year={2024},
      eprint={2405.08748},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

@article{huang2024dialoggen,
  title={DialogGen: Multi-modal Interactive Dialogue System for Multi-turn Text-to-Image Generation},
  author={Huang, Minbin and Long, Yanxin and Deng, Xinchi and Chu, Ruihang and Xiong, Jiangfeng and Liang, Xiaodan and Cheng, Hong and Lu, Qinglin and Liu, Wei},
  journal={arXiv preprint arXiv:2403.08857},
  year={2024}
}

Start History

Star History Chart

hunyuandit's People

Contributors

zml-ai avatar jarvis73 avatar xuhuaren avatar

Stargazers

梁庭嘉 avatar XuyaoWang avatar Hongzheng Li avatar Yue avatar  avatar  avatar Asch avatar Zhou Yile avatar  avatar  avatar Guo Jiaxin avatar  avatar Zhang WenYU avatar maxwang967 avatar  avatar  avatar zywgngc avatar Liangsheng Xu avatar Limon avatar  avatar  avatar  avatar  avatar  avatar Haohan Weng avatar Tom Li avatar  avatar ZBRprogrammer avatar Xu Liu avatar Cranyozen avatar Ting Jiang avatar  avatar  avatar  avatar  avatar  avatar yixinzhang avatar louis lin avatar  avatar Alive avatar  avatar Youliang Yuan avatar Darkness avatar  avatar  avatar Bonnie avatar  avatar  avatar  avatar Rodrigoandrigo avatar Tony Nrey avatar LiangChao avatar 逍遥 avatar  avatar Android zhang avatar Zhao Wang avatar  avatar  avatar  avatar  avatar  avatar Wu Junxian avatar Omnioculars avatar  avatar  avatar  avatar  avatar Allen Chen avatar Ken Lo avatar xufeiwu avatar 钟顺民 avatar Sunshiny avatar  avatar  avatar  avatar marlon avatar joangao avatar Elliott Zheng avatar  avatar  avatar Bailin Wu avatar  avatar  avatar Shuai Shao avatar Zheng Chen avatar wjheha avatar  avatar Zhiwen Liu avatar Apple tea avatar  avatar Aryan avatar  avatar han avatar tify4cloud avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

gradetwo avatar jacky avatar  avatar Song avatar  avatar wesily avatar  avatar winning1120xx avatar zhouwg avatar gsong avatar Omar B9 avatar  avatar  avatar  avatar  avatar Peng Du avatar Edward Kamau avatar Tom Claydon avatar  avatar Oli_Zhan avatar Nliver avatar Jukka Seppänen avatar  avatar Mr. Feng avatar 熊叫兽 avatar xiaozhiob avatar  avatar AdaDai avatar 東 avatar  avatar shimomura kei avatar  avatar  avatar

hunyuandit's Issues

httpx.ReadTimeout: timed out

(HunyuanDiT) PS E:\IMAGE\HunyuanDiT> python app/hydit_app.py --no-enhance
flash_attn import failed: No module named 'flash_attn'
2024-05-16 11:42:25.899 | INFO | hydit.inference:init:160 - Got text-to-image model root path: ckpts\t2i
2024-05-16 11:42:25.916 | INFO | hydit.inference:init:172 - Loading CLIP Text Encoder...
2024-05-16 11:42:27.218 | INFO | hydit.inference:init:175 - Loading CLIP Text Encoder finished
2024-05-16 11:42:27.218 | INFO | hydit.inference:init:178 - Loading CLIP Tokenizer...
2024-05-16 11:42:27.242 | INFO | hydit.inference:init:181 - Loading CLIP Tokenizer finished
2024-05-16 11:42:27.242 | INFO | hydit.inference:init:184 - Loading T5 Text Encoder and T5 Tokenizer...
You are using the default legacy behaviour of the <class 'transformers.models.t5.tokenization_t5.T5Tokenizer'>. This is expected, and simply means that the legacy (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set legacy=False. This should only be set if you understand what it means, and thoroughly read the reason why this was added as explained in huggingface/transformers#24565
C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\transformers\convert_slow_tokenizer.py:515: UserWarning: The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option which is not implemented in the fast tokenizers. In practice this means that the fast version of the tokenizer can produce unknown tokens whereas the sentencepiece version would have converted these unknown tokens into a sequence of byte tokens matching the original piece of text.
warnings.warn(
You are using a model of type mt5 to instantiate a model of type t5. This is not supported for all configurations of models and can yield errors.
2024-05-16 11:42:37.485 | INFO | hydit.inference:init:188 - Loading t5_text_encoder and t5_tokenizer finished
2024-05-16 11:42:37.485 | INFO | hydit.inference:init:191 - Loading VAE...
2024-05-16 11:42:37.633 | INFO | hydit.inference:init:194 - Loading VAE finished
2024-05-16 11:42:37.633 | INFO | hydit.inference:init:198 - Building HunYuan-DiT model...
2024-05-16 11:42:37.907 | INFO | hydit.modules.models:init:229 - Number of tokens: 4096
2024-05-16 11:42:46.679 | INFO | hydit.inference:init:218 - Loading model checkpoint ckpts\t2i\model\pytorch_model_ema.pt...
2024-05-16 11:42:48.218 | INFO | hydit.inference:init:229 - Loading inference pipeline...
2024-05-16 11:42:48.233 | INFO | hydit.inference:init:231 - Loading pipeline finished
2024-05-16 11:42:48.233 | INFO | hydit.inference:init:235 - ==================================================
2024-05-16 11:42:48.233 | INFO | hydit.inference:init:236 - Model is ready.
2024-05-16 11:42:48.233 | INFO | hydit.inference:init:237 - ==================================================
Running on local URL: http://0.0.0.0:443
Traceback (most recent call last):
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_transports\default.py", line 69, in map_httpcore_exceptions
yield
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_transports\default.py", line 233, in handle_request
resp = self._pool.handle_request(req)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_sync\connection_pool.py", line 216, in handle_request
raise exc from None
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_sync\connection_pool.py", line 196, in handle_request
response = connection.handle_request(
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_sync\http_proxy.py", line 207, in handle_request
return self._connection.handle_request(proxy_request)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_sync\connection.py", line 101, in handle_request
return self._connection.handle_request(request)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_sync\http11.py", line 143, in handle_request
raise exc
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_sync\http11.py", line 113, in handle_request
) = self._receive_response_headers(**kwargs)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_sync\http11.py", line 186, in _receive_response_headers
event = self._receive_event(timeout=timeout)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_sync\http11.py", line 224, in _receive_event
data = self._network_stream.read(
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_backends\sync.py", line 126, in read
return self._sock.recv(max_bytes)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\contextlib.py", line 131, in exit
self.gen.throw(type, value, traceback)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpcore_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadTimeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "app/hydit_app.py", line 170, in
interface.launch(server_name="0.0.0.0", server_port=443, share=True)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\gradio\blocks.py", line 2351, in launch
and not networking.url_ok(self.local_url)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\gradio\networking.py", line 54, in url_ok
r = httpx.head(url, timeout=3, verify=False)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_api.py", line 278, in head
return request(
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_api.py", line 106, in request
return client.request(
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_client.py", line 827, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_client.py", line 914, in send
response = self._send_handling_auth(
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_client.py", line 942, in _send_handling_auth
response = self._send_handling_redirects(
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_client.py", line 979, in _send_handling_redirects
response = self._send_single_request(request)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_client.py", line 1015, in _send_single_request
response = transport.handle_request(request)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_transports\default.py", line 233, in handle_request
resp = self._pool.handle_request(req)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\contextlib.py", line 131, in exit
self.gen.throw(type, value, traceback)
File "C:\Users\28687.conda\envs\HunyuanDiT\lib\site-packages\httpx_transports\default.py", line 86, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout: timed out

启动 multiTurnT2I_app.py,在UI中输入提示词,点击提交后,出现错误

请问一下,如何解决?
input history:[]
Traceback (most recent call last):
File "G:\AI\ZHB\HunyuanDiT\env\lib\site-packages\gradio\routes.py", line 534, in predict
output = await route_utils.call_process_api(
File "G:\AI\ZHB\HunyuanDiT\env\lib\site-packages\gradio\route_utils.py", line 226, in call_process_api
output = await app.get_blocks().process_api(
File "G:\AI\ZHB\HunyuanDiT\env\lib\site-packages\gradio\blocks.py", line 1550, in process_api
result = await self.call_function(
File "G:\AI\ZHB\HunyuanDiT\env\lib\site-packages\gradio\blocks.py", line 1185, in call_function
prediction = await anyio.to_thread.run_sync(
File "G:\AI\ZHB\HunyuanDiT\env\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "G:\AI\ZHB\HunyuanDiT\env\lib\site-packages\anyio_backends_asyncio.py", line 2144, in run_sync_in_worker_thread
return await future
File "G:\AI\ZHB\HunyuanDiT\env\lib\site-packages\anyio_backends_asyncio.py", line 851, in run
result = context.run(func, *args)
File "G:\AI\ZHB\HunyuanDiT\env\lib\site-packages\gradio\utils.py", line 661, in wrapper
response = f(*args, **kwargs)
File "G:\AI\ZHB\HunyuanDiT\app\multiTurnT2I_app.py", line 115, in pipeline
response, history_messages = enhancer(input_text, return_history=True, history=history_messages, skip_special=False)

RuntimeError: Failed to import transformers.models.clip.image_processing_clip because of the following error (look up to see its traceback): cannot import name 'builder' from 'google.protobuf.internal' (anaconda3/envs/aiimage/lib/python3.10/site-packages/google/protobuf/internal/__init__.py)

  1. What command or script did you run?
python app/hydit_app.py

按照项目依赖使用 protobuf==3.19.0 会报错:

RuntimeError: Failed to import transformers.models.clip.image_processing_clip because of the following error (look up to see its traceback):
cannot import name 'builder' from 'google.protobuf.internal' (anaconda3/envs/aiimage/lib/python3.10/site-packages/google/protobuf/internal/__init__.py)

直接使用 pip install protobuf -U 更新到最新,会出现另外一个错误:

raise RuntimeError(
RuntimeError: Failed to import diffusers.models.autoencoder_kl because of the following error (look up to see its traceback):
module 'torch' has no attribute 'compiler'

Environment

  1. Please run python utils/collect_env.py to collect necessary environment information and paste it here.
sys.platform: linux
Python: 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0: NVIDIA GeForce RTX 4090
CUDA_HOME: /usr/local/cuda-12.1
NVCC: Cuda compilation tools, release 12.1, V12.1.105
GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
PyTorch: 1.13.1+cu117
PyTorch compiling details: PyTorch built with:
  - GCC 9.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.7
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86
  - CuDNN 8.5
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.7, CUDNN_VERSION=8.5.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,

TorchVision: 0.14.1+cu117
OpenCV: 4.7.0

以上问题复现对代码HunyuanDiT/dialoggen/llava/model/init.py简单修复,避免异常被吞掉:

# try:    
#     from .language_model.llava_llama import LlavaLlamaForCausalLM, LlavaConfig
#     from .language_model.llava_mpt import LlavaMptForCausalLM, LlavaMptConfig
#     from .language_model.llava_mistral import LlavaMistralForCausalLM, LlavaMistralConfig
# except:
#     pass

from .language_model.llava_llama import LlavaLlamaForCausalLM, LlavaConfig
from .language_model.llava_mpt import LlavaMptForCausalLM, LlavaMptConfig
from .language_model.llava_mistral import LlavaMistralForCausalLM, LlavaMistralConfig

否则报错为:

ImportError: cannot import name 'LlavaLlamaForCausalLM' from 'llava.model'

Cannot copy out of meta tensor; no data!

error running on windows (wsl)

python app/hydit_app.py --infer-mode fa --lang en

  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/route_utils.py", line 270, in call_process_api
    output = await app.get_blocks().process_api(
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/blocks.py", line 1887, in process_api
    result = await self.call_function(
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/blocks.py", line 1472, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread
    return await future
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 851, in run
    result = context.run(func, *args)
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/utils.py", line 808, in wrapper
    response = f(*args, **kwargs)
  File "app/hydit_app.py", line 42, in infer
    success, enhanced_prompt = enhancer(prompt)
  File "/home/user/HunyuanDiT/./dialoggen/dialoggen_demo.py", line 145, in __call__
    enhanced_prompt = eval_model(
  File "/home/user/HunyuanDiT/./dialoggen/dialoggen_demo.py", line 113, in eval_model
    output_ids = models["model"].generate(
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/home/user/HunyuanDiT/dialoggen/llava/model/language_model/llava_mistral.py", line 125, in generate
    ) = self.prepare_inputs_labels_for_multimodal(
  File "/home/user/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 157, in prepare_inputs_labels_for_multimodal
    image_features = self.encode_images(concat_images)
  File "/home/user/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 141, in encode_images
    image_features = self.get_model().get_vision_tower()(images)
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 166, in new_forward
    output = module._old_forward(*args, **kwargs)
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/home/user/HunyuanDiT/dialoggen/llava/model/multimodal_encoder/clip_encoder.py", line 54, in forward
    image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype), output_hidden_states=True)
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 161, in new_forward
    args, kwargs = module._hf_hook.pre_forward(module, *args, **kwargs)
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 356, in pre_forward
    return send_to_device(args, self.execution_device), send_to_device(
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 180, in send_to_device
    return honor_type(
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 81, in honor_type
    return type(obj)(generator)
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 181, in <genexpr>
    tensor, (send_to_device(t, device, non_blocking=non_blocking, skip_keys=skip_keys) for t in tensor)
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 174, in send_to_device
    raise error
  File "/home/user/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 158, in send_to_device
    return tensor.to(device, non_blocking=non_blocking)
NotImplementedError: Cannot copy out of meta tensor; no data!```

关于推理速度

默认的推理采样步数是100,但是每一步采样速度很慢,比sd1.5/sdxl慢的多,导致生成图片很慢,生成一张图片需要1分半的时间
测试显卡是3090,没有使用flash-attn,这个是正常的吗
采样步数必须是100这么大吗,sd1.5/sdxl的20步生成质量是否会下降很多?我测试生成几张图片好像效果差不多

魔搭上下载的模型不行,缺文件

2024-05-16 03:24:16.542 | INFO     | hydit.inference:__init__:160 - Got text-to-image model root path: ckpts/t2i
2024-05-16 03:24:21.606 | INFO     | hydit.inference:__init__:172 - Loading CLIP Text Encoder...
2024-05-16 03:24:24.485 | INFO     | hydit.inference:__init__:175 - Loading CLIP Text Encoder finished
2024-05-16 03:24:24.485 | INFO     | hydit.inference:__init__:178 - Loading CLIP Tokenizer...
2024-05-16 03:24:24.675 | INFO     | hydit.inference:__init__:181 - Loading CLIP Tokenizer finished
2024-05-16 03:24:24.675 | INFO     | hydit.inference:__init__:184 - Loading T5 Text Encoder and T5 Tokenizer...
You are using the default legacy behaviour of the <class 'transformers.models.t5.tokenization_t5.T5Tokenizer'>. This is expected, and simply means that the `legacy` (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set `legacy=False`. This should only be set if you understand what it means, and thoroughly read the reason why this was added as explained in https://github.com/huggingface/transformers/pull/24565
/usr/python/lib/python3.9/site-packages/transformers/convert_slow_tokenizer.py:515: UserWarning: The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option which is not implemented in the fast tokenizers. In practice this means that the fast version of the tokenizer can produce unknown tokens whereas the sentencepiece version would have converted these unknown tokens into a sequence of byte tokens matching the original piece of text.
  warnings.warn(
You are using a model of type mt5 to instantiate a model of type t5. This is not supported for all configurations of models and can yield errors.
2024-05-16 03:24:40.931 | INFO     | hydit.inference:__init__:188 - Loading t5_text_encoder and t5_tokenizer finished
2024-05-16 03:24:40.932 | INFO     | hydit.inference:__init__:191 - Loading VAE...
2024-05-16 03:24:41.118 | INFO     | hydit.inference:__init__:194 - Loading VAE finished
2024-05-16 03:24:41.118 | INFO     | hydit.inference:__init__:198 - Building HunYuan-DiT model...
2024-05-16 03:24:41.666 | INFO     | hydit.modules.models:__init__:229 -     Number of tokens: 4096
2024-05-16 03:24:57.888 | INFO     | hydit.inference:__init__:218 - Loading model checkpoint ckpts/t2i/model/pytorch_model_ema.pt...
2024-05-16 03:25:00.776 | INFO     | hydit.inference:__init__:229 - Loading inference pipeline...
2024-05-16 03:25:00.796 | INFO     | hydit.inference:__init__:231 - Loading pipeline finished
2024-05-16 03:25:00.797 | INFO     | hydit.inference:__init__:235 - ==================================================
2024-05-16 03:25:00.797 | INFO     | hydit.inference:__init__:236 -                 Model is ready.                  
2024-05-16 03:25:00.797 | INFO     | hydit.inference:__init__:237 - ==================================================
2024-05-16 03:25:00.823 | INFO     | sample_t2i:inferencer:21 - Loading DialogGen model (for prompt enhancement)...
/usr/python/lib/python3.9/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
  warnings.warn(
Traceback (most recent call last):
  File "/usr/python/lib/python3.9/site-packages/urllib3/connection.py", line 198, in _new_conn
    sock = connection.create_connection(
  File "/usr/python/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection
    raise err
  File "/usr/python/lib/python3.9/site-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
OSError: [Errno 101] Network is unreachable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/python/lib/python3.9/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
  File "/usr/python/lib/python3.9/site-packages/urllib3/connectionpool.py", line 491, in _make_request
    raise new_e
  File "/usr/python/lib/python3.9/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    self._validate_conn(conn)
  File "/usr/python/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1099, in _validate_conn
    conn.connect()
  File "/usr/python/lib/python3.9/site-packages/urllib3/connection.py", line 616, in connect
    self.sock = sock = self._new_conn()
  File "/usr/python/lib/python3.9/site-packages/urllib3/connection.py", line 213, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fbfbc7e47c0>: Failed to establish a new connection: [Errno 101] Network is unreachable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/python/lib/python3.9/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/usr/python/lib/python3.9/site-packages/urllib3/connectionpool.py", line 847, in urlopen
    retries = retries.increment(
  File "/usr/python/lib/python3.9/site-packages/urllib3/util/retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /openai/clip-vit-large-patch14-336/resolve/main/preprocessor_config.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fbfbc7e47c0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1722, in _get_metadata_or_catch_error
    metadata = get_hf_file_metadata(url=url, proxies=proxies, timeout=etag_timeout, headers=headers)
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1645, in get_hf_file_metadata
    r = _request_wrapper(
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 372, in _request_wrapper
    response = _request_wrapper(
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 395, in _request_wrapper
    response = get_session().request(method=method, url=url, **params)
  File "/usr/python/lib/python3.9/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/python/lib/python3.9/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/utils/_http.py", line 66, in send
    return super().send(request, *args, **kwargs)
  File "/usr/python/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /openai/clip-vit-large-patch14-336/resolve/main/preprocessor_config.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fbfbc7e47c0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))"), '(Request ID: 2150ae95-4931-46f6-85fd-b17bbbe82b7c)')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/python/lib/python3.9/site-packages/transformers/utils/hub.py", line 385, in cached_file
    resolved_file = hf_hub_download(
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1221, in hf_hub_download
    return _hf_hub_download_to_cache_dir(
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1325, in _hf_hub_download_to_cache_dir
    _raise_on_head_call_error(head_call_error, force_download, local_files_only)
  File "/usr/python/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1826, in _raise_on_head_call_error
    raise LocalEntryNotFoundError(
huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/tti/HunyuanDiT/./app/hydit_api.py", line 34, in <module>
    args, gen, enhancer = inferencer()
  File "/data/tti/HunyuanDiT/sample_t2i.py", line 22, in inferencer
    enhancer = DialogGen(str(models_root_path / "dialoggen"))
  File "/data/tti/HunyuanDiT/dialoggen/dialoggen_demo.py", line 141, in __init__
    self.models = init_dialoggen_model(model_path)
  File "/data/tti/HunyuanDiT/dialoggen/dialoggen_demo.py", line 55, in init_dialoggen_model
    tokenizer, model, image_processor, context_len = load_pretrained_model(
  File "/data/tti/HunyuanDiT/dialoggen/llava/model/builder.py", line 142, in load_pretrained_model
    model = AutoModelForCausalLM.from_pretrained(model_path, low_cpu_mem_usage=True, **kwargs)
  File "/usr/python/lib/python3.9/site-packages/transformers/models/auto/auto_factory.py", line 566, in from_pretrained
    return model_class.from_pretrained(
  File "/usr/python/lib/python3.9/site-packages/transformers/modeling_utils.py", line 3594, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
  File "/data/tti/HunyuanDiT/dialoggen/llava/model/language_model/llava_mistral.py", line 47, in __init__
    self.model = LlavaMistralModel(config)
  File "/data/tti/HunyuanDiT/dialoggen/llava/model/language_model/llava_mistral.py", line 39, in __init__
    super(LlavaMistralModel, self).__init__(config)
  File "/data/tti/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 35, in __init__
    self.vision_tower = build_vision_tower(config, delay_load=True)
  File "/data/tti/HunyuanDiT/dialoggen/llava/model/multimodal_encoder/builder.py", line 9, in build_vision_tower
    return CLIPVisionTower(vision_tower, args=vision_tower_cfg, **kwargs)
  File "/data/tti/HunyuanDiT/dialoggen/llava/model/multimodal_encoder/clip_encoder.py", line 20, in __init__
    self.load_model()
  File "/data/tti/HunyuanDiT/dialoggen/llava/model/multimodal_encoder/clip_encoder.py", line 29, in load_model
    self.image_processor = CLIPImageProcessor.from_pretrained(self.vision_tower_name)
  File "/usr/python/lib/python3.9/site-packages/transformers/image_processing_utils.py", line 206, in from_pretrained
    image_processor_dict, kwargs = cls.get_image_processor_dict(pretrained_model_name_or_path, **kwargs)
  File "/usr/python/lib/python3.9/site-packages/transformers/image_processing_utils.py", line 335, in get_image_processor_dict
    resolved_image_processor_file = cached_file(
  File "/usr/python/lib/python3.9/site-packages/transformers/utils/hub.py", line 425, in cached_file
    raise EnvironmentError(
OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like openai/clip-vit-large-patch14-336 is not the path to a directory containing a file named preprocessor_config.json.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

看样子需要openai/clip-vit-large-patch14-336,配置文件里面确实有:

  "mm_vision_tower": "openai/clip-vit-large-patch14-336",

有点潦草。

Will the training code be public?

Great work! I am trying to do some finetuneing tasks on your work and was wondering if you could share your training code? I'm particularly interested in how you calculate loss and choose the scheduler.
I noticed your prediction pipeline outputs sigma, but the DDPM scheduler you're using doesn't seem to have this option. Can you help me solve this question?

Thanks in advance for your help!

how to run HunyuanDiT model locally with llama.cpp?

thanks for Tencent's amazing HunyuanDiT(it's very cool in "Hunyuan Assistant(aka 混元助手)" as a Wechat Mini App(aka Wechat Xiaochengxu or 微信小程序)).

  1. could you provide tutorial to illustrate how to run HunyuanDiT model locally with llama.cpp(similar to following tutorial:https://huggingface.co/01-ai/Yi-6B-Chat-8bits#quick-start---llamacpp)?

    or provide tutorial to illustrate how to run HunyuanDiT model locally with Tencent's NCNN?

  2. is there any plan to release a GPT-4o style model of the HunyuanDiT model(ASR, TTS, Text2Image, LLM......in a single HunyuanDiT model)?

thanks so much.

_pickle.UnpicklingError: Weights only load failed. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution.Do it only if you get the file from a trusted source. WeightsUnpickler error: Unsupported operand 118

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version.

Describe the bug
A clear and concise description of what the bug is.

Reproduction

  1. What command or script did you run?
A placeholder for the command.
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
  2. What dataset did you use?

Environment

  1. Please run python utils/collect_env.py to collect necessary environment information and paste it here.
  2. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback
If applicable, paste the error trackback here.

A placeholder for trackback.

Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

我在colab中运行你们huggingface空间和给出的安装步骤也试了一遍,报错,另外你们这个有精简的版本吗?硬盘和内存我估计会占用很大

运行python app.py 报错
Fetching 39 files: 100% 39/39 [00:00<00:00, 40.28it/s]
Traceback (most recent call last):
File "/content/HunyuanDiT/app.py", line 17, in
from sample_t2i import inferencer
File "/content/HunyuanDiT/sample_t2i.py", line 5, in
from dialoggen.dialoggen_demo import DialogGen
File "/content/HunyuanDiT/dialoggen/dialoggen_demo.py", line 9, in
from llava.constants import (
File "/content/HunyuanDiT/dialoggen/llava/init.py", line 1, in
from .model import LlavaLlamaForCausalLM
ImportError: cannot import name 'LlavaLlamaForCausalLM' from 'llava.model' (/content/HunyuanDiT/dialoggen/llava/model/init.py)

NotImplementedError: Cannot copy out of meta tensor; no data!

运行python sample_t2i.py --prompt "渔舟唱晚" 报错,下面是错误信息,请问怎么解决呀,网上没找到解决方案,谢谢。下面是错误信息。
flash_attn import failed: No module named 'flash_attn'
2024-05-17 09:22:52.036 | INFO | hydit.inference:init:160 - Got text-to-image model root path: ckpts/t2i
2024-05-17 09:22:52.061 | INFO | hydit.inference:init:172 - Loading CLIP Text Encoder...
2024-05-17 09:22:56.856 | INFO | hydit.inference:init:175 - Loading CLIP Text Encoder finished
2024-05-17 09:22:56.856 | INFO | hydit.inference:init:178 - Loading CLIP Tokenizer...
2024-05-17 09:22:56.890 | INFO | hydit.inference:init:181 - Loading CLIP Tokenizer finished
2024-05-17 09:22:56.891 | INFO | hydit.inference:init:184 - Loading T5 Text Encoder and T5 Tokenizer...
You are using the default legacy behaviour of the <class 'transformers.models.t5.tokenization_t5.T5Tokenizer'>. This is expected, and simply means that the legacy (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set legacy=False. This should only be set if you understand what it means, and thoroughly read the reason why this was added as explained in huggingface/transformers#24565
/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/transformers/convert_slow_tokenizer.py:515: UserWarning: The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option which is not implemented in the fast tokenizers. In practice this means that the fast version of the tokenizer can produce unknown tokens whereas the sentencepiece version would have converted these unknown tokens into a sequence of byte tokens matching the original piece of text.
warnings.warn(
You are using a model of type mt5 to instantiate a model of type t5. This is not supported for all configurations of models and can yield errors.
2024-05-17 09:23:21.105 | INFO | hydit.inference:init:188 - Loading t5_text_encoder and t5_tokenizer finished
2024-05-17 09:23:21.106 | INFO | hydit.inference:init:191 - Loading VAE...
2024-05-17 09:23:21.462 | INFO | hydit.inference:init:194 - Loading VAE finished
2024-05-17 09:23:21.462 | INFO | hydit.inference:init:198 - Building HunYuan-DiT model...
2024-05-17 09:23:21.828 | INFO | hydit.modules.models:init:229 - Number of tokens: 4096
2024-05-17 09:23:34.236 | INFO | hydit.inference:init:218 - Loading model checkpoint ckpts/t2i/model/pytorch_model_ema.pt...
2024-05-17 09:23:38.890 | INFO | hydit.inference:init:229 - Loading inference pipeline...
2024-05-17 09:23:38.927 | INFO | hydit.inference:init:231 - Loading pipeline finished
2024-05-17 09:23:38.927 | INFO | hydit.inference:init:235 - ==================================================
2024-05-17 09:23:38.927 | INFO | hydit.inference:init:236 - Model is ready.
2024-05-17 09:23:38.927 | INFO | hydit.inference:init:237 - ==================================================
2024-05-17 09:23:39.014 | INFO | main:inferencer:21 - Loading DialogGen model (for prompt enhancement)...
/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: resume_download is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use force_download=True.
warnings.warn(
/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/modeling.py:1363: UserWarning: Current model requires 318774152 bytes of buffer for offloaded layers, which seems does not fit any GPU's remaining memory. If you are experiencing a OOM later, please consider using offload_buffers=True.
warnings.warn(
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:04<00:00, 1.23s/it]
WARNING:root:Some parameters are on the meta device device because they were offloaded to the cpu.
2024-05-17 09:24:16.579 | INFO | main:inferencer:23 - DialogGen model loaded.
2024-05-17 09:24:16.579 | INFO | main::34 - Prompt Enhancement...
Traceback (most recent call last):
File "sample_t2i.py", line 35, in
success, enhanced_prompt = enhancer(args.prompt)
File "/home/hxt/LLM/Tencent-HunyuanDit/HunyuanDiT/dialoggen/dialoggen_demo.py", line 145, in call
enhanced_prompt = eval_model(
File "/home/hxt/LLM/Tencent-HunyuanDit/HunyuanDiT/dialoggen/dialoggen_demo.py", line 113, in eval_model
output_ids = models["model"].generate(
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/home/hxt/LLM/Tencent-HunyuanDit/HunyuanDiT/dialoggen/llava/model/language_model/llava_mistral.py", line 125, in generate
) = self.prepare_inputs_labels_for_multimodal(
File "/home/hxt/LLM/Tencent-HunyuanDit/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 157, in prepare_inputs_labels_for_multimodal
image_features = self.encode_images(concat_images)
File "/home/hxt/LLM/Tencent-HunyuanDit/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 141, in encode_images
image_features = self.get_model().get_vision_tower()(images)
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 166, in new_forward
output = module._old_forward(*args, **kwargs)
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/home/hxt/LLM/Tencent-HunyuanDit/HunyuanDiT/dialoggen/llava/model/multimodal_encoder/clip_encoder.py", line 54, in forward
image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype), output_hidden_states=True)
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 161, in new_forward
args, kwargs = module._hf_hook.pre_forward(module, *args, **kwargs)
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 356, in pre_forward
return send_to_device(args, self.execution_device), send_to_device(
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 180, in send_to_device
return honor_type(
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 81, in honor_type
return type(obj)(generator)
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 181, in
tensor, (send_to_device(t, device, non_blocking=non_blocking, skip_keys=skip_keys) for t in tensor)
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 174, in send_to_device
raise error
File "/home/hxt/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 158, in send_to_device
return tensor.to(device, non_blocking=non_blocking)
NotImplementedError: Cannot copy out of meta tensor; no data!

Cannot copy out of meta tensor; no data!

#==================================================================

运行以下命令,修改了 server_port=8192,share=False

python app/hydit_app.py

#==================================================================

环境

sys.platform: linux
Python: 3.8.12 (default, Oct 12 2021, 13:49:34) [GCC 7.5.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0: NVIDIA GeForce RTX 3090
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 11.8, V11.8.89
GCC: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
PyTorch: 1.13.1
PyTorch compiling details: PyTorch built with:

  • GCC 9.3
  • C++ Version: 201402
  • Intel(R) oneAPI Math Kernel Library Version 2022.1-Product Build 20220311 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  • OpenMP 201511 (a.k.a. OpenMP 4.5)
  • LAPACK is enabled (usually provided by MKL)
  • NNPACK is enabled
  • CPU capability usage: AVX2
  • CUDA Runtime 11.7
  • NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
  • CuDNN 8.5
  • Magma 2.6.1
  • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.7, CUDNN_VERSION=8.5.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,

TorchVision: 0.14.1+cu117

#==================================================================

错误

Traceback (most recent call last):
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/queueing.py", line 527, in process_events
response = await route_utils.call_process_api(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/route_utils.py", line 270, in call_process_api
output = await app.get_blocks().process_api(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/blocks.py", line 1887, in process_api
result = await self.call_function(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/blocks.py", line 1472, in call_function
prediction = await anyio.to_thread.run_sync(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread
return await future
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 851, in run
result = context.run(func, *args)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/utils.py", line 808, in wrapper
response = f(*args, **kwargs)
File "app/hydit_app.py", line 42, in infer
success, enhanced_prompt = enhancer(prompt)
File "/root/autodl-tmp/HunyuanDiT/./dialoggen/dialoggen_demo.py", line 145, in call
enhanced_prompt = eval_model(
File "/root/autodl-tmp/HunyuanDiT/./dialoggen/dialoggen_demo.py", line 113, in eval_model
output_ids = models["model"].generate(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/root/autodl-tmp/HunyuanDiT/dialoggen/llava/model/language_model/llava_mistral.py", line 125, in generate
) = self.prepare_inputs_labels_for_multimodal(
File "/root/autodl-tmp/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 157, in prepare_inputs_labels_for_multimodal
image_features = self.encode_images(concat_images)
File "/root/autodl-tmp/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 141, in encode_images
image_features = self.get_model().get_vision_tower()(images)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 166, in new_forward
output = module._old_forward(*args, **kwargs)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/root/autodl-tmp/HunyuanDiT/dialoggen/llava/model/multimodal_encoder/clip_encoder.py", line 54, in forward
image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype), output_hidden_states=True)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 161, in new_forward
args, kwargs = module._hf_hook.pre_forward(module, *args, **kwargs)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 356, in pre_forward
return send_to_device(args, self.execution_device), send_to_device(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 180, in send_to_device
return honor_type(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 81, in honor_type
return type(obj)(generator)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 181, in
tensor, (send_to_device(t, device, non_blocking=non_blocking, skip_keys=skip_keys) for t in tensor)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 174, in send_to_device
raise error
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 158, in send_to_device
return tensor.to(device, non_blocking=non_blocking)
NotImplementedError: Cannot copy out of meta tensor; no data!

关于app推理里的seed设置

Thanks for your error report and we appreciate it a lot.

目前设置的seed范围为0-2^32-1,好像是设置不了-1随机种子

请问为什么添加flash加速后,就会出现The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results. Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version.

Describe the bug
A clear and concise description of what the bug is.

Reproduction

  1. What command or script did you run?
A placeholder for the command.
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
  2. What dataset did you use?

Environment

  1. Please run python utils/collect_env.py to collect necessary environment information and paste it here.
  2. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback
If applicable, paste the error trackback here.

A placeholder for trackback.

Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

Text Rendering Ability (文字渲染能力)

image
image
image
image
image
image
image
SD3

Describe the feature

Motivation
A clear and concise description of the motivation of the feature.
Ex1. It is inconvenient when [....].
Ex2. There is a recent paper [....], which is very helpful for [....].

Related resources
If there is an official code release or third-party implementations, please also provide the information here, which would be very helpful.

Additional context
Add any other context or screenshots about the feature request here.
If you would like to implement the feature and create a PR, please leave a comment here and that would be much appreciated.

Could not generate image successfully that using sample commands in the README

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version.

Describe the bug
Got unexpected exception while run hunyuanDiT to generate image from prompt, as:
(HunyuanDiT) root@dsw-459611-54645bc446-tbxrv:/mnt/workspace/HunyuanDiT# python sample_t2i.py --infer-mode fa --prompt "我站在北高峰上 ,身后的 阳光洒向半山腰的茶园,金光闪闪,映射出灵隐寺佛光普照,一片宁静祥和!"
2024-05-15 16:36:30.564 | INFO | hydit.inference:init:160 - Got text-to-image model root path: ckpts/t2i
2024-05-15 16:36:30.564 | INFO | hydit.inference:init:172 - Loading CLIP Text Encoder...
2024-05-15 16:36:41.217 | INFO | hydit.inference:init:175 - Loading CLIP Text Encoder finished
2024-05-15 16:36:41.217 | INFO | hydit.inference:init:178 - Loading CLIP Tokenizer...
2024-05-15 16:36:41.252 | INFO | hydit.inference:init:181 - Loading CLIP Tokenizer finished
2024-05-15 16:36:41.253 | INFO | hydit.inference:init:184 - Loading T5 Text Encoder and T5 Tokenizer...
You are using the default legacy behaviour of the <class 'transformers.models.t5.tokenization_t5.T5Tokenizer'>. This is expected, and simply means that the legacy (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set legacy=False. This should only be set if you understand what it means, and thoroughly read the reason why this was added as explained in huggingface/transformers#24565
/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/transformers/convert_slow_tokenizer.py:515: UserWarning: The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option which is not implemented in the fast tokenizers. In practice this means that the fast version of the tokenizer can produce unknown tokens whereas the sentencepiece version would have converted these unknown tokens into a sequence of byte tokens matching the original piece of text.
warnings.warn(
You are using a model of type mt5 to instantiate a model of type t5. This is not supported for all configurations of models and can yield errors.
2024-05-15 16:38:02.836 | INFO | hydit.inference:init:188 - Loading t5_text_encoder and t5_tokenizer finished
2024-05-15 16:38:02.838 | INFO | hydit.inference:init:191 - Loading VAE...
2024-05-15 16:38:03.637 | INFO | hydit.inference:init:194 - Loading VAE finished
2024-05-15 16:38:03.637 | INFO | hydit.inference:init:198 - Building HunYuan-DiT model...
2024-05-15 16:38:03.810 | INFO | hydit.modules.models:init:196 - Enable Flash Attention.
2024-05-15 16:38:04.175 | INFO | hydit.modules.models:init:229 - Number of tokens: 4096
2024-05-15 16:38:19.334 | INFO | hydit.inference:init:218 - Loading model checkpoint ckpts/t2i/model/pytorch_model_ema.pt...
2024-05-15 16:38:35.411 | INFO | hydit.inference:init:229 - Loading inference pipeline...
2024-05-15 16:38:35.434 | INFO | hydit.inference:init:231 - Loading pipeline finished
2024-05-15 16:38:35.434 | INFO | hydit.inference:init:235 - ==================================================
2024-05-15 16:38:35.435 | INFO | hydit.inference:init:236 - Model is ready.
2024-05-15 16:38:35.435 | INFO | hydit.inference:init:237 - ==================================================
2024-05-15 16:38:35.530 | INFO | main:inferencer:21 - Loading DialogGen model (for prompt enhancement)...
/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: resume_download is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use force_download=True.
warnings.warn(
preprocessor_config.json: 100%|█████████████████████████████████████████████████████████████████████████████████| 316/316 [00:00<00:00, 326kB/s]
config.json: 4.76kB [00:00, 2.20MB/s]
pytorch_model.bin: 100%|███████████████████████████████████████████████████████████████████████████████████| 1.71G/1.71G [09:12<00:00, 3.10MB/s]
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████| 4/4 [00:32<00:00, 8.08s/it]
WARNING:root:Some parameters are on the meta device device because they were offloaded to the cpu.
2024-05-15 16:48:25.063 | INFO | main:inferencer:23 - DialogGen model loaded.
2024-05-15 16:48:25.063 | INFO | main::34 - Prompt Enhancement...
Traceback (most recent call last):
File "sample_t2i.py", line 35, in
success, enhanced_prompt = enhancer(args.prompt)
File "/mnt/workspace/HunyuanDiT/dialoggen/dialoggen_demo.py", line 145, in call
enhanced_prompt = eval_model(
File "/mnt/workspace/HunyuanDiT/dialoggen/dialoggen_demo.py", line 113, in eval_model
output_ids = models["model"].generate(
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/mnt/workspace/HunyuanDiT/dialoggen/llava/model/language_model/llava_mistral.py", line 125, in generate
) = self.prepare_inputs_labels_for_multimodal(
File "/mnt/workspace/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 157, in prepare_inputs_labels_for_multimodal
image_features = self.encode_images(concat_images)
File "/mnt/workspace/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 141, in encode_images
image_features = self.get_model().get_vision_tower()(images)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 166, in new_forward
output = module._old_forward(*args, **kwargs)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/mnt/workspace/HunyuanDiT/dialoggen/llava/model/multimodal_encoder/clip_encoder.py", line 54, in forward
image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype), output_hidden_states=True)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 161, in new_forward
args, kwargs = module._hf_hook.pre_forward(module, *args, **kwargs)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 356, in pre_forward
return send_to_device(args, self.execution_device), send_to_device(
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 180, in send_to_device
return honor_type(
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 81, in honor_type
return type(obj)(generator)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 181, in
tensor, (send_to_device(t, device, non_blocking=non_blocking, skip_keys=skip_keys) for t in tensor)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 174, in send_to_device
raise error
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 158, in send_to_device
return tensor.to(device, non_blocking=non_blocking)
NotImplementedError: Cannot copy out of meta tensor; no data!

Reproduction

  1. What command or script did you run?

python sample_t2i.py --infer-mode fa --prompt "我站在北高峰上 ,身后的 阳光洒向半山腰的茶园,金光闪闪,映射出灵隐寺佛光普照,一片宁静祥和!"

  1. Did you make any modifications on the code or config? Did you understand what you have modified?
    No any change happened.

  2. What dataset did you use?
    No specified dataset used.

Environment

  1. Please run python utils/collect_env.py to collect necessary environment information and paste it here.

sys.platform: linux
Python: 3.8.12 (default, Oct 12 2021, 13:49:34) [GCC 7.5.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0: NVIDIA A10
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.1, V12.1.105
GCC: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
PyTorch: 1.13.1
PyTorch compiling details: PyTorch built with:

  • GCC 9.3
  • C++ Version: 201402
  • Intel(R) oneAPI Math Kernel Library Version 2022.1-Product Build 20220311 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  • OpenMP 201511 (a.k.a. OpenMP 4.5)
  • LAPACK is enabled (usually provided by MKL)
  • NNPACK is enabled
  • CPU capability usage: AVX2
  • CUDA Runtime 11.7
  • NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
  • CuDNN 8.5
  • Magma 2.6.1
  • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.7, CUDNN_VERSION=8.5.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,

TorchVision: 0.14.1+cu117

  1. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

All installations are followed README.md.

Error traceback
If applicable, paste the error trackback here.

WARNING:root:Some parameters are on the meta device device because they were offloaded to the cpu.
2024-05-15 16:48:25.063 | INFO | main:inferencer:23 - DialogGen model loaded.
2024-05-15 16:48:25.063 | INFO | main::34 - Prompt Enhancement...
Traceback (most recent call last):
File "sample_t2i.py", line 35, in
success, enhanced_prompt = enhancer(args.prompt)
File "/mnt/workspace/HunyuanDiT/dialoggen/dialoggen_demo.py", line 145, in call
enhanced_prompt = eval_model(
File "/mnt/workspace/HunyuanDiT/dialoggen/dialoggen_demo.py", line 113, in eval_model
output_ids = models["model"].generate(
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/mnt/workspace/HunyuanDiT/dialoggen/llava/model/language_model/llava_mistral.py", line 125, in generate
) = self.prepare_inputs_labels_for_multimodal(
File "/mnt/workspace/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 157, in prepare_inputs_labels_for_multimodal
image_features = self.encode_images(concat_images)
File "/mnt/workspace/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 141, in encode_images
image_features = self.get_model().get_vision_tower()(images)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 166, in new_forward
output = module._old_forward(*args, **kwargs)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/mnt/workspace/HunyuanDiT/dialoggen/llava/model/multimodal_encoder/clip_encoder.py", line 54, in forward
image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype), output_hidden_states=True)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 161, in new_forward
args, kwargs = module._hf_hook.pre_forward(module, *args, **kwargs)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/hooks.py", line 356, in pre_forward
return send_to_device(args, self.execution_device), send_to_device(
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 180, in send_to_device
return honor_type(
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 81, in honor_type
return type(obj)(generator)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 181, in
tensor, (send_to_device(t, device, non_blocking=non_blocking, skip_keys=skip_keys) for t in tensor)
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 174, in send_to_device
raise error
File "/opt/conda/envs/HunyuanDiT/lib/python3.8/site-packages/accelerate/utils/operations.py", line 158, in send_to_device
return tensor.to(device, non_blocking=non_blocking)
NotImplementedError: Cannot copy out of meta tensor; no data!

Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

直接运行:ImportError: cannot import name 'LlavaLlamaForCausalLM' from 'llava.model'

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version.

Describe the bug
A clear and concise description of what the bug is.

Reproduction

  1. What command or script did you run?
A placeholder for the command.
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
  2. What dataset did you use?

Environment

  1. Please run python utils/collect_env.py to collect necessary environment information and paste it here.
  2. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback
If applicable, paste the error trackback here.

A placeholder for trackback.

Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'

尝试了修改为CPU模式下运行,能改的地方都改了,改到这里无处可改了,llava相关代码都已经默认指定了用CPU,但不知道为啥还是有问题……

Traceback (most recent call last):
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/queueing.py", line 527, in process_events
response = await route_utils.call_process_api(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/route_utils.py", line 270, in call_process_api
output = await app.get_blocks().process_api(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/blocks.py", line 1887, in process_api
result = await self.call_function(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/blocks.py", line 1472, in call_function
prediction = await anyio.to_thread.run_sync(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread
return await future
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 851, in run
result = context.run(func, *args)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/gradio/utils.py", line 808, in wrapper
response = f(*args, **kwargs)
File "app/hydit_app.py", line 42, in infer
success, enhanced_prompt = enhancer(prompt)
File "/HunyuanDiT/./dialoggen/dialoggen_demo.py", line 146, in call
enhanced_prompt = eval_model(
File "/HunyuanDiT/./dialoggen/dialoggen_demo.py", line 114, in eval_model
output_ids = models["model"].generate(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/HunyuanDiT/dialoggen/llava/model/language_model/llava_mistral.py", line 125, in generate
) = self.prepare_inputs_labels_for_multimodal(
File "/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 157, in prepare_inputs_labels_for_multimodal
image_features = self.encode_images(concat_images)
File "/HunyuanDiT/dialoggen/llava/model/llava_arch.py", line 141, in encode_images
image_features = self.get_model().get_vision_tower()(images)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/HunyuanDiT/dialoggen/llava/model/multimodal_encoder/clip_encoder.py", line 54, in forward
image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype), output_hidden_states=True)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py", line 917, in forward
return self.vision_model(
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py", line 841, in forward
hidden_states = self.embeddings(pixel_values)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(input, **kwargs)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py", line 182, in forward
patch_embeds = self.patch_embedding(pixel_values.to(dtype=target_dtype)) # shape = [
, width, grid, grid]
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 463, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/root/miniconda3/envs/HunyuanDiT/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'

NotImplementedError: Cannot copy out of meta tensor; no data

File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl
return forward_call(*args, **kwargs)
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\accelerate\hooks.py", line 166, in new_forward
output = module._old_forward(*args, **kwargs)
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\conda_pro\HunyuanDiT-main/dialoggen\llava\model\multimodal_encoder\clip_encoder.py", line 54, in forward
image_forward_outs = self.vision_tower(images.to(device=self.device, dtype=self.dtype), output_hidden_states=True)
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl
return forward_call(*args, **kwargs)
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\accelerate\hooks.py", line 161, in new_forward
args, kwargs = module._hf_hook.pre_forward(module, *args, **kwargs)
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\accelerate\hooks.py", line 356, in pre_forward
return send_to_device(args, self.execution_device), send_to_device(
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\accelerate\utils\operations.py", line 180, in send_to_device
return honor_type(
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\accelerate\utils\operations.py", line 81, in honor_type
return type(obj)(generator)
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\accelerate\utils\operations.py", line 181, in
tensor, (send_to_device(t, device, non_blocking=non_blocking, skip_keys=skip_keys) for t in tensor)
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\accelerate\utils\operations.py", line 174, in send_to_device
raise error
File "D:\sofa\anaconda\envs\HunyuanDiT\lib\site-packages\accelerate\utils\operations.py", line 158, in send_to_device
return tensor.to(device, non_blocking=non_blocking)
NotImplementedError: Cannot copy out of meta tensor; no data!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.