Update README.md
Browse filescorrect diffusers use
README.md
CHANGED
@@ -19,7 +19,8 @@ Data: https://huggingface.co/datasets/peter-sushko/RealEdit
|
|
19 |
Install diffusers, transformers library:
|
20 |
|
21 |
```bash
|
22 |
-
|
|
|
23 |
```
|
24 |
|
25 |
Download weights adapted for diffusers:
|
@@ -28,31 +29,24 @@ WEIGHTS
|
|
28 |
|
29 |
|
30 |
```python
|
31 |
-
import PIL
|
32 |
-
import requests
|
33 |
import torch
|
34 |
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
|
|
|
35 |
|
36 |
model_id = "peter-sushko/RealEdit"
|
37 |
-
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
|
|
|
|
|
|
|
|
|
38 |
pipe.to("cuda")
|
39 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
def download_image(url):
|
44 |
-
image = PIL.Image.open(requests.get(url, stream=True).raw)
|
45 |
-
image = PIL.ImageOps.exif_transpose(image)
|
46 |
-
image = image.convert("RGB")
|
47 |
-
return image
|
48 |
-
#image = download_image(url)
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
images = pipe(prompt, image=image, num_inference_steps=10, image_guidance_scale=1).images
|
55 |
-
images[0]
|
56 |
```
|
57 |
|
58 |
|
|
|
19 |
Install diffusers, transformers library:
|
20 |
|
21 |
```bash
|
22 |
+
# Install required libraries
|
23 |
+
pip install torch==2.7.0 diffusers==0.33.1 transformers==4.51.3 accelerate==1.6.0 pillow==11.2.1
|
24 |
```
|
25 |
|
26 |
Download weights adapted for diffusers:
|
|
|
29 |
|
30 |
|
31 |
```python
|
|
|
|
|
32 |
import torch
|
33 |
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
|
34 |
+
from PIL import Image
|
35 |
|
36 |
model_id = "peter-sushko/RealEdit"
|
37 |
+
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
|
38 |
+
model_id,
|
39 |
+
torch_dtype=torch.float16,
|
40 |
+
safety_checker=None
|
41 |
+
)
|
42 |
pipe.to("cuda")
|
43 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
44 |
|
45 |
+
image = Image.open("example_imgs/simba.jpg")
|
46 |
+
prompt = "give him a crown"
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
result = pipe(prompt, image=image, num_inference_steps=50, image_guidance_scale=2).images[0]
|
49 |
+
result.save("output.png")
|
|
|
|
|
|
|
|
|
50 |
```
|
51 |
|
52 |
|