Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1 |
---
|
2 |
license: other
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: other
|
3 |
---
|
4 |
+
|
5 |
+
# This is a Custom Diffusion model fine-tuned from the Stable Diffusion v1-4.
|
6 |
+
|
7 |
+
Custom Diffusion allows you to fine-tune text-to-image diffusion models, such as Stable Diffusion, given a few images of a new concept (~4-20).
|
8 |
+
|
9 |
+
Here we give an example model fine-tuned using 5 images of a cat downloaded from UnSplash. The example code of inference is shown below.
|
10 |
+
|
11 |
+
|
12 |
+
## Example code of inference
|
13 |
+
```python
|
14 |
+
import os
|
15 |
+
import sys
|
16 |
+
import torch
|
17 |
+
|
18 |
+
os.system("git clone https://github.com/adobe-research/custom-diffusion")
|
19 |
+
sys.path.append("custom-diffusion")
|
20 |
+
from diffusers import StableDiffusionPipeline
|
21 |
+
from src import diffuser_training
|
22 |
+
|
23 |
+
device = 'cuda'
|
24 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
25 |
+
pipe = pipe.to(self.device)
|
26 |
+
|
27 |
+
diffuser_training.load_model(pipe.text_encoder, pipe.tokenizer, pipe.unet, weight_path, '<new1>')
|
28 |
+
prompt = "<new1> cat swimming in a pool"
|
29 |
+
images = pipe(prompt, num_inference_steps=200, guidance_scale=6., eta=1.).images
|
30 |
+
```
|