asoderznik commited on
Commit
4fa2b44
1 Parent(s): af3699e

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -19
handler.py CHANGED
@@ -27,29 +27,15 @@ class EndpointHandler():
27
  self.pipe = self.pipe.to(device)
28
 
29
 
30
- def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
31
  """
32
  Args:
33
- images (:obj:`string`)
34
  Return:
35
  A :obj:`dict`:. base64 encoded image
36
  """
37
- inputs = data.pop("inputs", data)
38
- logger.info(f"Printing inputs {inputs}")
39
- logger.info(f"Printing image {inputs['image']}")
40
-
41
- # decode base64 image to PIL
42
- decoded_image = Image.open(BytesIO(base64.b64decode(inputs['image'])))
43
- logger.info(f"Printing loaded image into library {decoded_image}")
44
-
45
- # run inference pipeline
46
- with autocast(device.type):
47
- upscaled_image = self.pipe(prompt="", image = decoded_image).images[0]
48
-
49
- # encode image as base 64
50
- buffered = BytesIO()
51
- upscaled_image.save(buffered, format="JPEG")
52
- img_str = base64.b64encode(buffered.getvalue())
53
 
54
  # postprocess the prediction
55
- return {"image": img_str}
 
27
  self.pipe = self.pipe.to(device)
28
 
29
 
30
+ def __call__(self, *args, **kwargs) -> List[Dict[str, Any]]:
31
  """
32
  Args:
33
+ image (:obj:`string`)
34
  Return:
35
  A :obj:`dict`:. base64 encoded image
36
  """
37
+ print(args)
38
+ print(kwargs)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  # postprocess the prediction
41
+ return {"image": "nothing"}