Example #1
0
    def test_download_and_extract_muscima_pp_dataset_expect_images_to_be_downloaded(
            self):
        destination_directory = "MuscimaPlusPlus"
        downloader = MuscimaPlusPlusDatasetDownloader()
        zip_file = downloader.get_dataset_filename()
        number_of_images = 140
        target_file_extension = "*.png"

        self.download_dataset_and_verify_correct_extraction(
            destination_directory, number_of_images, target_file_extension,
            zip_file, downloader)
Example #2
0
    def test_download_and_extract_muscima_pp_dataset_expect_folder_to_be_created(
            self):
        # Arrange
        destination_directory = "MuscimaPlusPlus"
        downloader = MuscimaPlusPlusDatasetDownloader(destination_directory)
        zip_file = downloader.get_dataset_filename()
        number_of_samples_in_the_dataset = 141
        target_file_extension = "*.xml"

        self.download_dataset_and_verify_correct_extraction(
            destination_directory, number_of_samples_in_the_dataset,
            target_file_extension, zip_file, downloader)
    def test_download_and_extract_muscima_pp_dataset_expect_folder_to_be_created_v2(
            self):
        destination_directory = "MuscimaPlusPlus"
        downloader = MuscimaPlusPlusDatasetDownloader(dataset_version="2.0")
        zip_file = downloader.get_dataset_filename()
        number_of_samples_with_staff_lines = 140
        extra_files = 1
        number_of_xml_files_in_the_dataset = number_of_samples_with_staff_lines + extra_files
        target_file_extension = "*.xml"

        self.download_dataset_and_verify_correct_extraction(
            destination_directory, number_of_xml_files_in_the_dataset,
            target_file_extension, zip_file, downloader)
Example #4
0
    def test_download_extract_and_render_all_symbols(self):
        # Arrange
        datasetDownloader = MuscimaPlusPlusDatasetDownloader()

        # Act
        datasetDownloader.download_and_extract_dataset("temp/muscima_pp_raw")
        image_generator = MuscimaPlusPlusSymbolImageGenerator()
        image_generator.extract_and_render_all_symbol_masks("temp/muscima_pp_raw", "temp/muscima_img")
        all_image_files = [y for x in os.walk("temp/muscima_img") for y in glob(os.path.join(x[0], '*.png'))]
        expected_number_of_symbols = 91254
        actual_number_of_symbols = len(all_image_files)

        # Assert
        self.assertEqual(expected_number_of_symbols, actual_number_of_symbols)

        # Cleanup
        os.remove(datasetDownloader.get_dataset_filename())
        shutil.rmtree("temp")
Example #5
0
        help='The root directory that will contain the MuNG XMLs.')
    parser.add_argument(
        '-i',
        '--image_root',
        action='store',
        default="../data/images",
        help='The root directory that will contain the images of'
        ' scores that are represented by the MuNGs. The'
        ' image names must correspond to the MuNG file'
        ' names, up to the file type suffix.')
    args = parser.parse_args()
    mung_root_directory = args.mung_root
    image_root_directory = args.image_root

    os.makedirs(mung_root_directory, exist_ok=True)
    os.makedirs(image_root_directory, exist_ok=True)

    temporary_directory = "temp"
    dataset_downloader = MuscimaPlusPlusDatasetDownloader()
    dataset_downloader.download_and_extract_dataset(temporary_directory)

    copy_tree(
        os.path.join(temporary_directory, "v1.0", "data",
                     "cropobjects_manual"), mung_root_directory)
    copy_tree(os.path.join(temporary_directory, "v1.0", "data", "images"),
              image_root_directory)

    shutil.rmtree(temporary_directory)
    os.remove(dataset_downloader.get_dataset_filename())
    os.remove(dataset_downloader.get_imageset_filename())