Spaces:
Runtime error
Runtime error
alitavanaali
commited on
Commit
•
67e7382
1
Parent(s):
911803a
Update app.py
Browse files
app.py
CHANGED
@@ -32,7 +32,7 @@ from datasets import Features, Sequence, ClassLabel, Value, Array2D, Array3D
|
|
32 |
from transformers import LayoutLMv3ForTokenClassification,LayoutLMv3FeatureExtractor
|
33 |
|
34 |
# define id2label
|
35 |
-
id2label={0: '
|
36 |
custom_config = r'--oem 3 --psm 6'
|
37 |
# lang='eng+deu+ita+chi_sim'
|
38 |
lang='spa'
|
@@ -62,19 +62,19 @@ def unnormalize_box(bbox, width, height):
|
|
62 |
|
63 |
def iob_to_label(label):
|
64 |
if label == 0:
|
65 |
-
return '
|
66 |
if label == 1:
|
67 |
-
return '
|
68 |
if label == 2:
|
69 |
-
return '
|
70 |
if label == 3:
|
71 |
-
return '
|
72 |
if label == 4:
|
73 |
-
return '
|
74 |
if label == 5:
|
75 |
-
return '
|
76 |
if label == 6:
|
77 |
-
return '
|
78 |
if label == 7:
|
79 |
return 'others'
|
80 |
|
@@ -176,9 +176,10 @@ def visualize_image(final_bbox, final_preds, l_words, image):
|
|
176 |
draw = ImageDraw.Draw(image)
|
177 |
font = ImageFont.load_default()
|
178 |
|
179 |
-
label2color = {'
|
180 |
-
l2l = {'
|
181 |
-
f_labels = {'
|
|
|
182 |
|
183 |
json_df = []
|
184 |
|
|
|
32 |
from transformers import LayoutLMv3ForTokenClassification,LayoutLMv3FeatureExtractor
|
33 |
|
34 |
# define id2label
|
35 |
+
id2label = {0: 'song name', 1: 'artist', 2: 'year', 3: 'album', 4: 'genres', 5: 'song writer', 6: 'lyrics', 7: 'others'}
|
36 |
custom_config = r'--oem 3 --psm 6'
|
37 |
# lang='eng+deu+ita+chi_sim'
|
38 |
lang='spa'
|
|
|
62 |
|
63 |
def iob_to_label(label):
|
64 |
if label == 0:
|
65 |
+
return 'song name'
|
66 |
if label == 1:
|
67 |
+
return 'artist'
|
68 |
if label == 2:
|
69 |
+
return 'year'
|
70 |
if label == 3:
|
71 |
+
return 'album'
|
72 |
if label == 4:
|
73 |
+
return 'genres'
|
74 |
if label == 5:
|
75 |
+
return 'song writer'
|
76 |
if label == 6:
|
77 |
+
return 'lyrics'
|
78 |
if label == 7:
|
79 |
return 'others'
|
80 |
|
|
|
176 |
draw = ImageDraw.Draw(image)
|
177 |
font = ImageFont.load_default()
|
178 |
|
179 |
+
label2color = {'song name':'red', 'artist':'blue', 'year':'black', 'album':'green', 'genres':'brown', 'song writer':'blue', 'lyrics':'purple', 'others': 'white'}
|
180 |
+
l2l = {'song name':'red', 'artist':'blue', 'year':'black', 'album':'green', 'genres':'brown', 'song writer':'blue','lyrics':'purple', 'others':'white'}
|
181 |
+
f_labels = {'song name':'red', 'artist':'blue', 'year':'black', 'album':'green', 'genres':'brown', 'song writer':'blue','lyrics':'purple', 'others':'white'}
|
182 |
+
|
183 |
|
184 |
json_df = []
|
185 |
|