Closed NicholasKao1029 closed 1 year ago
Changed to
from PIL import Image
from io import BytesIO
from diffusers import StableDiffusionUpscalePipeline
import torch
import requests
import oneflow as flow
def url_to_image(url):
# Send a HTTP request to the URL of the image
response = requests.get(url)
# Raise an exception if the GET request was unsuccessful
response.raise_for_status()
# Get the content of the response and turn it into a PIL image
img = Image.open(BytesIO(response.content))
return img
def upscale_ai(img_url, scale):
low_res_img = url_to_image(img_url)
print('low res image got')
prompt = "beautiful woman"
model_id = "stabilityai/stable-diffusion-x4-upscaler"
flow.mock_torch.disable()
pipeline = StableDiffusionUpscalePipeline.from_pretrained(model_id)
print('pipe')
upscaled_image = pipeline(prompt=prompt, image=low_res_img, num_inference_steps=50).images[0]
flow.mock_torch.enable()
return upscaled_image
and now getting
pipe
to() received an invalid combination of arguments - got (oneflow._oneflow_internal.device), but expected one of:
* (torch.device device, torch.dtype dtype, bool non_blocking, bool copy, *, torch.memory_format memory_format)
* (torch.dtype dtype, bool non_blocking, bool copy, *, torch.memory_format memory_format)
* (Tensor tensor, bool non_blocking, bool copy, *, torch.memory_format memory_format)
^CStack trace (most recent call last):
[2023-06-01 01:54:37 +0000] [6585] [INFO] Handling signal: int
Stack trace (most recent call last) in thread 6651:
Object "/opt/conda/lib/python3.8/site-packages/oneflow/../oneflow.libs/liboneflow-f60617dd.so", at 0x7f07310e3f15, in AbortSignalHandler(int)
Aborted (Signal sent by tkill() 6587 0)
Running upscaler for simple stable diffusion in a server that has oneflow in it causes issues