pierreguillou
commited on
Commit
•
2f13069
1
Parent(s):
4501585
Update app.py
Browse files
app.py
CHANGED
@@ -55,10 +55,16 @@ os.system('python -m pip install --upgrade pip')
|
|
55 |
import torch
|
56 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
57 |
|
58 |
-
|
59 |
-
|
60 |
model_id = "pierreguillou/lilt-xlm-roberta-base-finetuned-with-DocLayNet-base-at-linelevel-ml384"
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
model2 = LayoutLMv2ForTokenClassification.from_pretrained(model_id);
|
63 |
model2.to(device);
|
64 |
|
@@ -68,7 +74,8 @@ feature_extractor = LayoutLMv2FeatureExtractor(apply_ocr=False)
|
|
68 |
|
69 |
# tokenizer
|
70 |
from transformers import AutoTokenizer
|
71 |
-
|
|
|
72 |
|
73 |
# APP outputs
|
74 |
def app_outputs(uploaded_pdf):
|
|
|
55 |
import torch
|
56 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
57 |
|
58 |
+
# model 1
|
59 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
60 |
model_id = "pierreguillou/lilt-xlm-roberta-base-finetuned-with-DocLayNet-base-at-linelevel-ml384"
|
61 |
+
tokenizer1 = AutoTokenizer.from_pretrained(model_id)
|
62 |
+
model1 = AutoModelForTokenClassification.from_pretrained(model_id);
|
63 |
+
model1.to(device);
|
64 |
+
|
65 |
+
# model 2
|
66 |
+
from transformers import LayoutLMv2ForTokenClassification # LayoutXLMTokenizerFast,
|
67 |
+
model_id = "pierreguillou/layout-xlm-base-finetuned-with-DocLayNet-base-at-linelevel-ml384"
|
68 |
model2 = LayoutLMv2ForTokenClassification.from_pretrained(model_id);
|
69 |
model2.to(device);
|
70 |
|
|
|
74 |
|
75 |
# tokenizer
|
76 |
from transformers import AutoTokenizer
|
77 |
+
tokenizer_id = "xlm-roberta-base"
|
78 |
+
tokenizer2 = AutoTokenizer.from_pretrained(tokenizer_id)
|
79 |
|
80 |
# APP outputs
|
81 |
def app_outputs(uploaded_pdf):
|