🚀 ltxvideo-disney
這是一個基於Lightricks/LTX-Video的LyCORIS適配器。它能夠生成具有特定風格的黑白迪士尼場景視頻,為視頻生成領域帶來了新的可能性。
🚀 快速開始
你可以參考以下代碼示例,快速開始使用 ltxvideo-disney
進行推理:
import torch
from diffusers import DiffusionPipeline
from lycoris import create_lycoris_from_weights
def download_adapter(repo_id: str):
import os
from huggingface_hub import hf_hub_download
adapter_filename = "pytorch_lora_weights.safetensors"
cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
os.makedirs(path_to_adapter, exist_ok=True)
hf_hub_download(
repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
)
return path_to_adapter_file
model_id = 'Lightricks/LTX-Video'
adapter_repo_id = 'bghira/ltxvideo-disney'
adapter_filename = 'pytorch_lora_weights.safetensors'
adapter_file_path = download_adapter(repo_id=adapter_repo_id)
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
lora_scale = 1.0
wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
wrapper.merge_to()
prompt = "A black and white disney scene in the style of Steamboat Willie"
negative_prompt = 'ugly, cropped, blurry, low-quality, mediocre average'
from optimum.quanto import quantize, freeze, qint8
quantize(pipeline.transformer, weights=qint8)
freeze(pipeline.transformer)
pipeline.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu')
model_output = pipeline(
prompt=prompt,
negative_prompt=negative_prompt,
num_inference_steps=25,
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
width=768,
height=512,
guidance_scale=3.8,
).frames[0]
from diffusers.utils.export_utils import export_to_gif
export_to_gif(model_output, "output.gif", fps=25)
✨ 主要特性
- 風格獨特:能夠生成具有黑白迪士尼風格的視頻,風格類似《汽船威利號》。
- 可定製性強:提供了豐富的訓練和推理參數設置,用戶可以根據需求進行調整。
- 推理便捷:支持直接使用基礎模型的文本編碼器進行推理,無需額外訓練。
📚 詳細文檔
驗證設置
- 分類器自由引導(CFG):
3.8
- CFG 重縮放:
0.0
- 步數:
25
- 採樣器:
FlowMatchEulerDiscreteScheduler
- 隨機種子:
42
- 分辨率:
768x512
注意:驗證設置不一定與訓練設置相同。
你可以在以下圖庫中找到一些示例圖像:
文本編碼器未進行訓練,你可以重用基礎模型的文本編碼器進行推理。
訓練設置
- 訓練輪數:2666
- 訓練步數:8000
- 學習率:5e-05
- 最大梯度值:0.0
- 有效批量大小:24
- 微批量大小:8
- 梯度累積步數:1
- GPU 數量:3
- 梯度檢查點:啟用
- 預測類型:流匹配(額外參數=['training_scheduler_timestep_spacing=trailing', 'inference_scheduler_timestep_spacing=trailing'])
- 優化器:adamw_bf16
- 可訓練參數精度:純 BF16
- 基礎模型精度:
int8-quanto
- 字幕丟棄概率:10.0%
LyCORIS 配置:
{
"bypass_mode": true,
"algo": "lokr",
"multiplier": 1.0,
"full_matrix": true,
"linear_dim": 10000,
"linear_alpha": 1,
"factor": 4,
"apply_preset": {
"target_module": [
"Attention",
"FeedForward"
],
"module_algo_map": {
"FeedForward": {
"factor": 4
},
"Attention": {
"factor": 2
}
}
}
}
數據集
迪士尼黑白數據集
- 重複次數:0
- 圖像總數:約 69
- 縱橫比桶總數:1
- 分辨率:0.2304 兆像素
- 裁剪:否
- 裁剪風格:無
- 裁剪縱橫比:無
- 是否用於正則化數據:否
指數移動平均(EMA)
SimpleTuner 會生成 EMA 權重的 safetensors 變體和一個 pt 文件。
safetensors 文件用於推理,pt 文件用於繼續微調。
EMA 模型可能會提供更全面的結果,但與完整模型相比,通常會感覺訓練不足,因為它是模型權重的衰減運行平均值。
📄 許可證
本項目使用其他許可證。