anujg1508 commited on
Commit
ffa81ea
·
1 Parent(s): 5047451

change pipeline to user StableDiffusionXLPipeling

Browse files
Files changed (1) hide show
  1. handler.py +3 -3
handler.py CHANGED
@@ -1,7 +1,7 @@
1
  from typing import Dict, List, Any
2
  import torch
3
  from torch import autocast
4
- from diffusers import StableDiffusionAdapterPipeline
5
  import base64
6
  from io import BytesIO
7
 
@@ -13,7 +13,7 @@ if device.type != "cuda":
13
 
14
  class EndpointHandler():
15
  def __init__(self, path="") :
16
- self.pipe = StableDiffusionAdapterPipeline.from_pretrained(path, feature_extractor=None, adapter=None, safety_checker=None, torch_dtype=torch.float16)
17
  self.pipe = self.pipe.to(device)
18
 
19
 
@@ -21,7 +21,7 @@ class EndpointHandler():
21
  inputs = data.pop("inputs", data)
22
 
23
  with autocast(device.type):
24
- image = self.pipe(inputs, guidance_scale=7.5)["samples"][0]
25
 
26
  buffered = BytesIO()
27
  image.save(buffered, format="JPEG")
 
1
  from typing import Dict, List, Any
2
  import torch
3
  from torch import autocast
4
+ from diffusers import StableDiffusionXLPipeline
5
  import base64
6
  from io import BytesIO
7
 
 
13
 
14
  class EndpointHandler():
15
  def __init__(self, path="") :
16
+ self.pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
17
  self.pipe = self.pipe.to(device)
18
 
19
 
 
21
  inputs = data.pop("inputs", data)
22
 
23
  with autocast(device.type):
24
+ image = self.pipe(inputs, guidance_scale=7.5).images[0]
25
 
26
  buffered = BytesIO()
27
  image.save(buffered, format="JPEG")