Skip to content
Snippets Groups Projects
Commit 6158f1c7 authored by Yoann Schneider's avatar Yoann Schneider :tennis: Committed by Manon Blanco
Browse files

Fix parsing of labels.json when generating stats

parent 5c37875f
No related branches found
No related tags found
1 merge request!260Fix parsing of labels.json when generating stats
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from collections import Counter, defaultdict from collections import Counter, defaultdict
from operator import itemgetter
from pathlib import Path from pathlib import Path
from typing import Dict, List, Optional from typing import Dict, List, Optional
...@@ -156,8 +155,7 @@ class Statistics: ...@@ -156,8 +155,7 @@ class Statistics:
# Path to the images are the key of the dict # Path to the images are the key of the dict
self.create_image_statistics(images=split_data.keys()) self.create_image_statistics(images=split_data.keys())
# The text is actually under the "text" key of the values labels = list(split_data.values())
labels = list(map(itemgetter("text"), split_data.values()))
# Text statistics # Text statistics
self.create_label_statistics(labels=labels) self.create_label_statistics(labels=labels)
......
{ {
"train": { "train": {
"tests/data/training/training_dataset/images/0a34e13a-4ab0-4a91-8d7c-b1d8fee32628.png": { "tests/data/training/training_dataset/images/0a34e13a-4ab0-4a91-8d7c-b1d8fee32628.png": "The latter do not regard",
"text": "The latter do not regard" "tests/data/training/training_dataset/images/0a70e14f-feda-4607-989c-36cf581ddff5.png": "At the beginning of"
},
"tests/data/training/training_dataset/images/0a70e14f-feda-4607-989c-36cf581ddff5.png": {
"text": "At the beginning of"
}
}, },
"val": { "val": {
"tests/data/training/training_dataset/images/0a576062-303c-4893-a729-c09c92865d31.png": { "tests/data/training/training_dataset/images/0a576062-303c-4893-a729-c09c92865d31.png": "One can remember with",
"text": "One can remember with" "tests/data/training/training_dataset/images/0b2457c8-81f1-4600-84d9-f8bf2822a991.png": "The play was no more"
},
"tests/data/training/training_dataset/images/0b2457c8-81f1-4600-84d9-f8bf2822a991.png": {
"text": "The play was no more"
}
}, },
"test": { "test": {
"tests/data/training/training_dataset/images/fb3edb59-3678-49f8-8e16-8e32e3b0f051.png": { "tests/data/training/training_dataset/images/fb3edb59-3678-49f8-8e16-8e32e3b0f051.png": "Both her wrists bore",
"text": "Both her wrists bore" "tests/data/training/training_dataset/images/fe498de2-ece4-4fbe-8b53-edfce1b820f0.png": "SOME years ago a contemporary"
},
"tests/data/training/training_dataset/images/fe498de2-ece4-4fbe-8b53-edfce1b820f0.png": {
"text": "SOME years ago a contemporary"
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment