Instructions to use OtraBoi/document_classifier_testing with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OtraBoi/document_classifier_testing with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="OtraBoi/document_classifier_testing")# Load model directly from transformers import AutoProcessor, AutoModelForSequenceClassification processor = AutoProcessor.from_pretrained("OtraBoi/document_classifier_testing") model = AutoModelForSequenceClassification.from_pretrained("OtraBoi/document_classifier_testing") - Notebooks
- Google Colab
- Kaggle
Commit ·
4799f35
1
Parent(s): 96ac1a0
update handler
Browse files- handler.py +3 -2
handler.py
CHANGED
|
@@ -21,8 +21,9 @@ class EndpointHandler:
|
|
| 21 |
self.PROCESSOR = LayoutLMv3Processor(self.FEATURE_EXTRACTOR, self.TOKENIZER)
|
| 22 |
self.MODEL = LayoutLMv3ForSequenceClassification.from_pretrained("OtraBoi/document_classifier_testing").to(device)
|
| 23 |
|
| 24 |
-
def __call__(self, data: Dict):
|
| 25 |
-
image = Image.open(io.BytesIO(data["inputs"])).convert("RGB")
|
|
|
|
| 26 |
encoding = self.PROCESSOR(image, return_tensors="pt", padding="max_length", truncation=True)
|
| 27 |
|
| 28 |
for k,v in encoding.items():
|
|
|
|
| 21 |
self.PROCESSOR = LayoutLMv3Processor(self.FEATURE_EXTRACTOR, self.TOKENIZER)
|
| 22 |
self.MODEL = LayoutLMv3ForSequenceClassification.from_pretrained("OtraBoi/document_classifier_testing").to(device)
|
| 23 |
|
| 24 |
+
def __call__(self, data: Dict[str, bytes]):
|
| 25 |
+
#image = Image.open(io.BytesIO(data["inputs"])).convert("RGB")
|
| 26 |
+
image = data.pop("inputs", data)
|
| 27 |
encoding = self.PROCESSOR(image, return_tensors="pt", padding="max_length", truncation=True)
|
| 28 |
|
| 29 |
for k,v in encoding.items():
|