| <!--Copyright 2023 The HuggingFace Team. All rights reserved. |
|
|
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
|
|
| http: |
|
|
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations under the License. |
| --> |
|
|
| # InstructPix2Pix: Learning to Follow Image Editing Instructions |
|
|
| ## Overview |
|
|
| [InstructPix2Pix: Learning to Follow Image Editing Instructions](https: |
|
|
| The abstract of the paper is the following: |
|
|
| |
|
|
| Resources: |
|
|
| |
| |
| |
| |
|
|
|
|
| ## Available Pipelines: |
|
|
| | Pipeline | Tasks | Demo |
| |---|---|:---:| |
| | [StableDiffusionInstructPix2PixPipeline](https: |
|
|
| <!-- TODO: add Colab --> |
|
|
| ## Usage example |
|
|
| ```python |
| import PIL |
| import requests |
| import torch |
| from diffusers import StableDiffusionInstructPix2PixPipeline |
|
|
| model_id = "timbrooks/instruct-pix2pix" |
| pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda") |
|
|
| url = "https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png" |
|
|
|
|
| def download_image(url): |
| image = PIL.Image.open(requests.get(url, stream=True).raw) |
| image = PIL.ImageOps.exif_transpose(image) |
| image = image.convert("RGB") |
| return image |
|
|
|
|
| image = download_image(url) |
|
|
| prompt = "make the mountains snowy" |
| images = pipe(prompt, image=image, num_inference_steps=20, image_guidance_scale=1.5, guidance_scale=7).images |
| images[0].save("snowy_mountains.png") |
| ``` |
|
|
| ## StableDiffusionInstructPix2PixPipeline |
| [[autodoc]] StableDiffusionInstructPix2PixPipeline |
| - __call__ |
| - all |
|
|