dskjal
広告
広告

Z Image の LoRA 作成 tips

カテゴリ:deeplearning

Z Image Turbo

ツール

ai-toolkit がサポートしている。ostris/zimage_turbo_training_adapter が必要。v2 は LoRA のランクと学習時間とを増やしたバージョンでこちらが推奨されている。

musubi tuner でも作成可能。ベースはDe Turbo

キャプション

Z Image は markdown で構造化されたキャプションも理解できるが、学習はタグリストとべた書きの自然言語とで行われている。学習に使われている言語は英語と中国語。

テキストエンコーダーの Qwen 3 4b は日本語も理解できるが、日本語の理解力は低い。

キャプションの作成方法

VLM を使って5種類のキャプションを作成し、ランダムに選択して使用している。

  1. タグリスト
  2. 短いキャプション
  3. 中程度の長さのキャプション
  4. 長いキャプション
  5. ユーザーの入力したプロンプトをシミュレートした短いキャプション

画像入力可能な推論モデルはローカルでは mistralai/Ministral-3-14B-Reasoning-2512-GGUF がある(というかこれぐらいしかない)(新しいMinistral 3 14B Reasoning 2512 Q8を使った経験)。ただし、推論なしの VLM の方がキャプション性能がいい。

Ministral-3-14B-Reasoning のシステムプロンプト例

<s>[SYSTEM_PROMPT]# HOW YOU SHOULD THINK AND ANSWER

First draft your thinking process (inner monologue) until you arrive at a response. Format your response using Markdown, and use LaTeX for any mathematical equations. Write both your thoughts and the response in the same language as the input.

Your thinking process must follow the template below:[THINK]Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate the response to the user.[/THINK]Here, provide a self-contained response.[/SYSTEM_PROMPT][INST]What is 1+1?[/INST]2[INST]What is 2+2?[/INST]

画像の要素をタグで出力

VLM に画像とシステムプロンプトとを入力してタグリストを出力させる。論文の例ではテキストはシングルクオートになっている。

以下の情報も追加する:

入力画像

入力画像

出力例

1 girl, single subject focus, young woman, another person in the background, East Asian, black hair, bangs, white T-shirt, red apron, Hangzhou food festival, holding a plate, using hopsticks, Longjing shrimp, West Lake, Hangzhou, China, Leifeng Pagoda, EUROSTAR, magazine cover, outdoors, daytime, lakeside, water, tour boat, willow trees, displayed food,  smanthus cake, tea leaves, glass jars, orange triangular flags, white tents, photography, half-body shot, white border, 'Food', 'Culture', 'Design Travel', 'ND', '2025', 'THE MAGAZINE', 'F BIODI', 'FOOD', 'EUROSTAR', 'SPECIAL', 'TASTY HANGZHOU', '美⻝节攻略', 'HANGZOU FOOD FESTIVAL 2025', '骑⾏路线', '2025 杭州美⻝节

短い自然言語の例

以下の4つを VLM に入力して短いキャプションを作る。

  1. 入力画像
  2. タグリスト
  3. 推論モデルの推論過程
  4. 短いキャプションを作成させるシステムプロンプト

出力例

A promotional magazine cover themed around Hangzhou Cuisine, featuring a young woman at a West Lake food stall during the 2025 Hangzhou Food Festival, holding a plate and selling Longjing shrimp.

長い自然言語の例

以下の4つを VLM に入力して長いキャプションを作る。

  1. 入力画像
  2. タグリスト
  3. 推論モデルの推論過程
  4. 長いキャプションを作成させるシステムプロンプト

出力例

A “Food ND” magazine cover, a special issue about “HANGZHOU FOOD FESTIVAL 2025.” The scene takes place on the shore of West Lake, one of Hangzhou’s iconic andmarks, captured in a vibrant, sunny daytime setting.At the center of the image is a young East Asian woman with black hair, wearing a white T-shirt and a bright red apron. She is holding a white plate of the famous local dish Longjing Shrimp and lifting a piece with a pair of green chopsticks. The red apron is printed with white text reading “2025 杭州美⻝节”. To her right is a food stall under a white tent, decorated with a string of orange triangular flags. On the table are various local delicacies: two jars of Longjing tea leaves, a wooden tray with square white cakes sprinkled with osmanthus, several jars of pickled vegetables, and an orange hanging tag with vertical black text reading “中⾬⾹”. In the background is the expansive view of West Lake, its surface shimmering in the sunlight, with several traditional-style boats gliding across the water. On the opposite shore rise lush green hills, and the famous Leifeng Pagoda stands clearly on the right-side hilltop...(続く)

広告
広告

カテゴリ