Dataset Viewer
Auto-converted to Parquet Duplicate
image_id
int64
0
3.48k
image
imagewidth (px)
400
3.52k
width
int64
400
3.52k
height
int64
299
11.5k
objects
sequence
ground_truth
dict
0
815
1,623
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 ], "area": [ 34323, 3634, 21731, 22560, 20610, 217...
{ "gt_parse": { "headline": [ "މާދަމާގެ އެއްވުމަށް ފުލުހުން ޝަރުތުތަކެއް ކަނޑައަޅައި އަދާލަތު ޕާޓީ އަށް ސިޓީ", "ފޮނުވައިފި" ], "textline": [ "ސަރުކާރާ ދެކޮޅަށް އިދިކޮޅު މީހުން މާދަމާ މާލޭގައި ބާއްވާ އެއްވުމަށް ގިނަ ޝަރުތުތަކެއް ކޮށް، ފުލުހުން އަދާލަތު ޕާޓީ އަށް މިއަދު", "ސިޓީއެއް ފ...
1
2,338
2,667
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4...
{ "gt_parse": { "headline": [ "ފެން ހޮޅި އުފެއްދުމުގެ މަސައްކަތް އެމްޑަބްލިއުއެސްސީން", "ފަށަައިފި" ], "textline": [ "ފެނާއި ނަރުދަމާ އަދި އިމާރާތް ކުރުމުގެ ދާއިރާ އަށް ވަރަށް މުހިއްމު ވަސީލަތެއް", "ވަޒީފާގެ ރަނުގެ ފުރުސަތުތަކެއް ވެސް ފަހިވެގެން ގޮސްފައިވާ ކަމަށެވެ. \"އަޅުގަނޑުމެން...
2
1,814
1,985
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4...
{ "gt_parse": { "headline": [ "އީޔޫން ރާއްޖެއާ ދެކޮޅަށް ފާސްކުރީ \"ހަރުކަށި ގަރާރެއް\": ތަޖުރިބާކާރުން" ], "textline": [ "ކުރީގެ ރައީސް މުހައްމަދު ނަޝީދު ވަގުތުން ދޫކޮށްލާށާއި ހުދުމުހުތާރު ވެރިކަމަކާ ދިމާއަށް ރާއްޖެ މިސްރާބު ޖަހާފައިވާ ކަމަށް", "ގައުމަކަށް ވެސް ފުރަތަމަ ދެނީ ފުރުސަތު ކަމ...
3
556
569
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ], "area": [ 15795, 12570, 13454, 13021, 13536, 12900, 11774, 12864, 12339, 13952, 12296, 11165, 7884 ], "bbox": [ [ 91, 48, 405, ...
{ "gt_parse": { "headline": [ "ހުއްދަ ނެތި އުތުރު ބަނދަރަށް ނޫސްވެރިން ވަނުން މަނާކޮށްފި" ], "textline": [ "ހުއްދަ ނެތި، މާލޭ އުތުރު ފަރާތުގެ އާ ޖެޓީ ނުވަތަ މީރުބަހުރު ބަނދަރަށް", "ނޫސްވެރިން ވަނުން މޯލްޑިވްސް ޕޯޓްސް ލިމިޓެޑުން މިއަދު މަނާކޮށްފި އެވެ.", "އާންމުކޮށް ހުޅުވާލާފައި އޮނ...
4
421
1,539
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 ], "area": [ 14742, 11310, 599...
{ "gt_parse": { "headline": [ "ނަޝީދު ދޫކޮށްލުމުގެ ކުރިއަކުން", "މަސައްކަތެއް ހުއްޓަލެއް ނުލާނަން:", "ވަކީލް އަމާލް" ], "textline": [ "ޓެރަރިޒަމްގެ ކުށުގައި 13 އަހަރަށް ޖަލަށް ލާފައިވާ ކުރީގެ", "ރައީސް މުހައްމަދު ނަޝީދު މިނިވަންކުރުމުގެ ކުރިއަކުން", "ވަކީލުންގެ މަސައްކަ...
5
482
1,280
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ], "area": [ 15888, 6720, 13908, 13912, 13728, 12358, 14402, 12460, 14625, 14706, ...
{ "gt_parse": { "headline": [ "މާބްލް ހޮޓަލާ މެދު ފިޔަވަޅު އަޅައިދޭން", "ފުލުހުން އެދިއްޖެ" ], "textline": [ "މާބްލް ހޮޓާ ކައިރީގައި ހުންނަ ގުދަނެއް ފާސްކޮށް،", "ރޭ ގިނަ އަދަދެެއްގެ ރާ ފުޅި އަތުލައިގެންފައިވާއިރު، އެ", "ރާފުޅިތަކާ އެ ހޮޓަލާ ގުޅުން ހުރި ކަމަށް ބެލެވޭތީ،", ...
6
828
1,684
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 ], "area": [ 17094, 23544, 24850, 25620, 23240, 24...
{ "gt_parse": { "headline": [ "ރައީސަށް އަޑުއިވެން ފަށައިފި، އާ ދުވަހެއް ފެންނާނެ: އަމީން" ], "textline": [ "އަނިޔާވެރިކަން ހުއްޓާލަން ގޮވާލައި އިދިކޮޅު ފަރާތްތަކުން ދައްކާ ވާހަކަ ރައީސް އަބްދުﷲ ޔާމީނަށް", "އަޑުއިވިވަޑައިގަންނަވަން ފަށައިފި ކަމަށާއި ދިވެހިން އެދޭ \"އާ ދުވަހެއް\" ދައްކައި...
7
452
1,277
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ], "area": [ 14996, 12395, 10920, 11130, 11662, 11700, 11725, 12240, 12456, ...
{ "gt_parse": { "headline": [ "މުޒާހަރާތަކާ ދެކޮޅަށް އަނިޔާވެރިނުވުމަށާއި", "މަރުގެ އަދަބު ނުދޭން ރާއްޖެ އަށް ގޮވާލާ", "ގަރާރު އީޔޫން ފާސްކޮށްފި" ], "textline": [ "ރާއްޖޭގައި ސުލްހަވެރިކަމާ އެކު ކުރާ މުޒާހަރާތަކާ", "ދެކޮޅަށް އަނިޔާވެރިވުންހުއްޓާލުމަށާއި މަރުގެ އަދަބު", ...
8
427
3,338
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4...
{ "gt_parse": { "headline": [ "މާދަމާގެ އެއްވުމުގައި ހަމަނުޖެހުން", "ހިންގާނެ ކަމަކަށް ނުބެލެވޭ:", "އިލެކްޝަަންސް" ], "textline": [ "ސިޔާސީ ޕާޓީތަކުން މާދަމާ ބާއްވާ އެއްވުމަކީ ގާނޫނީ", "އިމުގެ ތެރޭގައި ސުލްހަވެރިކަމާ އެކު ބާއްވާ އެއްވުމެއް", "ކަމަށް ޕާޓީތަކުން ޔަގީންކަނ...
9
637
2,021
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4...
{ "gt_parse": { "headline": [ "ދައުލަތުގެ މީޑިއާ ހިންގާ ބޯޑުގެ މެންބަރުންނަށް ރުހުން ދީ،", "މުސާރަ ކަނޑައަޅައިފި" ], "textline": [ "ސަރުކާރުން އުފެއްދި ދައުލަތުގެ މީޑިއާ ހިންގާ ކުންފުނީގެ ބޯޑަށް އައްޔަންކުރުމަށް ރައީސް", "ޔާމީން މަޖިލީހަށް ހުށަހެޅުއްވި މެންބަރުންނަށް ރައްޔިތުންގެ މ...
10
448
2,519
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4...
{ "gt_parse": { "headline": [ "ސިޔާސީ ފަރާތްތަކާ އެކު މަޝްވަރާކޮށް", "ހައްލެއް ހޯދުން މުހިންމު: އީޔޫ" ], "textline": [ "ސިޔާސީ ހާސްކަން ފިލުވާލުމަށާއި އަމާން ވެއްޓެއް", "ގާއިމްކުރުމަށް ޓަކައިި ސިޔާސީ ފަރާތްތަކާ ވާހަކަ ދެއްކުން ވަރަށް", "މުހިންމު ކަމަށާއި އެކަމަށް ބާރު އަޅައި ...
11
415
1,725
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 ], "area": [ 10260, 1505, 8960, 10989, ...
{ "gt_parse": { "headline": [ "އިމްރާން މިއަދު އިމިގްރޭޝަނަށް ހާޒިރެއް", "ނުކުރި" ], "textline": [ "އަދާލަތު ޕާޓީގެ ރައީސް ޝެއިހް އިމްރާން", "އަބްދުﷲ، ޕާސްޕޯޓް ހިފައިގެންޑިޕާޓްމެންޓް އޮފް", "އިމިގްރޭޝަނަށް މިއަދު ހަވީރު ހާޒިރުވުމަށް", "އެޑިޕާޓްމެންޓުން އެންގި ނަމަވެސް އ...
12
464
1,085
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ], "area": [ 11653, 10857, 6804, 9019, 9870, 10410, 11284, 10170, 11067, 82416, 6090, 10440, 10261, 9610, 11070, 1...
{ "gt_parse": { "headline": [ "ހަމަޖެހުން ނަގާލުމުގެ އެއްވުންތަކުގައި", "ބައިވެރިނުވަން ނައިބު ރައީސް", "އިލްތިމާސްކުރައްވައިފި" ], "textline": [ "ގައުމުގެ މަސްލަހަތާއި އަމާންކަމާއި ސުލްހަ މަސަލަސްކަން", "ނަގާލައި، ހަމަނުޖެހުމަށް މަގުފަހިކުރަން ބާއްވާ އެއްވުންތަކުގައި", ...
13
645
1,717
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 ], "area": [ 25694, 23482, 15990, 16200, 16960, 14529, ...
{ "gt_parse": { "headline": [ "ގަދަކަމުން ވެރިކަން ހޯދުމާއި ގަދަކަމުން ވެރިކަން", "ދެމެެހެއްޓުމަކީ ކުރާނެ ކަމެއް ނޫން: ރައީސް" ], "textline": [ "ކޮންމެ ގޮތަކުން ނަމަވެސް ވެރިކަން ހޯދައިގެން ވެރިކަން ދެމެެހެއްޓުމަކީ ޕީޕީއެމްގެ ސަރުކާރަކުން ކުރާނެ", "ކަމެއް ނޫން ކަމަށާއި އެ ޕާޓީގެ ފި...
14
580
2,961
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4...
{ "gt_parse": { "headline": [ "ފާތުމަ މަރާލި މައްސަލަ ޝަހީމްގެ މައްޗަށް ސާބިތެއް ނުވި" ], "textline": [ "ހދ. ނޭކުރެންދޫ، ރަންވިލު، ފާތިމަތު ޒަކަރިއްޔާ (ފާތުމަ ދައިތަ)", "މަރާލުމުގެދައުވާ އުފުލާފައިވާ ކ. ގުރައިދޫ ގުލްހަޒާރުގޭ އަލީ", "ޝަހީމުގެ މައްޗަށް އެކުށް ސާބިތުނުވާ ކަމަށް މިއަދު...
15
1,325
1,682
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4...
{ "gt_parse": { "headline": [ "އަދީބަކީ ރާއްޖޭގައި ނެތްވަރުގެ ބޮޑު ފާސިދު، ފާސިގު، މުޖްރިމެއް:", "އިމްރާން" ], "textline": [ "ރައީސް އަބްދުﷲ ޔާމީންގެ ކުރިފުޅުމަތީގައި ޓޫރިޒަމް މިނިސްޓަރު އަހްމަދު އަދީބަކީ", "އެވެ.ހޮޓަލް ޖެންގައި ޕީޕީއެމުން ބޭއްވި ރަސްމިއްޔާތުގައި ރައީސް ޔާމީން ވިދާ...
16
1,288
988
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 ], "area": [ 24248, 9900, 361584, 14198, 13311, 13...
{ "gt_parse": { "headline": [ "މިލަންދޫގައި ގެއްލިގެން ހޯދަމުން ދިޔަ މީހަކު މޫދުގައި", "މަރުވެފައި އޮއްވައި ފެނިއްޖެ" ], "textline": [ "ށ. މިލަންދޫން ގެއްލިގެން ހޯދަމުން ދިޔަ މީހަކު މޫދުގައި މަރުވެފައި އޮއްވައި ރޭ ފެނިއްޖެ", "އެބަ ތިއްބެ އެވެ.", "ށ. މިލަންދޫން ގެއްލިގެން ހޯދަ...
17
427
1,319
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 ], "area":...
{ "gt_parse": { "headline": [ "އިމްރާން ކުރައްވާ މަސައްކަތަކުން އެއްވެސް", "ދިރުމެއް ނުފެނޭ: ރައީސް" ], "textline": [ "އަދާލަތު ޕާޓީގެ ރައީސް އިމްރާން އަބްދުﷲ މަގުމައްޗަށް ނިކުމެވަޑައިގެން", "މިހާރު ކުރައްވަމުން ގެންދަވާ މަސައްކަތުން އެއްވެސް ދިރުމެއް ނުފެންނަ", "ކަމަށް ރައީސ...
18
485
1,747
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ], "area": [ 17296, 8448, 11594, 13755, 14004,...
{ "gt_parse": { "headline": [ "ލޯފަން ކުދިންނަށް ހާއްސަ މުސްހަފް އެ ކުދިންގެ", "ޖަމިއްޔާ އަށް ހަދިޔާކޮށްފި" ], "textline": [ "ލޯފަން ކުދިން ކިޔެވުމަށް ހާއްސަކޮށް ތައްޔާރުކޮށްފައި ހުންނަ", "މުސްހަފް އިސްލާމިކް މިނިސްޓްރީގެ ފަރާތުން ލޯފަން ކުދިންގެ ޖަމިއްޔާ", "އަށް މިއަދު ހަދިޔ...
19
556
2,338
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4...
{ "gt_parse": { "headline": [ "ސިފައިންގެ ތެރެއަށް ސިޔާސީ ކަންކަން ވަދެގެން", "ނުވާނެ: ރައީސް" ], "textline": [ "ސިފައިންގެ ތެރެއަށް ސިޔާސީ ކަންކަން ވަދެގެން ނުވާނެ ކަމަށާއި ގައުމުގެ", "ހާލަތު ބަދަލުވެގެން ދަނީ ސިޔާސީ ގޮތުން ކިހިނެއްކަން ސިފައިންގެ", "ޖެނެރަލުންނަށް ނިންމަން ...
20
632
1,295
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ], "area": [ 16676, 13716, 15092, 14672, 14700, 14476, 14877, 15036, 13717, 217550, 4371, 15036, 14140...
{ "gt_parse": { "headline": [ "ނޭޕާލުން 14 ދިވެއްސަކު އިންޑިއާ އަށް ހިނގައްޖެ" ], "textline": [ "ނޭޕާލަށް މިދިޔަ ހޮނިހިރު ދުވަހު އައި ބާރުގަދަ ބިންހެލުމާ ގުޅިގެން ލިބުނުގެއްލުންތަކުގައި ހާލުގައި ޖެހިފައިވާ", "ދިވެހިންގެ ތެރެއިން 14 ދަރިވަރަކު އިންޑިއާ ބޯޑަރު ހުރަސް ކުރުމަށް ފަހު، ދެންމެ ...
21
560
2,395
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4...
{ "gt_parse": { "headline": [ "މޭ 1 ގައި ބާއްވަނީ ސުލްހަވެރި ހަރަކާތެއް ކަމަށް ނުބެލެވޭ:", "ޕޮލިސް" ], "textline": [ "އަންނަ ހުކުރު ދުވަހު އިދިކޮޅު ފަރާތްތަކުން ބާއްވަން އުޅެނީ، އިވޭ", "އަޑުތަކަށާއިފެންނަ މަންޒަރުތަކަށް ބަލާއިރު، ސުލްހަވެރިކަމާއެކު", "ކުރިއަށް ގެންދިއުމަށްރާވ...
22
437
1,433
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ], "area": [ 12728, 14429, 8876, 8736, 9380, ...
{ "gt_parse": { "headline": [ "ސައިކަލުގެ ޑިއުޓީ ކުޑަކޮށް، އަންނައުނުގެ", "ޑިއުޓީ ކަނޑާލާ ބިލް ތަސްދީގު ކުރައްވައިފި" ], "textline": [ "ސައިކަލްތަކުގެގެ ޑިއުޓީ ކުޑަކޮށް، އަންނައުނުގެ ބާވަތްތަކުގެ", "ޑިއުޓީ ކަނޑާލަން ރައްޔިިތުންގެ މަޖިލީހުން ފާސްކުރި ބިލް", "ރައީސް އަބްދުﷲ ޔާމ...
23
647
1,007
{ "id": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ], "area": [ 24531, 3956, 16480, 16928, 15872, 15424, 15469, 17391, 17824, ...
{ "gt_parse": { "headline": [ "ރިޔާސަތުގެ މޭޒު ދޮށަށް ދާނަމަ ކޮމިޓީ އެލަވަންސް ނުދޭން", "ފާސްކޮށްފި" ], "textline": [ "ރައްޔިތުންގެ މަޖިލީހުގެ ރިޔާސަތުގެ މޭޒާއި އިދާރީ މޭޒު ދޮށަށް ހުއްދަ ނެތިވަޑައިގަންނަވާ", "މެމްބަރުންނާއި ނަން އިއްވާ މެމްބަރަކު މަޖިލީހުގެ ޖަލްސާދޫނުކުރައްވައި ހުނ...
End of preview. Expand in Data Studio

📦 Dhivehi Synthetic Document Layout + Textline Dataset

This dataset contains synthetically generated image-document pairs with detailed layout annotations and ground-truth Dhivehi text extractions.
It’s designed for document layout analysis, visual document understanding, OCR fine-tuning, and related tasks specifically for Dhivehi script.

Note: this version image are compressed. Raw version 📁 Repository: Hugging Face Datasets

📋 Dataset Summary

  • Total Examples: ~58,738
  • Image Content: Synthetic Dhivehi documents generated to simulate real-world layouts, including headlines, textlines, pictures, and captions.
  • Annotations:
    • Bounding boxes (bbox)
    • Object areas (area)
    • Object categories (category)
    • Ground-truth parsed text, split into:
      • headline (major headings)
      • textline (paragraph or text body lines)

⚠️ Important Note

This dataset is synthetic — no real-world documents or personal data were used. It was generated programmatically to train and evaluate models under controlled conditions, without legal or ethical concerns tied to real-world data.

🏷️ Categories

Label ID Label Name
0 Textline
1 Heading
2 Picture
3 Caption
4 Columns

📁 Features

Field Type
image_id int64
image image
width int64
height int64
objects List of:
  • id: int64
  • area: int64
  • bbox: [x, y, width, height] (float32)
  • category: label (class label 0–4) | | ground_truth.gt_parse |
  • headline: list of strings
  • textline: list of strings |

📊 Split

Split # Examples Size (bytes)
Train 58,738 ~84.31 GB (compressed)

📦 Download

  • Download size: ~93.32 GB
  • Uncompressed dataset size: ~84.31 GB

🔧 Example Use (with 🤗 Datasets)

from datasets import load_dataset

dataset = load_dataset("alakxender/od-syn-page-annotations")

categories = dataset.features["objects"].feature["category"].names
id2label = {i: name for i, name in enumerate(categories)}

print(id2label)

sample = dataset['train'][0]
print("Image ID:", sample['image_id'])
print("Image size:", sample['width'], "x", sample['height'])
print("First object category:", sample['objects']['category'][0])
print("First headline:", sample['ground_truth']['gt_parse']['headline'][0])

📊 Visualize

import numpy as np
from PIL import Image, ImageDraw, ImageFont
from datasets import load_dataset

def get_color(idx):
    palette = [
        "red", "green", "blue", "orange", "purple", "cyan", "magenta", "yellow", "lime", "pink"
    ]
    return palette[idx % len(palette)]

def draw_bboxes(sample, id2label, save_path=None):
    """
    Draw bounding boxes and labels on a single dataset sample.

    Args:
        sample: A dataset example (dict) with 'image' and 'objects'.
        id2label: Mapping from category ID to label name.
        save_path: If provided, saves the image to this path.

    Returns:
        PIL Image with drawn bounding boxes.
    """
    image = sample["image"]
    annotations = sample["objects"]

    image = Image.fromarray(np.array(image))
    draw = ImageDraw.Draw(image)
    try:
        font = ImageFont.truetype("arial.ttf", 14)
    except:
        font = ImageFont.load_default()

    for category, box in zip(annotations["category"], annotations["bbox"]):
        x, y, w, h = box
        color = get_color(category)
        draw.rectangle((x, y, x + w, y + h), outline=color, width=2)
        label = id2label[category]
        bbox = font.getbbox(label)
        text_width = bbox[2] - bbox[0]
        text_height = bbox[3] - bbox[1]
        draw.rectangle([x, y, x + text_width + 4, y + text_height + 2], fill=color)
        draw.text((x + 2, y + 1), label, fill="black", font=font)

    if save_path:
        image.save(save_path)
        print(f"Saved image to {save_path}")
    else:
        image.show()

    return image

# Load one sample
dataset = load_dataset("alakxender/od-syn-page-annotations", split="train[:1]")

# Get category mapping
categories = dataset.features["objects"].feature["category"].names
id2label = {i: name for i, name in enumerate(categories)}

# Draw bounding boxes on the first sample
draw_bboxes(
    sample=dataset[0],
    id2label=id2label,
    save_path="sample_0.png"
)
Downloads last month
56