Uddipan Basu Bir commited on
Commit
4956f20
·
1 Parent(s): a63ba49

Download checkpoint from HF hub in OcrReorderPipeline

Browse files
Files changed (1) hide show
  1. inference.py +5 -5
inference.py CHANGED
@@ -29,13 +29,13 @@ class OcrReorderPipeline(Pipeline):
29
  self.projection.to(self.device)
30
 
31
  def _sanitize_parameters(self, **kwargs):
32
- # extract the pipeline 'inputs' (base64 image) and custom args
33
- image = kwargs.pop("inputs", None)
34
- words = kwargs.pop("words", None)
35
- boxes = kwargs.pop("boxes", None)
36
- return {"image": image, "words": words, "boxes": boxes}, {}, {}
37
 
38
  def preprocess(self, image, words, boxes):
 
39
  data = base64.b64decode(image)
40
  img = Image.open(BytesIO(data)).convert("RGB")
41
  return self.feature_extractor(
 
29
  self.projection.to(self.device)
30
 
31
  def _sanitize_parameters(self, **kwargs):
32
+ # Extract only the custom args for preprocess; 'inputs' (the image) is passed positionally
33
+ words = kwargs.get("words", None)
34
+ boxes = kwargs.get("boxes", None)
35
+ return {"words": words, "boxes": boxes}, {}, {}
 
36
 
37
  def preprocess(self, image, words, boxes):
38
+ # 'image' comes from the positional 'inputs' argument
39
  data = base64.b64decode(image)
40
  img = Image.open(BytesIO(data)).convert("RGB")
41
  return self.feature_extractor(