Spaces:
Runtime error
Runtime error
Rajiv Shah
commited on
Commit
Β·
9373e2d
1
Parent(s):
2726e12
slowly
Browse files
app.py
CHANGED
@@ -20,13 +20,14 @@ processor = LayoutLMv3Processor.from_pretrained("microsoft/layoutlmv3-base")
|
|
20 |
model = LayoutLMv3ForTokenClassification.from_pretrained("nielsr/layoutlmv3-finetuned-cord")
|
21 |
|
22 |
# load image example
|
23 |
-
|
24 |
#image = Image.open(dataset[0]["image_path"]).convert("RGB")
|
25 |
image = Image.open("./test0.jpeg")
|
26 |
#image.save("document.png")
|
27 |
# define id2label, label2color
|
28 |
labels = dataset.features['ner_tags'].feature.names
|
29 |
id2label = {v: k for v, k in enumerate(labels)}
|
|
|
30 |
label2color = {'question':'blue', 'answer':'green', 'header':'orange', 'other':'violet'}
|
31 |
|
32 |
def unnormalize_box(bbox, width, height):
|
|
|
20 |
model = LayoutLMv3ForTokenClassification.from_pretrained("nielsr/layoutlmv3-finetuned-cord")
|
21 |
|
22 |
# load image example
|
23 |
+
dataset = load_dataset("nielsr/cord-layoutlmv3", split="test")
|
24 |
#image = Image.open(dataset[0]["image_path"]).convert("RGB")
|
25 |
image = Image.open("./test0.jpeg")
|
26 |
#image.save("document.png")
|
27 |
# define id2label, label2color
|
28 |
labels = dataset.features['ner_tags'].feature.names
|
29 |
id2label = {v: k for v, k in enumerate(labels)}
|
30 |
+
print(id2label)
|
31 |
label2color = {'question':'blue', 'answer':'green', 'header':'orange', 'other':'violet'}
|
32 |
|
33 |
def unnormalize_box(bbox, width, height):
|