Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,22 +30,31 @@ Image.open(dataset[2]["image_path"]).convert("RGB").save("example1.png")
|
|
| 30 |
Image.open(dataset[1]["image_path"]).convert("RGB").save("example2.png")
|
| 31 |
Image.open(dataset[0]["image_path"]).convert("RGB").save("example3.png")
|
| 32 |
# define id2label, label2color
|
| 33 |
-
labels = dataset.features['ner_tags'].feature.names
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
"B-
|
| 46 |
-
"
|
| 47 |
-
"
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
def unnormalize_box(bbox, width, height):
|
| 51 |
return [
|
|
|
|
| 30 |
Image.open(dataset[1]["image_path"]).convert("RGB").save("example2.png")
|
| 31 |
Image.open(dataset[0]["image_path"]).convert("RGB").save("example3.png")
|
| 32 |
# define id2label, label2color
|
| 33 |
+
#labels = dataset.features['ner_tags'].feature.names
|
| 34 |
+
labels = ['O', 'HEADER', 'SUBHEADER', 'TEXTO', 'NUMERAL', 'RESUMEN']
|
| 35 |
+
#id2label = {v: k for v, k in enumerate(labels)}
|
| 36 |
+
id2label = {0: 'O', 1: 'HEADER', 2: 'SUBHEADER', 3: 'TEXTO', 4: 'NUMERAL', 5: 'RESUMEN'}
|
| 37 |
+
label2color = {'O': 'violet',
|
| 38 |
+
'HEADER': 'orange',
|
| 39 |
+
'SUBHEADER': 'blue',
|
| 40 |
+
'TEXTO': 'green',
|
| 41 |
+
'NUMERAL': 'yellow',
|
| 42 |
+
'RESUMEN': 'black',}
|
| 43 |
+
|
| 44 |
+
#label2color = {
|
| 45 |
+
# "B-ABN": 'blue',
|
| 46 |
+
# "B-BILLER": 'blue',
|
| 47 |
+
# "B-BILLER_ADDRESS": 'green',
|
| 48 |
+
# "B-BILLER_POST_CODE": 'orange',
|
| 49 |
+
# "B-DUE_DATE": "blue",
|
| 50 |
+
# "B-GST": 'green',
|
| 51 |
+
# "B-INVOICE_DATE": 'violet',
|
| 52 |
+
# "B-INVOICE_NUMBER": 'orange',
|
| 53 |
+
# "B-SUBTOTAL": 'green',
|
| 54 |
+
# "B-TOTAL": 'blue',
|
| 55 |
+
# "I-BILLER_ADDRESS": 'blue',
|
| 56 |
+
# "O": 'orange'
|
| 57 |
+
# }
|
| 58 |
|
| 59 |
def unnormalize_box(bbox, width, height):
|
| 60 |
return [
|