← 返回
内容创作 Key 中文

Lora Finetune

LoRA fine-tuning pipeline for Stable Diffusion on Apple Silicon — dataset prep, training, evaluation with LLM-as-judge scoring. Use when fine-tuning image ge...
Apple Silicon 稳定扩散 LoRA 微调流程,包含数据集准备、训练及基于 LLM-as-judge 评分的评估。适用于图像生成微调。
nissan
内容创作 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 755
下载
💾 25
安装
1
版本
#latest

概述

LoRA Fine-Tuning (Apple Silicon)

Train custom LoRA adapters for Stable Diffusion 1.5 on Mac hardware. Tested on M4 24GB — produces 3.1MB weight files in ~15 minutes at 500 steps.

Hardware Requirements

ConfigModelResolutionVRAM
------------
M4 24GBSD 1.5512×512✅ Works
M4 24GBSDXL512×512⚠️ Tight, may OOM
M4 24GBFLUX.1-schnellAny❌ OOMs
M4 Pro 48GBSDXL1024×1024✅ Estimated

Training Pipeline

  1. Prepare dataset: 15-25 images in consistent style, 512×512, with text captions
  2. Train LoRA: 500 steps, learning rate 1e-4, rank 4
  3. Evaluate: Generate test images, compare base vs LoRA vs reference (Gemini/DALL-E)
  4. Score: LLM-as-judge rates each on style consistency, quality, prompt adherence

Quick Start

# Prepare training images in a folder
ls training_data/
# image_001.png  image_001.txt  image_002.png  image_002.txt ...

# Train (see scripts/train_lora.py for full options)
python3 scripts/train_lora.py \
  --data_dir ./training_data \
  --output_dir ./lora_weights \
  --steps 500 \
  --lr 1e-4 \
  --rank 4

Evaluation with LLM-as-Judge

# Compare base model vs LoRA vs commercial (Gemini/DALL-E)
# Pixtral Large scores each image 1-10 on:
# - Style consistency with training data
# - Image quality and coherence
# - Prompt adherence

# Our results: Base 6.8 → LoRA 9.0 → Gemini 9.5
# Lesson: Gemini wins without training, but LoRA closes the gap significantly

Key Lessons

  • float32 required on MPS — float16 silently produces NaN on Apple Silicon for SD pipelines
  • mflux is faster than PyTorch MPS for FLUX (~105s vs ~90min) but doesn't support LoRA training
  • SD 1.5 is the ceiling for 24GB — FLUX LoRA OOMs even with gradient checkpointing
  • 15-25 images is the sweet spot — fewer undertrain, more doesn't help proportionally
  • Gemini (Imagen 4.0) beats fine-tuned SD 1.5 with zero training — use commercial APIs for production, LoRA for experimentation and offline use

Files

  • scripts/train_lora.py — Training script with Apple Silicon MPS support
  • scripts/compare_models.py — LLM-as-judge evaluation comparing base vs LoRA vs reference

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 06:23 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Observability Lgtm

nissan
Set up a full local LGTM observability stack (Loki + Grafana + Tempo + Prometheus + Alloy) for FastAPI apps. One Docker
★ 0 📥 966
content-creation

Baidu Wenku AIPPT

ide-rea
使用百度文库 AI 智能生成 PPT,自动根据内容选择模板。
★ 66 📥 46,224
content-creation

Humanizer

biostartechnology
消除AI写作痕迹,使文本更自然真实。基于维基百科"AI写作特征"指南,识别并修正夸张象征、宣传用语、肤浅-ing分析、模糊归因、破折号滥用、三项排比、AI词汇、负面平行结构及冗长连接词等模式。
★ 860 📥 199,997