File size: 1,680 Bytes
0ced07b
65a8ae0
 
 
 
56e0324
 
 
 
0ced07b
19e942b
0ced07b
 
 
 
 
 
11dcc3a
0ced07b
56e0324
0ced07b
 
19e942b
0ced07b
2bea164
554a215
0ced07b
19e942b
0ced07b
 
19e942b
 
 
 
 
 
 
 
 
 
 
f9cfe0e
19e942b
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
base_model:
- timbrooks/instruct-pix2pix
- SherryXTChen/Instruct-CLIP
- SherryXTChen/LatentDiffusionDINOv2
datasets:
- SherryXTChen/InstructCLIP-InstructPix2Pix-Data
language:
- en
library_name: diffusers
license: apache-2.0
tags:
- stable-diffusion
- stable-diffusion-diffusers
- text-to-image
- diffusers
- diffusers-training
- image-to-image
inference: true
pipeline_tag: image-to-image
---

# InstructCLIP: Improving Instruction-Guided Image Editing with Automated Data Refinement Using Contrastive Learning

The model is based on the paper [Instruct-CLIP: Improving Instruction-Guided Image Editing with Automated Data Refinement Using Contrastive Learning](https://huggingface.co/papers/2503.18406).
GitHub: https://github.com/SherryXTChen/Instruct-CLIP.git

## Example

```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)
pipe.load_lora_weights("SherryXTChen/InstructCLIP-InstructPix2Pix")
pipe.to("cuda")
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)

url = "https://raw.githubusercontent.com/SherryXTChen/Instruct-CLIP/refs/heads/main/assets/1_input.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 = "as a 3 d sculpture"
images = pipe(prompt, image=image, num_inference_steps=20).images
images[0].save("output.jpg")
```