---
title: instruct-pix2pix
canonical_url: "https://www.modelscope.cn/models/AI-ModelScope/instruct-pix2pix"
md_url: "https://www.modelscope.cn/models/AI-ModelScope/instruct-pix2pix.md"
repository: AI-ModelScope/instruct-pix2pix
last_updated: 2024-06-06
license: mit
parameters: 4.7B
tensor_type:
  - F32
  - F16
  - I32
  - I64
library_name:
  - pytorch
  - safetensors
  - diffusers
frameworks:
  - pytorch
downloads: 5713
stars: 5
tags:
  - image-to-image
---

# instruct-pix2pix

> instruct-pix2pix - AI-ModelScope 在 ModelScope 开源的模型。InstructPix2Pix: Learning to Follow Image Editing Instructions GitHub: https://github.com/timothybrooks/instruct-pix2pix

AI-ModelScope/instruct-pix2pix 是 ModelScope 魔搭社区上的 4.7B 参数机器学习模型，采用 mit 许可。

- **Repository**: AI-ModelScope/instruct-pix2pix
- **License**: mit
- **Parameters**: 4.7B
- **Tags**: image-to-image
- **Downloads**: 5713
- **Stars**: 5
- **Last updated**: 2024-06-06

Source: https://www.modelscope.cn/models/AI-ModelScope/instruct-pix2pix

---

# InstructPix2Pix: Learning to Follow Image Editing Instructions
GitHub: https://github.com/timothybrooks/instruct-pix2pix
<img src='https://instruct-pix2pix.timothybrooks.com/teaser.jpg'/>



## Example

To use `InstructPix2Pix`, install `diffusers` using `main` for now. The pipeline will be available in the next release

```bash
pip install diffusers accelerate safetensors transformers
```

```python
import PIL
import requests
import torch
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler

model_id = "timbrooks/instruct-pix2pix"
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None)
pipe.to("cuda")
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)

url = "https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/main/imgs/example.jpg"
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 = "turn him into cyborg"
images = pipe(prompt, image=image, num_inference_steps=10, image_guidance_scale=1).images
images[0]
```
