Downloads · 30 days
132
100% of all-time downloads
HelloSun/animagine-xl-4.0-Lightning-OpenVINO-INT4
animagine-xl-4.0-Lightning-OpenVINO-INT4 is a text-to-image model from HelloSun. Use it when you need an image from a text prompt. It is set up for diffusers. The card lists the license as openrail.
⚠️ 關於本 repo 名稱 本 repo 名稱為 ...-OpenVINO-INT4,但實際權重並非 INT4。 經解析 OpenVINO IR 確認:只有 unet/ 含有 INT8 張量, textencoder/、textencoder2/、vaeencoder/、vaedecoder/ 全數為 FP32 未量化。 repo 內所有說明檔(README、REPORT、convertint8.py)一律標示為 INT8, 推…
Downloads · 30 days
132
100% of all-time downloads
All-time downloads
132
Public
Repo size
6.2 GB
Likes
0
Public
Click a slice to open those files.
.bin6.2 GB · 99%
From the Hugging Face model README
⚠️ 關於本 repo 名稱
本 repo 名稱為
...-OpenVINO-INT4,但實際權重並非 INT4。 經解析 OpenVINO IR 確認:只有unet/含有 INT8 張量,text_encoder/、text_encoder_2/、vae_encoder/、vae_decoder/全數為 FP32 未量化。 repo 內所有說明檔(README、REPORT、convert_int8.py)一律標示為 INT8, 推測INT4是從同系列的dreamshaper-xl-lightning-OpenVINO-INT4複製時留下的名稱。
將 cagliostrolab/animagine-xl-4.0
與 ByteDance/SDXL-Lightning
(sdxl_lightning_4step_unet)合併後,以 匯出時 INT8 壓縮轉為 OpenVINO IR。
實測 1024×1024、4 steps、guidance 0.0,純 CPU。
| 項目 | 內容 |
|---|---|
| 基座模型 | cagliostrolab/animagine-xl-4.0 |
| 蒸餾來源 | ByteDance/SDXL-Lightning 的 sdxl_lightning_4step_unet |
| Pipeline | StableDiffusionXLPipeline |
| Scheduler | EulerDiscreteScheduler(timestep_spacing=trailing,由 Lightning 模型帶入) |
| 量化格式 | 僅 unet 為 INT8;其餘元件維持 FP32 |
| 模型大小 | 6.18 GB(其中 INT8 僅 2.58 GB,FP32 佔 3.61 GB) |
| 推論裝置 | CPU(OpenVINO CPU plugin) |
| 推薦參數 | num_inference_steps=4、guidance_scale=0.0、1024×1024 |
| 轉換工具 | optimum-intel 2.2.0 / optimum 2.3.0 / OpenVINO 2026.4.0(diffusers 0.38.0) |
guidance_scale=0.0(即不啟用 CFG)。weight_format="int8" 在匯出階段直接壓縮,只需一次匯出,不必再跑 NNCF 量化流程。from_pretrained()。INT4 與實際的 INT8 不符,詳見上方說明。pip install diffusers==0.37.1 transformers==4.57.6 tokenizers==0.22.0 huggingface-hub==0.35.1 optimum==2.3.0 optimum-intel==2.2.0 openvino==2026.4.0==3.4.0 torch pillow psutil safetensors
本 repo 不需要
nncf(未使用 NNCF 量化流程)。
safetensors為轉換腳本convert_int8.py所需。
psutil未被任何腳本使用,可省略。
import torch
from optimum.intel import OVDiffusionPipeline
pipe = OVDiffusionPipeline.from_pretrained(
"HelloSun/animagine-xl-4.0-Lightning-OpenVINO-INT4", compile=True)
image = pipe(
prompt="Astronaut in a jungle, cold color palette, muted colors, "
"detailed, 8k, photorealistic, cinematic lighting",
height=1024, width=1024,
num_inference_steps=4, guidance_scale=0.0,
generator=torch.Generator().manual_seed(43),
).images[0]
image.save("out.png")
完整可執行範例:inference_ov.py 批次生成 + benchmark:generate5.py
| 參數 | 建議值 | 說明 |
|---|---|---|
num_inference_steps | 4 | SDXL-Lightning 4-step 蒸餾。請勿增加。 |
guidance_scale | 0.0 | Lightning 模型不啟用 CFG(等於 do_classifier_free_guidance=False)。 |
height / width | 1024 | SDXL 原生解析度。 |
compile=True | 開啟 | 編譯模型以取得較佳效能。 |
全部為 4 steps / guidance 0.0 / 1024×1024 / CPU,seed 42–46 固定,可完全重現。
每組另附 512px 對照組(
examples/*_512.png)。
Young Chinese woman in red Hanfu, intricate embroidery, impeccable makeup, red floral forehead pattern, elaborate high bun, golden phoenix headdress, soft-lit outdoor night background, silhouetted tiered pagoda, blurred colorful distant lights, photorealistic, ultra detailed, 8k

Astronaut in a jungle, cold color palette, muted colors, detailed, 8k, photorealistic, cinematic lighting

Cyberpunk street in Taipei at night, heavy rain, neon signs with text 'TAIPEI' and Chinese characters '台北', reflections on wet asphalt, crowded night market, cinematic, ultra detailed

Cute Shiba Inu wearing a tiny astronaut helmet, sitting in a field of sunflowers under a starry sky, dreamy illustration, vibrant colors, high quality

Traditional Chinese ink wash landscape, misty mountains, a small pagoda on a cliff, cranes flying, minimalist, elegant, high aesthetic quality

以下 10 張為 10 類風格 × 同一組 5 組基礎 prompt(seed 42–51), 使用與上方基準測試完全相同的推論設定。
注意:這批圖片沒有對應的
examples/benchmark.json紀錄,也沒有腳本可重現, 完整 prompt 亦未收錄於 repo(早期說明檔中的版本已被截斷,無法還原)。
油畫、版畫、水彩等傳統媒材

吉卜力 × 新海誠動畫風

UE5 寫實渲染、CG 質感

電影感人像攝影

敦煌壁畫、水墨等東方美學

絲線刺繡、陶瓷、木雕等

商業插畫、扁平幾何設計

分形、生成藝術

80s 霓虹、賽博龐克

油畫厚塗、概念設定

完整逐 step 數據見 REPORT.md 與 examples/benchmark.json。
測試環境
| 項目 | 內容 |
|---|---|
| CPU | Intel(R) Xeon(R) Platinum 8559C |
| 拓撲 | 2 sockets × 48 cores × 2 threads/core = 192 vCPU(96 實體核心) |
| RAM | 2.0 TiB |
| 虛擬化 | KVM(完整虛擬化) |
| OpenVINO | CPU only,2026.4.0(build 2026.4.0-22959-99c81491cc3-releases/2026/4) |
| 設定 | num_inference_steps=4、guidance_scale=0.0、1024×1024 + 512×512 對照 |
總結
| 指標 | 主測組 | 對照組 |
|---|---|---|
| 解析度 | 1024×1024 | 512×512 |
| 平均總耗時 | 10.26 s / 張 | 3.39 s / 張 |
| 平均單步耗時 | 2.12 s | 0.73 s |
| 最快 / 最慢 | 9.15 s / 12.24 s | 3.25 s / 3.61 s |
| 對照組倍數 | — | 3.03× |
逐張結果(1024×1024 / 4 steps)
| # | Prompt | Seed | 總耗時 (s) | 平均單步 (s) | 512px 總耗時 (s) | 512px 單步 (s) |
|---|---|---|---|---|---|---|
| 01_hanfu | 42 | 12.24 | 2.483 | 3.61 | 0.776 | |
| 02_astronaut | 43 | 10.53 | 2.209 | 3.44 | 0.733 | |
| 03_taipei | 44 | 10.14 | 2.112 | 3.33 | 0.734 | |
| 04_shiba | 45 | 9.15 | 1.864 | 3.25 | 0.691 | |
| 05_ink | 46 | 9.25 | 1.914 | 3.30 | 0.721 | |
| 平均 | 10.26 | 2.116 | 3.39 | 0.731 |
模型大小
以下為 repo 內 openvino_model.bin 的實際位元組數(Git LFS 記錄值)。
| 元件 | 位元組 | 大小 | 精度 |
|---|---|---|---|
text_encoder_2 | 2,778,640,144 | 2.78 GB | FP32 |
unet | 2,576,698,520 | 2.58 GB | INT8 |
text_encoder | 492,242,708 | 0.49 GB | FP32 |
vae_decoder | 197,960,968 | 0.20 GB | FP32 |
vae_encoder | 136,654,812 | 0.14 GB | FP32 |
| 合計 | 6,182,197,152 | 6.18 GB |
unet/ 為 INT8(u8 張量 2.57 GB + f32/f16 少量),其餘元件全為 FP32。
因此 6.18 GB 的總量中有 3.61 GB(58.5%)完全沒有被壓縮;text_encoder_2 的 2.78 GB 就是未量化的 FP16→FP32 原始大小。
若需要更小體積,請參考同系列的 INT4 repo(例如 dreamshaper-xl-lightning-OpenVINO-INT4)。
.
├── README.md # 本文件
├── REPORT.md # 完整轉換 + 實測報告
├── model_index.json # diffusers pipeline 索引
├── inference_ov.py # 單張推論範例
├── convert_int8.py # 合併 Lightning UNet + 匯出 INT8 OpenVINO
├── generate5.py # 5 組 prompt 批次生成 + benchmark
├── unet/ # INT8 UNet(由 SDXL-Lightning 4-step 權重覆蓋)
├── text_encoder/ # FP32 CLIP text encoder
├── text_encoder_2/ # FP32 CLIP text encoder (projection)
├── tokenizer/ # CLIP tokenizer
├── tokenizer_2/ # CLIP tokenizer 2
├── vae_encoder/ # FP32 VAE encoder
├── vae_decoder/ # FP32 VAE decoder
├── scheduler/ # EulerDiscreteScheduler (trailing) 設定
└── examples/ # 15 張實測圖 + benchmark.json + prompts.txt
├── *_1024.png # 主測組(5 張)
├── *_512.png # 對照組(5 張)
├── *_seed*_1024.png # 風格展示(10 張)
├── benchmark.json # 逐 step 耗時 + 系統資訊
└── prompts.txt # 5 組 prompt 與 seed
# 1. 合併 SDXL-Lightning UNet 並以 INT8 匯出 OpenVINO
# (convert_int8.py 會下載 sdxl_lightning_4step_unet.safetensors、
# 覆寫 UNet 權後以 weight_format="int8" 匯出)
python convert_int8.py
# 2. 單張推論
python inference_ov.py
# 3. 批次生成 5 組 + 512px 對照 + benchmark
python generate5.py --outdir examples
量化設定:
# convert_int8.py 核心:匯出時直接以 INT8 壓縮,不使用 NNCF
from optimum.intel import OVStableDiffusionXLPipeline
pipe = OVStableDiffusionXLPipeline.from_pretrained(
tmp_dir,
export=True,
compile=False,
weight_format="int8",
ov_config={
"PERFORMANCE_HINT": "LATENCY",
"NUM_STREAMS": "1",
"INFERENCE_NUM_THREADS": "4",
},
)
pipe.save_pretrained(ov_output_dir)
INT4,實際僅 UNet 為 INT8,其餘為 FP32。ov_config 中 INFERENCE_NUM_THREADS=4、NUM_STREAMS=1,在多核心機器上不會自動擴展。若要吃滿 192 vCPU 需自行調整匯出設定並重新匯出。benchmark.json 非腳本直接產出:檔案內容與 generate5.py 的輸出格式不一致(例如缺少 image 欄位),推測經人工編修,引用時請留意。diffusers==0.37.1,但各 config.json 實際記錄為 0.38.0。來源模型:cagliostrolab/animagine-xl-4.0 + ByteDance/SDXL-Lightning
授權:兩個來源模型皆為 OpenRAIL++ 系列條款;本 repo frontmatter 標示為 openrail,實際適用條款請以兩個來源模型為準。
轉換:合併 Lightning UNet 權重 + 格式轉換 + 匯出時 INT8 壓縮。
使用本模型時請一併遵守來源模型的授權條款與 OpenRAIL++ 使用政策。
Made with OpenVINO + optimum-intel + NNCF
</div>