thoth-AI commited on
Commit
c99069e
1 Parent(s): f30af1b

Updated handler.py

Browse files
Files changed (1) hide show
  1. handler.py +2 -9
handler.py CHANGED
@@ -28,23 +28,16 @@ class EndpointHandler:
28
  A :obj:`dict`:. The object returned should be a dict of one list like {"captions": ["A hugging face at the office"]} containing :
29
  - "caption": A string corresponding to the generated caption.
30
  """
 
31
  inputs = data.pop("inputs", data)
32
  parameters = data.pop("parameters", {})
33
 
34
  raw_images = Image.open(BytesIO(inputs))
35
-
36
- inputs = self.processor(inputs, return_tensors="pt").to("cuda")
37
 
38
  processed_image = self.processor(images=raw_images, return_tensors="pt").to(device)
39
 
40
  out = self.model.generate(**processed_image)
41
- # processed_image["pixel_values"] = processed_image["pixel_values"].to(device)
42
- # processed_image = {**processed_image, **parameters}
43
-
44
- # with torch.no_grad():
45
- # out = self.model.generate(
46
- # **processed_image
47
- # )
48
  captions = self.processor.decode(out[0], skip_special_tokens=True)
49
 
50
  # postprocess the prediction
 
28
  A :obj:`dict`:. The object returned should be a dict of one list like {"captions": ["A hugging face at the office"]} containing :
29
  - "caption": A string corresponding to the generated caption.
30
  """
31
+
32
  inputs = data.pop("inputs", data)
33
  parameters = data.pop("parameters", {})
34
 
35
  raw_images = Image.open(BytesIO(inputs))
 
 
36
 
37
  processed_image = self.processor(images=raw_images, return_tensors="pt").to(device)
38
 
39
  out = self.model.generate(**processed_image)
40
+
 
 
 
 
 
 
41
  captions = self.processor.decode(out[0], skip_special_tokens=True)
42
 
43
  # postprocess the prediction