Upload Memo: Production-grade Transformers + Safetensors implementation
a8fc815
verified
LoRA Configuration - Safetensors Only
Directory Structure
data/lora/
βββ memo-scene-lora.safetensors # Main LoRA weights
βββ readme.md # This file
βββ versions/ # Versioned LoRA files
βββ v1.0/
βββ v1.1/
LoRA File Requirements
Security Requirements
- ONLY .safetensors files - No .bin, .ckpt, or other formats allowed
- Model signatures required - All LoRA files must have proper signatures
- Version tracking - Each version must be clearly identified
Technical Requirements
- Format: PyTorch safetensors
- Precision: FP16 recommended for memory efficiency
- Compression: Quantized versions for faster loading
- Metadata: Include training information and compatibility notes
Loading LoRA Weights
Basic Loading
from models.image.sd_generator import get_generator
generator = get_generator(lora_path="data/lora")
Version-Specific Loading
generator = get_generator(lora_path="data/lora/versions/v1.1")
Multiple LoRA Support
lora_paths = [
"data/lora/memo-scene-lora.safetensors",
"data/lora/style-lora.safetensors"
]
for lora_path in lora_paths:
generator.pipe.load_lora_weights(
os.path.dirname(lora_path),
weight_name=os.path.basename(lora_path)
)
LoRA Training Configuration
Recommended Settings
- Base Model: stabilityai/stable-diffusion-xl-base-1.0
- LoRA Rank: 16-64 (higher rank = more capacity)
- Alpha: 32-128 (typically 2x the rank)
- Dropout: 0.1-0.2 for regularization
- Precision: FP16 for training, FP16 inference
Training Script Usage
python scripts/train_scene_lora.py \
--base_model "stabilityai/stable-diffusion-xl-base-1.0" \
--output_dir "data/lora/versions/v1.2" \
--rank 32 \
--alpha 64 \
--epochs 5
Model Tier Configuration
Free Tier
- Base model only (no LoRA)
- Lower inference steps (15-20)
- Standard resolution (512x512)
Pro Tier
- Base + scene LoRA
- Higher inference steps (25-30)
- Higher resolution (768x768 or 1024x1024)
- LCM acceleration
Enterprise Tier
- Base + multiple LoRAs
- Highest quality settings
- Custom resolution
- Priority processing
Security Notes
- Never load .bin files - Use only safetensors
- Verify signatures - Check LoRA file integrity
- Isolate environments - Separate model loading contexts
- Audit logs - Track all LoRA loading operations
- Version pinning - Lock specific LoRA versions for production
Performance Notes
- Memory optimization - Use quantized LoRA when possible
- Preloading - Load frequently used LoRA files at startup
- Caching - Cache LoRA states for faster switching
- Cold start - Minimize initial LoRA loading time
- Dynamic loading - Load LoRA on-demand for different scenes