File size: 1,824 Bytes
c945057
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# LoRA training Cog model

## Use on Replicate

Easy-to-use model pre-configured for faces, objects, and styles:

[![Replicate](https://replicate.com/replicate/lora-training/badge)](https://replicate.com/replicate/lora-training)

Advanced model with all the parameters:

[![Replicate](https://replicate.com/replicate/lora-advanced-training/badge)](https://replicate.com/replicate/lora-advanced-training)

Feed the trained model into this inference model to run predictions:

[![Replicate](https://replicate.com/replicate/lora/badge)](https://replicate.com/replicate/lora)

If you want to share your trained LoRAs, please join the `#lora` channel in the [Replicate Discord](https://discord.gg/replicate).

## Use locally

First, download the pre-trained weights [with your Hugging Face auth token](https://huggingface.co./settings/tokens):

```
cog run script/download-weights <your-hugging-face-auth-token>
```

Then, you can run train your dreambooth:

```
cog predict -i [email protected]
```

The resulting LoRA weights file can be used with `patch_pipe` function:

```python
from diffusers import StableDiffusionPipeline
from lora_diffusion import patch_pipe, tune_lora_scale, image_grid
import torch

model_id = "runwayml/stable-diffusion-v1-5"

pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(
    "cuda:1"
)

patch_pipe(pipe, "./my-images.safetensors")
prompt = "detailed photo of <s1><s2>, detailed face, a brown cloak, brown steampunk corset, belt, virtual youtuber, cowboy shot, feathers in hair, feather hair ornament, white shirt, brown gloves, shooting arrows"

tune_lora_scale(pipe.unet, 0.8)
tune_lora_scale(pipe.text_encoder, 0.8)

imgs = pipe(
    [prompt],
    num_inference_steps=50,
    guidance_scale=4.5,
    height=640,
    width=512,
).images
...
```