Update README.md
Browse files
README.md
CHANGED
@@ -3,4 +3,34 @@ license: mit
|
|
3 |
tags:
|
4 |
- object insertion
|
5 |
pipeline_tag: image-to-image
|
6 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
tags:
|
4 |
- object insertion
|
5 |
pipeline_tag: image-to-image
|
6 |
+
---
|
7 |
+
|
8 |
+
These are the model weights for [EraseDraw](https://erasedraw.cs.columbia.edu).
|
9 |
+
|
10 |
+
To use this model, install diffusers using main for now. The API is the same as that of InstructPix2Pix
|
11 |
+
|
12 |
+
pip install diffusers accelerate safetensors transformers
|
13 |
+
import PIL
|
14 |
+
import requests
|
15 |
+
import torch
|
16 |
+
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
|
17 |
+
|
18 |
+
model_id = "alpercanberk/erasedraw"
|
19 |
+
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None)
|
20 |
+
pipe.to("cuda")
|
21 |
+
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
22 |
+
|
23 |
+
url = "https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/main/imgs/example.jpg"
|
24 |
+
def download_image(url):
|
25 |
+
image = PIL.Image.open(requests.get(url, stream=True).raw)
|
26 |
+
image = PIL.ImageOps.exif_transpose(image)
|
27 |
+
image = image.convert("RGB")
|
28 |
+
return image
|
29 |
+
image = download_image(url)
|
30 |
+
|
31 |
+
prompt = "add sunglasses"
|
32 |
+
images = pipe(prompt, image=image, num_inference_steps=10, image_guidance_scale=1).images
|
33 |
+
images[0]
|
34 |
+
|
35 |
+
|
36 |
+
Code and data are coming soon to GitHub.
|