dataset_stats.py 1.9 KB
Newer Older
sjjsmuel's avatar
sjjsmuel committed
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 40 41 42
from helpers.AnnotationLocationLoader import AnnotationLocationLoader

'''
This script is able to load the annotations for each part of the dataset separately and report a few stats about them.
'''

def get_stats(annotation_loader):
    bilder = annotation_loader.get_all_annotated_images()
    bilder_count = len(annotation_loader.get_all_available_images())
    bilder_mit_annotation = 0
    summe_der_annotationen = 0
    for image in bilder:
        annot_per_image = len(annotation_loader.get_annotations(image, ['Caries']))
        summe_der_annotationen += annot_per_image
        if annot_per_image > 0:
            bilder_mit_annotation += 1
    print("Anzahl Bilder: {}".format(bilder_count))
    print("Bilder mit Caries Annotationen: {}".format(bilder_mit_annotation))
    print("Summe der Annotationen: {}".format(summe_der_annotationen))
    print()


if __name__ == '__main__':

    print('Test')
    annotLoader_test = AnnotationLocationLoader(annotation_file='input/caries_dataset_annotation.json',
                                                 images_base_folder='input/test_data',
                                                 mouth_annotations_folder='input/mouth_annotations')
    get_stats(annotLoader_test)

    print('Training')
    annotLoader_train = AnnotationLocationLoader(annotation_file='input/caries_dataset_annotation.json',
                                                 images_base_folder='input/training_data',
                                                 mouth_annotations_folder='input/mouth_annotations')
    get_stats(annotLoader_train)

    print('Evaluation')
    annotLoader_eval = AnnotationLocationLoader(annotation_file='input/caries_dataset_annotation.json',
                                                 images_base_folder='input/evaluation_data',
                                                 mouth_annotations_folder='input/mouth_annotations')
    get_stats(annotLoader_eval)