Update README.md
Browse files
README.md
CHANGED
|
@@ -112,3 +112,35 @@ grid
|
|
| 112 |
```
|
| 113 |
|
| 114 |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
```
|
| 113 |
|
| 114 |

|
| 115 |
+
|
| 116 |
+
## Image-to-image
|
| 117 |
+
|
| 118 |
+
We start with this image generated earlier:
|
| 119 |
+
|
| 120 |
+

|
| 121 |
+
|
| 122 |
+
```python
|
| 123 |
+
from diffusers import StableDiffusion3Img2ImgPipeline
|
| 124 |
+
from diffusers.utils import load_image
|
| 125 |
+
|
| 126 |
+
pipeline = StableDiffusion3Img2ImgPipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16)
|
| 127 |
+
|
| 128 |
+
pipeline=pipeline.to('cuda')
|
| 129 |
+
init_image = load_image("https://huggingface.co/lamm-mit/stable-diffusion-3-medium-leaf-inspired/resolve/main/image_20240721_212111.png")
|
| 130 |
+
|
| 131 |
+
prompt = "Turn this image into a spider web."
|
| 132 |
+
negative_prompt=""
|
| 133 |
+
|
| 134 |
+
n_steps=20
|
| 135 |
+
guidance_scale=25
|
| 136 |
+
|
| 137 |
+
image = pipeline(prompt, num_inference_steps=n_steps,
|
| 138 |
+
guidance_scale=guidance_scale,
|
| 139 |
+
negative_prompt=negative_prompt,
|
| 140 |
+
image=init_image,
|
| 141 |
+
).images[0]
|
| 142 |
+
save_image(image, directory='generated_images', base_name="image_grid", )
|
| 143 |
+
image
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+

|