Exemple #1
0
def test_reference_subset_option(compressors, reference, individual=False):
    print("Choose a reference subset.")
    i = 0
    choose = ""
    for ref_set in reference:
        i += 1
        ref = ""
        for image in ref_set:
            ref += " " + re.sub(".pgm", " ", image)
        choose += "{} -{} subset\n".format(i, ref)
    choose += "{} - Choose your own subset (3 images).\n".format(i + 1)
    op = ""
    while op not in ("1", "2", "3", "4", "5", "6", "7", "8", "9"):
        print(choose)
        op = input("Option: ")
        if op.lower() not in ("1", "2", "3", "4", "5", "6", "7", "8", "9"):
            print("\tInvalid Option.\n")

    if op == "9":
        if individual:
            return choose_own_subset(compressors, individual)
        choose_own_subset(compressors, individual)
    else:
        if individual:
            return [reference[int(op) - 1]]
        perform_testing(compressors, [reference[int(op) - 1]])
Exemple #2
0
def choose_own_subset(compressors, individual=False):
    images = [
        "01.pgm", "02.pgm", "03.pgm", "04.pgm", "05.pgm", "06.pgm", "07.pgm",
        "08.pgm", "09.pgm", "10.pgm"
    ]
    subset = []
    options = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
    while len(subset) < 3:
        print("\nChoose image to add to reference subset.")
        i = 0
        for img in images:
            i += 1
            print("\t{} - {}".format(i, img))
        op = input("Option: ")
        if op.lower() not in options:
            print("\tInvalid Option.")
        else:
            subset.append(images[int(op) - 1])
            images.remove(images[int(op) - 1])
            options.remove(options[len(options) - 1])

    subset = [tuple(sorted(subset))]
    print("Chosen subset: {}\n".format(subset))

    if individual:
        return subset
    else:
        perform_testing(compressors, subset)
Exemple #3
0
def test_compression_algorithm_option(reference, individual=False):
    print("Choose a compression algorithm.")
    algorithms = "1 - BROTLI.\n" \
                 "2 - BZIP2.\n" \
                 "3 - GZIP.\n" \
                 "4 - LZ4.\n" \
                 "5 - LZMA.\n" \
                 "6 - ZLIB.\n"

    algorithm = ""
    while algorithm not in ("1", "2", "3", "4", "5", "6"):
        print(algorithms)
        algorithm = input("Option: ")
        if algorithm.lower() not in ("1", "2", "3", "4", "5", "6"):
            print("\tInvalid Option.\n")

    compression_algorithm = []

    if algorithm == "1":
        compression_algorithm = [brotli_results]
        print(
            "(May take around 50 minutes to finish testing for a reference subset)\n"
        )
    elif algorithm == "2":
        compression_algorithm = [bz2_results]
        print(
            "(May take around 3-4 minutes to finish testing for a reference subset)\n"
        )
    elif algorithm == "3":
        compression_algorithm = [gzip_results]
        print(
            "(May take around 40 seconds to finish testing for a reference subset)\n"
        )
    elif algorithm == "4":
        compression_algorithm = [lz4_results]
        print(
            "(May take around 20 seconds to finish testing for a reference subset)\n"
        )
    elif algorithm == "5":
        compression_algorithm = [lzma_results]
        print(
            "(May take around 20 minutes to finish testing for a reference subset)\n"
        )
    elif algorithm == "6":
        compression_algorithm = [zlib_results]
        print(
            "(May take around 35 seconds to finish testing for a reference subset)\n"
        )

    if individual:
        return compression_algorithm

    perform_testing(compression_algorithm, reference)
Exemple #4
0
def main():
    print("Face identification using compression algorithms.")
    menu = "Choose what test to run.\n" \
           "1 - Full testing.\n" \
           "2 - Testing by compression algorithm.\n" \
           "3 - Testing by reference subset.\n" \
           "4 - Test a compression algorithm individually.\n" \
           "\ninfo - display information about the tests, compression algorithms available and reference subsets used.\n"

    compressors = [
        gzip_results, bz2_results, zlib_results, lz4_results, lzma_results,
        brotli_results
    ]
    reference_subsets = [("01.pgm", "02.pgm", "03.pgm"),
                         ("04.pgm", "05.pgm", "06.pgm"),
                         ("07.pgm", "08.pgm", "09.pgm"),
                         ("02.pgm", "04.pgm", "10.pgm"),
                         ("06.pgm", "08.pgm", "10.pgm"),
                         ("01.pgm", "03.pgm", "05.pgm"),
                         ("01.pgm", "07.pgm", "09.pgm"),
                         ("02.pgm", "05.pgm", "07.pgm")]
    op = ""

    while op.lower() not in ("1", "2", "3", "4"):
        print(menu)
        op = input("Option: ")
        if op.lower() not in ("1", "2", "3", "4", "info"):
            print("\tInvalid Option.\n")
        if op.lower() == "info":
            print_info(reference_subsets)

    if op == "1":
        print(
            "Performing Full testing.\n(May take around 11 hours to finish all tests)\n"
        )
        perform_testing(compressors, reference_subsets)
    elif op == "2":
        print("Performing testing by compression algorithm.")
        test_compression_algorithm_option(reference_subsets)
    elif op == "3":
        print("Performing testing by reference subset.")
        test_reference_subset_option(compressors, reference_subsets)
    elif op == "4":
        print("Performing testing for a compression algorithm individually.")
        test_compression_algorithm_individually_option(compressors,
                                                       reference_subsets)
Exemple #5
0
def test_compression_algorithm_individually_option(compressors, reference):
    algorithm = test_compression_algorithm_option(reference, True)
    ref = test_reference_subset_option(compressors, reference, True)
    print(ref)

    perform_testing(algorithm, ref)