Update README.md
Browse files
README.md
CHANGED
@@ -5,3 +5,36 @@ license: mit
|
|
5 |
# InstructPix2Pix: Learning to Follow Image Editing Instructions
|
6 |
GitHub: https://github.com/timothybrooks/instruct-pix2pix
|
7 |
<img src='https://instruct-pix2pix.timothybrooks.com/teaser.jpg'/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# InstructPix2Pix: Learning to Follow Image Editing Instructions
|
6 |
GitHub: https://github.com/timothybrooks/instruct-pix2pix
|
7 |
<img src='https://instruct-pix2pix.timothybrooks.com/teaser.jpg'/>
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
## Example
|
12 |
+
|
13 |
+
To use `InstructPix2Pix`, install `diffusers` using `main` for now. The pipeline will be available in the next release
|
14 |
+
|
15 |
+
```bash
|
16 |
+
pip install git+https://github.com/huggingface/diffusers.git
|
17 |
+
```
|
18 |
+
|
19 |
+
```python
|
20 |
+
import PIL
|
21 |
+
import requests
|
22 |
+
import torch
|
23 |
+
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
|
24 |
+
|
25 |
+
model_id = "timbrooks/instruct-pix2pix"
|
26 |
+
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None).to("cuda")
|
27 |
+
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
28 |
+
|
29 |
+
url = "https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/main/imgs/example.jpg"
|
30 |
+
def download_image(url):
|
31 |
+
image = PIL.Image.open(requests.get(url, stream=True).raw)
|
32 |
+
image = PIL.ImageOps.exif_transpose(image)
|
33 |
+
image = image.convert("RGB")
|
34 |
+
return image
|
35 |
+
image = download_image(URL)
|
36 |
+
|
37 |
+
prompt = "turn him into cyborg"
|
38 |
+
images = pipe(prompt, image=image, num_inference_steps=10, image_guidance_scale=1).images
|
39 |
+
images[0]
|
40 |
+
```
|