Instructions to use whosouravsharma/diffusiondb-sd15-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use whosouravsharma/diffusiondb-sd15-lora with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("whosouravsharma/diffusiondb-sd15-lora") prompt = "a anthropomorphic lion wizard, diffuse lighting, fantasy, intricate, elegant, highly detailed, lifelike, photorealistic, digital painting, artstation, illustration, concept art, smooth, sharp focus, naturalism, trending on byron's - muse, by greg rutkowski and greg staples" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Point scripts at checkpoints/ prefix
Browse files- training/sample_job.py +2 -1
- training/train_lora_job.py +7 -3
training/sample_job.py
CHANGED
|
@@ -46,6 +46,7 @@ BASE_MODEL = "runwayml/stable-diffusion-v1-5"
|
|
| 46 |
|
| 47 |
# "base" renders vanilla SD 1.5 with no adapter - the comparison baseline.
|
| 48 |
CHECKPOINT = os.environ.get("CHECKPOINT", "base")
|
|
|
|
| 49 |
|
| 50 |
STEPS = int(os.environ.get("STEPS", 30))
|
| 51 |
GUIDANCE = float(os.environ.get("GUIDANCE", 7.5))
|
|
@@ -84,7 +85,7 @@ def main() -> None:
|
|
| 84 |
print(f"Loading LoRA {CHECKPOINT} ...")
|
| 85 |
pipeline.load_lora_weights(
|
| 86 |
MODEL_REPO, weight_name="pytorch_lora_weights.safetensors",
|
| 87 |
-
subfolder=CHECKPOINT,
|
| 88 |
)
|
| 89 |
|
| 90 |
images = []
|
|
|
|
| 46 |
|
| 47 |
# "base" renders vanilla SD 1.5 with no adapter - the comparison baseline.
|
| 48 |
CHECKPOINT = os.environ.get("CHECKPOINT", "base")
|
| 49 |
+
CHECKPOINT_DIR = "checkpoints"
|
| 50 |
|
| 51 |
STEPS = int(os.environ.get("STEPS", 30))
|
| 52 |
GUIDANCE = float(os.environ.get("GUIDANCE", 7.5))
|
|
|
|
| 85 |
print(f"Loading LoRA {CHECKPOINT} ...")
|
| 86 |
pipeline.load_lora_weights(
|
| 87 |
MODEL_REPO, weight_name="pytorch_lora_weights.safetensors",
|
| 88 |
+
subfolder=f"{CHECKPOINT_DIR}/{CHECKPOINT}",
|
| 89 |
)
|
| 90 |
|
| 91 |
images = []
|
training/train_lora_job.py
CHANGED
|
@@ -80,6 +80,9 @@ CAPTION_DROPOUT = float(os.environ.get("CAPTION_DROPOUT", 0.1))
|
|
| 80 |
|
| 81 |
CHECKPOINT_EVERY = int(os.environ.get("CHECKPOINT_EVERY", 500))
|
| 82 |
RESUME_FROM = os.environ.get("RESUME_FROM") # e.g. "checkpoint-1500"
|
|
|
|
|
|
|
|
|
|
| 83 |
SEED = int(os.environ.get("SEED", 42))
|
| 84 |
|
| 85 |
WORK_DIR = Path("run")
|
|
@@ -139,7 +142,7 @@ def save_checkpoint(unet, optimizer, scaler, step, epoch, api, scaling_factor):
|
|
| 139 |
}, indent=2))
|
| 140 |
|
| 141 |
api.upload_folder(
|
| 142 |
-
folder_path=str(out), path_in_repo=name,
|
| 143 |
repo_id=MODEL_REPO, repo_type="model",
|
| 144 |
commit_message=f"Checkpoint at step {step}",
|
| 145 |
)
|
|
@@ -150,9 +153,10 @@ def save_checkpoint(unet, optimizer, scaler, step, epoch, api, scaling_factor):
|
|
| 150 |
def load_checkpoint(unet, optimizer, scaler, device):
|
| 151 |
print(f"Resuming from {RESUME_FROM} ...")
|
| 152 |
local = snapshot_download(
|
| 153 |
-
MODEL_REPO, allow_patterns=f"{RESUME_FROM}/*",
|
|
|
|
| 154 |
)
|
| 155 |
-
folder = Path(local) / RESUME_FROM
|
| 156 |
|
| 157 |
unet.load_lora_adapter(str(folder / "pytorch_lora_weights.safetensors"))
|
| 158 |
blob = torch.load(folder / "optimizer.pt", map_location=device)
|
|
|
|
| 80 |
|
| 81 |
CHECKPOINT_EVERY = int(os.environ.get("CHECKPOINT_EVERY", 500))
|
| 82 |
RESUME_FROM = os.environ.get("RESUME_FROM") # e.g. "checkpoint-1500"
|
| 83 |
+
|
| 84 |
+
# Checkpoints live under this prefix so the repo root stays readable.
|
| 85 |
+
CHECKPOINT_DIR = "checkpoints"
|
| 86 |
SEED = int(os.environ.get("SEED", 42))
|
| 87 |
|
| 88 |
WORK_DIR = Path("run")
|
|
|
|
| 142 |
}, indent=2))
|
| 143 |
|
| 144 |
api.upload_folder(
|
| 145 |
+
folder_path=str(out), path_in_repo=f"{CHECKPOINT_DIR}/{name}",
|
| 146 |
repo_id=MODEL_REPO, repo_type="model",
|
| 147 |
commit_message=f"Checkpoint at step {step}",
|
| 148 |
)
|
|
|
|
| 153 |
def load_checkpoint(unet, optimizer, scaler, device):
|
| 154 |
print(f"Resuming from {RESUME_FROM} ...")
|
| 155 |
local = snapshot_download(
|
| 156 |
+
MODEL_REPO, allow_patterns=f"{CHECKPOINT_DIR}/{RESUME_FROM}/*",
|
| 157 |
+
repo_type="model",
|
| 158 |
)
|
| 159 |
+
folder = Path(local) / CHECKPOINT_DIR / RESUME_FROM
|
| 160 |
|
| 161 |
unet.load_lora_adapter(str(folder / "pytorch_lora_weights.safetensors"))
|
| 162 |
blob = torch.load(folder / "optimizer.pt", map_location=device)
|