Views
No views yet
InstructPix2Pix, install diffusers using main for now. The pipeline will be available in the next releasepip install diffusers accelerate safetensors transformers1import PIL
2import requests
3import torch
4from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
5
6model_id = "yutengz/Action2Vision"
7pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None)
8pipe.to("cuda")
9pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
10
11
12to_tensor = transforms.ToTensor()
13resize = transforms.Resize((256, 256))
14
15def download_image(URL):
16 return PIL.Image.open(requests.get(url, stream=True).raw).convert("RGB").resize((256, 256))
17
18url = "https://github.com/yutengzhang03/Action2Vision/blob/main/img/source.png"
19image = download_image(url)
20prompt = "There is a hammer and a block in the middle of the table. If the block is closer to the left robotic arm, it uses the left arm to pick up the hammer and strike the block; otherwise, it does the opposite."
21images = pipe(prompt, image=image).images
22images[0]