Spaces:
Runtime error
Runtime error
Rajiv Shah
commited on
Commit
Β·
ce0f679
1
Parent(s):
da3b44f
PIL error
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ import gradio as gr
|
|
14 |
import numpy as np
|
15 |
from transformers import LayoutLMv3Processor, LayoutLMv3ForTokenClassification
|
16 |
from datasets import load_dataset
|
17 |
-
from PIL import Image, ImageDraw, ImageFont
|
18 |
|
19 |
processor = LayoutLMv3Processor.from_pretrained("microsoft/layoutlmv3-base")
|
20 |
model = LayoutLMv3ForTokenClassification.from_pretrained("nielsr/layoutlmv3-finetuned-cord")
|
@@ -28,8 +28,8 @@ image = Image.open("./test0.jpeg")
|
|
28 |
labels = dataset.features['ner_tags'].feature.names
|
29 |
id2label = {v: k for v, k in enumerate(labels)}
|
30 |
|
31 |
-
label_ints = np.random.randint(0, len(
|
32 |
-
label_color_pil = [k for k,_ in
|
33 |
label_color = [label_color_pil[i] for i in label_ints]
|
34 |
label2color = {}
|
35 |
for k,v in id2label.items():
|
|
|
14 |
import numpy as np
|
15 |
from transformers import LayoutLMv3Processor, LayoutLMv3ForTokenClassification
|
16 |
from datasets import load_dataset
|
17 |
+
from PIL import Image, ImageDraw, ImageFont, ImageColor
|
18 |
|
19 |
processor = LayoutLMv3Processor.from_pretrained("microsoft/layoutlmv3-base")
|
20 |
model = LayoutLMv3ForTokenClassification.from_pretrained("nielsr/layoutlmv3-finetuned-cord")
|
|
|
28 |
labels = dataset.features['ner_tags'].feature.names
|
29 |
id2label = {v: k for v, k in enumerate(labels)}
|
30 |
|
31 |
+
label_ints = np.random.randint(0, len(ImageColor.colormap.items()), 60)
|
32 |
+
label_color_pil = [k for k,_ in ImageColor.colormap.items()]
|
33 |
label_color = [label_color_pil[i] for i in label_ints]
|
34 |
label2color = {}
|
35 |
for k,v in id2label.items():
|