Views
No views yet

ldm can be created
and activated with:conda env create -f environment.yaml
conda activate ldmconda install pytorch torchvision -c pytorch
pip install transformers==4.19.2 diffusers invisible-watermark
pip install -e .sd-v1-1.ckpt: 237k steps at resolution 256x256 on laion2B-en.
194k steps at resolution 512x512 on laion-high-resolution (170M examples from LAION-5B with resolution >= 1024x1024).sd-v1-2.ckpt: Resumed from sd-v1-1.ckpt.
515k steps at resolution 512x512 on laion-aesthetics v2 5+ (a subset of laion2B-en with estimated aesthetics score > 5.0, and additionally
filtered to images with an original size >= 512x512, and an estimated watermark probability < 0.5. The watermark estimate is from the LAION-5B metadata, the aesthetics score is estimated using the LAION-Aesthetics Predictor V2).sd-v1-3.ckpt: Resumed from sd-v1-2.ckpt. 195k steps at resolution 512x512 on "laion-aesthetics v2 5+" and 10% dropping of the text-conditioning to improve classifier-free guidance sampling.sd-v1-4.ckpt: Resumed from sd-v1-2.ckpt. 225k steps at resolution 512x512 on "laion-aesthetics v2 5+" and 10% dropping of the text-conditioning to improve classifier-free guidance sampling.


stable-diffusion-v1-*-original weights, link themmkdir -p models/ldm/stable-diffusion-v1/
ln -s <path/to/model.ckpt> models/ldm/stable-diffusion-v1/model.ckpt python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --plms --scale 7.5, Katherine Crowson's implementation of the PLMS sampler,
and renders images of size 512x512 (which it was trained on) in 50 steps. All supported arguments are listed below (type python scripts/txt2img.py --help).1usage: txt2img.py [-h] [--prompt [PROMPT]] [--outdir [OUTDIR]] [--skip_grid] [--skip_save] [--ddim_steps DDIM_STEPS] [--plms] [--laion400m] [--fixed_code] [--ddim_eta DDIM_ETA]
2 [--n_iter N_ITER] [--H H] [--W W] [--C C] [--f F] [--n_samples N_SAMPLES] [--n_rows N_ROWS] [--scale SCALE] [--from-file FROM_FILE] [--config CONFIG] [--ckpt CKPT]
3 [--seed SEED] [--precision {full,autocast}]
4
5optional arguments:
6 -h, --help show this help message and exit
7 --prompt [PROMPT] the prompt to render
8 --outdir [OUTDIR] dir to write results to
9 --skip_grid do not save a grid, only individual samples. Helpful when evaluating lots of samples
10 --skip_save do not save individual samples. For speed measurements.
11 --ddim_steps DDIM_STEPS
12 number of ddim sampling steps
13 --plms use plms sampling
14 --laion400m uses the LAION400M model
15 --fixed_code if enabled, uses the same starting code across samples
16 --ddim_eta DDIM_ETA ddim eta (eta=0.0 corresponds to deterministic sampling
17 --n_iter N_ITER sample this often
18 --H H image height, in pixel space
19 --W W image width, in pixel space
20 --C C latent channels
21 --f F downsampling factor
22 --n_samples N_SAMPLES
23 how many samples to produce for each given prompt. A.k.a. batch size
24 --n_rows N_ROWS rows in the grid (default: n_samples)
25 --scale SCALE unconditional guidance scale: eps = eps(x, empty) + scale * (eps(x, cond) - eps(x, empty))
26 --from-file FROM_FILE
27 if specified, load prompts from this file
28 --config CONFIG path to config which constructs model
29 --ckpt CKPT path to checkpoint of model
30 --seed SEED the seed (for reproducible sampling)
31 --precision {full,autocast}
32 evaluate at this precisionuse_ema=False is set in the configuration, otherwise the code will try to switch from
non-EMA to EMA weights. If you want to examine the effect of EMA vs no EMA, we provide "full" checkpoints
which contain both types of weights. For these, use_ema=False will load and use the non-EMA weights.1# make sure you're logged in with `huggingface-cli login`
2from torch import autocast
3from diffusers import StableDiffusionPipeline
4
5pipe = StableDiffusionPipeline.from_pretrained(
6 "CompVis/stable-diffusion-v1-4",
7 use_auth_token=True
8).to("cuda")
9
10prompt = "a photo of an astronaut riding a horse on mars"
11with autocast("cuda"):
12 image = pipe(prompt)["sample"][0]
13
14image.save("astronaut_rides_horse.png")python scripts/img2img.py --prompt "A fantasy landscape, trending on artstation" --init-img <path-to-img.jpg> --strength 0.8


@misc{rombach2021highresolution,
title={High-Resolution Image Synthesis with Latent Diffusion Models},
author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer},
year={2021},
eprint={2112.10752},
archivePrefix={arXiv},
primaryClass={cs.CV}
}