asoderznik commited on
Commit
b4614a6
1 Parent(s): d4c5cc1

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +4 -3
handler.py CHANGED
@@ -2,7 +2,7 @@ from typing import Dict, List, Any
2
  from PIL import Image
3
  import torch
4
  from torch import autocast
5
- from diffusers import StableDiffusionPipeline
6
  import base64
7
  from io import BytesIO
8
  from transformers.utils import logging
@@ -24,7 +24,7 @@ class EndpointHandler():
24
  self.path = path
25
  # load the optimized model
26
  #model_id = "stabilityai/stable-diffusion-x4-upscaler"
27
- self.pipe = StableDiffusionPipeline.from_pretrained(path, torch_dtype=torch.float16)
28
  self.pipe = self.pipe.to(device)
29
 
30
 
@@ -44,9 +44,10 @@ class EndpointHandler():
44
  image_bytes = BytesIO(image_base64)
45
  logger.info('image_bytes')
46
  image = Image.open(image_bytes)
 
47
  logger.info('image')
48
  with autocast(device.type):
49
- upscaled_image = self.pipe(prompt="", image = image).images[0]
50
 
51
  #buffered = BytesIO()
52
  #upscaled_image.save(buffered, format="JPEG")
 
2
  from PIL import Image
3
  import torch
4
  from torch import autocast
5
+ from diffusers import StableDiffusionUpscalePipeline
6
  import base64
7
  from io import BytesIO
8
  from transformers.utils import logging
 
24
  self.path = path
25
  # load the optimized model
26
  #model_id = "stabilityai/stable-diffusion-x4-upscaler"
27
+ self.pipe = StableDiffusionUpscalePipeline.from_pretrained(path, torch_dtype=torch.float16)
28
  self.pipe = self.pipe.to(device)
29
 
30
 
 
44
  image_bytes = BytesIO(image_base64)
45
  logger.info('image_bytes')
46
  image = Image.open(image_bytes)
47
+ prompt = inputs['prompt']
48
  logger.info('image')
49
  with autocast(device.type):
50
+ upscaled_image = self.pipe(prompt, image).images[0]
51
 
52
  #buffered = BytesIO()
53
  #upscaled_image.save(buffered, format="JPEG")