A LoRA for MOSS-Image-SFT.
Use Val in your prompt.
Open the MOSS-Image demo with this LoRA. If the repo is private, sign in there first.
MOSS-Image ships its own pipeline without a LoRA loader, so attach the adapter with PEFT:
import json
import torch
from diffusers import DiffusionPipeline
from huggingface_hub import hf_hub_download
from peft import LoraConfig, inject_adapter_in_model, set_peft_model_state_dict
from safetensors.torch import load_file
pipe = DiffusionPipeline.from_pretrained(
"OpenMOSS-Team/MOSS-Image-SFT", custom_pipeline="pipeline_moss_image", trust_remote_code=True,
torch_dtype={"default": torch.bfloat16, "vae": torch.float32},
)
cfg = json.load(open(hf_hub_download("the-big-juice/val-moss-1", "adapter_config.json")))
inject_adapter_in_model(LoraConfig(r=cfg["r"], lora_alpha=cfg["lora_alpha"], target_modules=cfg["target_modules"]), pipe.transformer)
state = load_file(hf_hub_download("the-big-juice/val-moss-1", "pytorch_lora_weights.safetensors"))
set_peft_model_state_dict(pipe.transformer, {k.removeprefix("transformer."): v for k, v in state.items()})
pipe.transformer.to(torch.bfloat16)
pipe.to("cuda")
image = pipe("a photo of Val standing in a sunlit park, soft afternoon light, shallow depth of field", uncond_skip_layers=[22], generator=torch.Generator("cpu").manual_seed(42)).images[0]
image.save("out.png")
Trained on Hugging Face Jobs with the MOSS-Image Trainer Space. The flow-matching loss, noise schedule and optimizer settings follow the MOSS-Image technical report; the text encoder stays frozen as the user guide asks.
Apache 2.0, like MOSS-Image. This is not an official OpenMOSS release.
OpenMOSS-Team/MOSS-Image-SFT