Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- image-to-image
|
| 5 |
+
---
|
| 6 |
+
# ip2p-RoboPredict: InstructPix2Pix Fine-tuning for Robotic Action Frame Prediction
|
| 7 |
+
GitHub: https://github.com/yutengzhang03/ip2p-finetune
|
| 8 |
+
<img src='https://github.com/yutengzhang03/ip2p-finetune/blob/main/img/show-example.png'/>
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
## Example
|
| 13 |
+
|
| 14 |
+
To use `InstructPix2Pix`, install `diffusers` using `main` for now. The pipeline will be available in the next release
|
| 15 |
+
|
| 16 |
+
```bash
|
| 17 |
+
pip install diffusers accelerate safetensors transformers
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
```python
|
| 21 |
+
import PIL
|
| 22 |
+
import requests
|
| 23 |
+
import torch
|
| 24 |
+
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
|
| 25 |
+
model_id = "yutengz/ip2p-RoboPredict"
|
| 26 |
+
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None)
|
| 27 |
+
pipe.to("cuda")
|
| 28 |
+
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 29 |
+
url = "https://github.com/yutengzhang03/ip2p-finetune/blob/main/img/source.png"
|
| 30 |
+
def download_image(url):
|
| 31 |
+
image = PIL.Image.open(requests.get(url, stream=True).raw)
|
| 32 |
+
image = PIL.ImageOps.exif_transpose(image)
|
| 33 |
+
image = image.convert("RGB")
|
| 34 |
+
return image
|
| 35 |
+
image = download_image(url)
|
| 36 |
+
prompt = "turn him into cyborg"
|
| 37 |
+
images = pipe(prompt, image=image, num_inference_steps=10, image_guidance_scale=1).images
|
| 38 |
+
images[0]
|
| 39 |
+
```
|