見出し画像

HunyuanDiT/ComfyUIを試してみた話@paperspace

上のサイト見ていると、ComfyUIで使用できるということでPaperspaceで試してみました。Paperspaceで動作しました。freeA4000です。
HunyuanDiT自体は5月に公開されたもので、最近SD3が公開されたのに合わせて比較されたりしています。

HunyuanDiTとは何か?

Ditというのは「Diffusion Transformer」というもので、Stable diffusion3が採用しているものになります。

HunyuanDiTとSD3の違い(論文の比較)

Hunyuan-DiT
使用方法: Hunyuan-DiTでは、ディフュージョントランスフォーマーモデルを使用して、特に多言語(英語と中国語)対応のテキストから画像生成を行っています。
<特徴>
デュアルテキストエンコーダー(バイリンガルCLIPと多言語T5エンコーダー)を使用。
新しいネットワークアーキテクチャとデータ処理パイプラインを採用。
SD3
使用方法: SD3では、トランスフォーマーアーキテクチャを使用して高解像度画像の生成を行います。このモデルは、整流流量(Rectified Flow)モデルに新しいノイズサンプリング技術を組み合わせています。
<特徴>
双方向情報フローを可能にする新しいトランスフォーマーアーキテクチャ。
画像とテキストトークン間の相互作用を強化するためのモジュールを持つ。
<両者の共通点>
DiTの使用: 両方のモデルとも、ディフュージョントランスフォーマーモデルを使用しており、これは生成モデルとしてのアーキテクチャの一部です。
テキストから画像生成: 両方の研究ともテキストから画像を生成するタスクに焦点を当てています。
<両者の相違点>
焦点の違い:
Hunyuan-DiT: 特に多言語対応(中国語と英語)に強みを持ち、マルチターンの対話が可能な点に重点を置いています。
SD3 高解像度の画像生成に特化し、効率的な整流流量モデルを採用して、少ないステップで高品質な画像を生成することに焦点を当てています。

ということの様です。

ネットを検索していると、SD3よりは生成画像の質が高い可能性もあると言及している方もいるようです。

<個人的な感想>

①アジア人の生成に強い
②解剖学的な失敗は少ない:SD3より
③NSFW的なものは出せないのは同じ
④Hunyuan-DiT:の方が生成時間が長い:かなり長い
⑤Hunyuan-DiTの方がインストールしにくい

<ComfyUIのインストール例>

ComfyUIのインストールコマンドは一時ディレクトリ使用だと以下です。
一応使えるのですが、うまく動いていない可能性もあります。
その当たりは自己責任ということで。
基本お試し程度とご理解ください。

インストールにそこそこ時間がかかります。
ログがあまり出ないようなコマンドにしました。

# Install and Upgrade diffusers, transformers, and accelerate packages
!echo "Installing and upgrading diffusers..."
!pip install --upgrade diffusers -q

!echo "Installing and upgrading transformers..."
!pip install --upgrade transformers -q

!echo "Installing and upgrading accelerate..."
!pip install --upgrade accelerate -q

# Fixing dependency issues
!pip install --upgrade accelerate>=0.21.0 fsspec[http]>=2023.1.0 -q

# Install the huggingface_hub package with CLI tools
!echo "Installing huggingface_hub with CLI tools..."
!python -m pip install "huggingface_hub[cli]" -q

# Create the directory for the model weights
!echo "Creating directory for model weights..."
!mkdir -p /tmp/ComfyUI/models/hunyuan

# Download model weights to the specified directory
!echo "Downloading model weights..."
!huggingface-cli download Tencent-Hunyuan/HunyuanDiT --local-dir /tmp/ComfyUI/models/hunyuan/ckpts > /dev/null 2>&1

# Clone the HunyuanDiT repository directly into the custom_nodes directory
!echo "Cloning HunyuanDiT repository..."
%cd /tmp/ComfyUI/custom_nodes
!git clone --depth 1 --filter=blob:none --sparse https://github.com/Tencent/HunyuanDiT -q
%cd HunyuanDiT
!git sparse-checkout set comfyui-hydit -q

!pip install librosa

%cd /tmp/ComfyUI/custom_nodes/comfyui-hydit
!echo "Installing requirements..."
!pip install -r requirements.txt -q || echo "requirements.txt not found, please install required packages manually."
!echo "Setup complete."

こんな感じのエラーが出ていますが、気にせずそのまま進めます。

このまま起動すると、カスタムノードはインストールされていないので、以下も追加で行います。

%cd /tmp/ComfyUI/custom_nodes
!rm -rf comfyui-hydit
!rm -rf HunyuanDiT
!git clone --depth 1 --filter=blob:none --sparse https://github.com/Tencent/HunyuanDiT
%cd HunyuanDiT
!git sparse-checkout set comfyui-hydit
%cd ..
!mv HunyuanDiT/comfyui-hydit .
!rm -rf HunyuanDiT
!pip install librosa
%cd /tmp/ComfyUI/custom_nodes/comfyui-hydit
!pip install -r requirements.txt

これで、起動時に以下の様にカスタムノードがインストールされれば実行可能になります。

公式が出しているワークフローです。


<実際に生成してみたもの>

英語のプロンプトにしてみます。
Girl in summer dress. Her long braided hair sways in the wind and she smiles at us. Against the backdrop of a European cityscape, the girl stands in the crowd and waves her hand. photorealistic.
サマードレスを着た少女。長い三つ編みをした髪の毛が風で揺れ、こちらに笑顔を向けている。ヨーロッパの街並みを背景に、人混みの中に少女は立って手を振っている。

感想:生成時間がかなりかかります。プロンプトの追従性は良く、破綻も少なそうです。

Ksamplerよりも、Diffuser版の方が時間がかかります。

無検閲的な文言は無視されてる感じになると思います。

A girl with a tear mole smiles at us, making a peace sign. Her light-colored hair blows in the wind. The background features a blue sky with white clouds. She wears casual clothes, exuding a sense of joy and openness.

photorealisticを追加

A girl with a tear mole smiles at us, making a peace sign. Her light-colored hair blows in the wind. The background features a blue sky with white clouds. She wears casual clothes, exuding a sense of joy and openness. photorealistic, big breasts, sexy costume, Against the backdrop of a European cityscape, the girl stands in the crowd and waves her hand. photorealistic.

A girl smiles while making a peace sign. Her light-colored hair flutters in the wind. She has big breasts and wears a sexy costume that exudes joy and openness. she is asian.
The background is blue sky and white clouds with beautirul realistic fireworks are being set off. The girl stands in a crowd against an old-fashioned European cityscape. Photorealistic and realistic scene.

A girl smiles while making a peace sign. Her light-colored hair flutters in the wind. She has big breasts and wears a sexy costume that exudes joy and openness. she is asian super modes.her eyes are big and very cute. The background is blue sky and white clouds with beautirul realistic fireworks are being set off. The girl stands in a crowd against an old-fashioned European cityscape. Photorealistic and realistic scene.

指については、一定頻度で破綻していました。ネガティブプロンプトで調整したりすると頻度は下がる気がします。
Githubサイトを見ると、controlnetにも対応しているとのことです。
使用した状況だと、通常生成に時間がかかるため、手が出せていません。

サンプラーは、いくつか試しましたが、いい条件がよくわかりませんでした。デフォルトがとりあえず安定した結果になった印象です。

この記事が気に入ったらサポートをしてみませんか?