Spaces:
Running
Running
Uddipan Basu Bir
commited on
Commit
·
4956f20
1
Parent(s):
a63ba49
Download checkpoint from HF hub in OcrReorderPipeline
Browse files- 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 |
-
#
|
33 |
-
|
34 |
-
|
35 |
-
|
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(
|