sergeipetrov commited on
Commit
b13e405
1 Parent(s): bd90d6e

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +6 -1
handler.py CHANGED
@@ -2,9 +2,12 @@ from typing import Dict, List, Any
2
  from transformers import AutoImageProcessor, Swin2SRForImageSuperResolution
3
  import torch
4
  import base64
 
5
  from PIL import Image
6
  from io import BytesIO
7
 
 
 
8
 
9
  # check for GPU
10
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
@@ -19,8 +22,10 @@ class EndpointHandler:
19
  self.model.to(device)
20
 
21
  def __call__(self, data: Any) -> List[List[Dict[str, float]]]:
22
-
 
23
  image = Image.open(BytesIO(base64.b64decode(data)))
 
24
  inputs = self.processor(image, return_tensors="pt")
25
  outputs = self.model(**inputs)
26
 
 
2
  from transformers import AutoImageProcessor, Swin2SRForImageSuperResolution
3
  import torch
4
  import base64
5
+ import logging
6
  from PIL import Image
7
  from io import BytesIO
8
 
9
+ logger = logging.getLogger()
10
+ logger.setLevel(logging.DEBUG)
11
 
12
  # check for GPU
13
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
22
  self.model.to(device)
23
 
24
  def __call__(self, data: Any) -> List[List[Dict[str, float]]]:
25
+ logger.info(f"data: {data}")
26
+ logger.info(f"data type: {type(data)}")
27
  image = Image.open(BytesIO(base64.b64decode(data)))
28
+ logger.info("image read")
29
  inputs = self.processor(image, return_tensors="pt")
30
  outputs = self.model(**inputs)
31