Downloads · 30 days
0
Shruthi2606/magicbrush-lora-sd15
magicbrush-lora-sd15 is a machine learning model from Shruthi2606. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Model: LoRA adapter for Stable Diffusion v1.5 (UNet) Base model: runwayml/stable-diffusion-v1-5 Adapter file: unetlorafinal5000.safetensors Trained on: MagicBrush dataset (osunlp/MagicBrush) Training steps: 5000 LoRA…
Downloads · 30 days
0
Access
Public
Updated Nov 21, 2025
Repo size
14.2 MB
Likes
0
Public
Click a slice to open those files.
.safetensors13.7 MB · 96%
From the Hugging Face model README
Model: LoRA adapter for Stable Diffusion v1.5 (UNet)
Base model: runwayml/stable-diffusion-v1-5
Adapter file: unet_lora_final_5000.safetensors
Trained on: MagicBrush dataset (osunlp/MagicBrush)
Training steps: 5000
LoRA rank (r): 8
Device: Apple M4 Pro (MPS)
Usage: Apply this adapter to SD v1.5 UNet to enable instruction-guided editing in MagicBrush style.
from safetensors.torch import load_file
from diffusers import StableDiffusionPipeline
import torch
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5").to("mps")
lora = load_file("unet_lora_final_5000.safetensors")
# naive mapping — best-effort; adjust if attribute paths differ
def apply_lora_to_unet(unet, lora_state):
for name, arr in lora_state.items():
parts = name.split(".")
target = unet
for p in parts[:-1]:
if hasattr(target, p):
target = getattr(target, p)
else:
try:
idx = int(p)
target = target[idx]
except Exception:
target = None
break
if target is None:
continue
attr = parts[-1]
if hasattr(target, attr):
t = torch.from_numpy(arr) if not isinstance(arr, torch.Tensor) else arr
getattr(target, attr).data.copy_(t.to(getattr(target, attr).device))
apply_lora_to_unet(pipe.unet, lora)
# then run pipe(...) as usual