fashxp commited on
Commit
d96784a
1 Parent(s): eddb2e2
Files changed (1) hide show
  1. handler.py +4 -9
handler.py CHANGED
@@ -9,10 +9,10 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
9
 
10
  class EndpointHandler():
11
  def __init__(self, path=""):
12
- #model_id = "timbrooks/instruct-pix2pix"
13
- #self.pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, safety_checker=None)
14
- #self.pipe.to(device)
15
- #self.pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(self.pipe.scheduler.config)
16
 
17
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
18
  """
@@ -23,11 +23,6 @@ class EndpointHandler():
23
  A :obj:`string`:. Base64 encoded image string
24
  """
25
 
26
- model_id = "timbrooks/instruct-pix2pix"
27
- self.pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, safety_checker=None)
28
- self.pipe.to(device)
29
- self.pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(self.pipe.scheduler.config)
30
-
31
 
32
  image_data = data.pop("inputs", data)
33
  # decode base64 image to PIL
 
9
 
10
  class EndpointHandler():
11
  def __init__(self, path=""):
12
+ model_id = "timbrooks/instruct-pix2pix"
13
+ self.pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, safety_checker=None)
14
+ self.pipe.to(device)
15
+ self.pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(self.pipe.scheduler.config)
16
 
17
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
18
  """
 
23
  A :obj:`string`:. Base64 encoded image string
24
  """
25
 
 
 
 
 
 
26
 
27
  image_data = data.pop("inputs", data)
28
  # decode base64 image to PIL