Commit
·
02bc627
1
Parent(s):
5d2161b
update readme
Browse files
README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-4.0
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-4.0
|
| 3 |
---
|
| 4 |
+
## Example Usage
|
| 5 |
+
````py
|
| 6 |
+
import torch
|
| 7 |
+
from diffusers import SD3Transformer2DModel
|
| 8 |
+
from diffusers import DiffusionPipeline
|
| 9 |
+
from diffusers.utils import load_image
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
resolution = 512
|
| 13 |
+
image = load_image("https://hf.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png").resize(
|
| 14 |
+
(resolution, resolution)
|
| 15 |
+
)
|
| 16 |
+
edit_instruction = "Turn sky into a sunny one"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
pipe = DiffusionPipeline.from_pretrained(
|
| 20 |
+
"stabilityai/stable-diffusion-3-medium-diffusers", custom_pipeline="pipeline_stable_diffusion_3_instruct_pix2pix", torch_dtype=torch.float16).to('cuda')
|
| 21 |
+
|
| 22 |
+
pipe.transformer = SD3Transformer2DModel.from_pretrained("CaptainZZZ/sd3-instructpix2pix",torch_dtype=torch.float16).to('cuda')
|
| 23 |
+
|
| 24 |
+
edited_image = pipe(
|
| 25 |
+
prompt=edit_instruction,
|
| 26 |
+
image=image,
|
| 27 |
+
height=resolution,
|
| 28 |
+
width=resolution,
|
| 29 |
+
guidance_scale=7.5,
|
| 30 |
+
image_guidance_scale=1.5,
|
| 31 |
+
num_inference_steps=30,
|
| 32 |
+
).images[0]
|
| 33 |
+
|
| 34 |
+
edited_image.save("edited_image.png")
|
| 35 |
+
````
|
| 36 |
+
|Original|Edited|
|
| 37 |
+
|---|---|
|
| 38 |
+
||
|
| 39 |
+
|
| 40 |
+
### Note
|
| 41 |
+
This model is trained on 512x512, so input size is better on 512x512.
|
| 42 |
+
For better editing performance, please refer to this powerful model https://huggingface.co/BleachNick/SD3_UltraEdit_freeform and Paper "UltraEdit: Instruction-based Fine-Grained Image
|
| 43 |
+
Editing at Scale", many thanks to their contribution!
|