asoderznik commited on
Commit
732c9a5
1 Parent(s): bdb5d3a

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -5
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 DiffusionPipeline
6
  import base64
7
  from io import BytesIO
8
  from transformers.utils import logging
@@ -16,15 +16,15 @@ logger.warning("WARN")
16
  # set device
17
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
18
 
19
- #if device.type != 'cuda':
20
- #raise ValueError("need to run on GPU")
21
 
22
  class EndpointHandler():
23
  def __init__(self, path=""):
24
  self.path = path
25
  # load the optimized model
26
- model_id = "stabilityai/stable-diffusion-x4-upscaler"
27
- self.pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
28
  self.pipe = self.pipe.to(device)
29
 
30
 
 
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
 
16
  # set device
17
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
18
 
19
+ if device.type != 'cuda':
20
+ raise ValueError("need to run on GPU")
21
 
22
  class EndpointHandler():
23
  def __init__(self, path=""):
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