jinhybr commited on
Commit
b1392a0
1 Parent(s): 04e6a7b

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +3 -5
handler.py CHANGED
@@ -1,7 +1,6 @@
1
  from typing import Dict, List, Any
2
- from transformers import AutoModelForTokenClassification
3
 
4
- from transformers import AutoProcessor
5
  import torch
6
  from subprocess import run
7
 
@@ -24,8 +23,6 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
24
  class EndpointHandler:
25
  def __init__(self, path=""):
26
  # load model and processor from path
27
-
28
-
29
  self.model = AutoModelForTokenClassification.from_pretrained(path).to(device)
30
  self.processor = AutoProcessor.from_pretrained(path)
31
 
@@ -63,4 +60,5 @@ class EndpointHandler:
63
  text = self.processor.tokenizer.decode(inp_ids)
64
  bbox = unnormalize_box(bbox.tolist(), image.width, image.height)
65
  result.append({"label": label, "score": score, "text": text, "bbox": bbox})
66
- return {"predictions": result}
 
 
1
  from typing import Dict, List, Any
 
2
 
3
+ from transformers import AutoModelForTokenClassification, AutoProcessor
4
  import torch
5
  from subprocess import run
6
 
 
23
  class EndpointHandler:
24
  def __init__(self, path=""):
25
  # load model and processor from path
 
 
26
  self.model = AutoModelForTokenClassification.from_pretrained(path).to(device)
27
  self.processor = AutoProcessor.from_pretrained(path)
28
 
 
60
  text = self.processor.tokenizer.decode(inp_ids)
61
  bbox = unnormalize_box(bbox.tolist(), image.width, image.height)
62
  result.append({"label": label, "score": score, "text": text, "bbox": bbox})
63
+ return {"predictions": result}
64
+