Tried to use OpenCl for my AMD

#7
by THALES352 - opened

import PIL
import matplotlib
import requests
import pyopencl as cl

from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler

model_id = "timbrooks/instruct-pix2pix"
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, 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"
images = pipe.run_on_opencl(prompt, image, num_inference_steps=10, image_guidance_scale=1).images
images[0].save("output.jpg")

matplotlib.pyplot.imshow(images[0])

But unfortunately it said it couldn't find the model.safetensors file, and even if it did find my board, it probably wouldn't do the trick. But found it useful for those with AMD cards.

Sign up or log in to comment