-
Notifications
You must be signed in to change notification settings - Fork 0
/
testip2p.py
21 lines (20 loc) · 1014 Bytes
/
testip2p.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import PIL
import torch
from pipeline_onnx_stable_diffusion_instruct_pix2pix import OnnxStableDiffusionInstructPix2PixPipeline
from diffusers import EulerAncestralDiscreteScheduler
import requests
pipe = OnnxStableDiffusionInstructPix2PixPipeline.from_pretrained("./ip2p_onnx", provider="DmlExecutionProvider", safety_checker=None)
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"
seed=42
generator = torch.Generator()
generator = generator.manual_seed(seed)
images = pipe(prompt, image=image, num_inference_steps=10, guidance_scale=7.5, image_guidance_scale=1, generator=generator).images[0]
images.save("cyborg.png")