Exemplo n.º 1
0
def main():
    # start the timer and parse any args from the user
    start_time = time()
    in_arg = get_input_args()
    check_command_line_arguments(in_arg)

    # infer the correct answers from the image file names
    results = get_pet_labels(in_arg.dir)
    check_creating_pet_image_labels(results)

    # predict the result for each image, for the given architecture
    classify_images(in_arg.dir, results, in_arg.arch)
    check_classifying_images(results)

    # aggregate the results to dog not-dog level
    adjust_results4_isadog(results, in_arg.dogfile)
    check_classifying_labels_as_dogs(results)

    # calculate accuracy and some other aggregate statistics
    results_stats = calculates_results_stats(results)
    check_calculating_results(results, results_stats)

    # print the final results for this architecture and stop the timer
    print_results(results, results_stats, in_arg.arch, True, True)
    end_time = time()

    tot_time = (end_time - start_time)
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 2
0
def main():
    # TODO 0: Measures total program runtime by collecting start time
    start_time = time()

    sleep(10)

    # This function returns
    # the collection of these command line arguments from the function call as
    # the variable in_arg
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)

    # This function creates the results dictionary that contains the results,
    # this dictionary is returned from the function call as the variable results
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results
    check_creating_pet_image_labels(results)

    # Creates Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results
    check_classifying_images(results)

    # Adjusts the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)

    # TODO 5: Define calculates_results_stats function within the file calculates_results_stats.py
    # This function creates the results statistics dictionary that contains a
    # summary of the results statistics (this includes counts & percentages). This
    # dictionary is returned from the function call as the variable results_stats
    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)

    # TODO 0: Measure total program runtime by collecting end time
    end_time = time()

    # TODO 0: Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 3
0
def main():

    start_time = time()

    in_arg = get_input_args()

    check_command_line_arguments(in_arg)

    results = get_pet_labels(in_arg.dir)

    check_creating_pet_image_labels(results)

    classify_images(in_arg.dir, results, in_arg.arch)

    check_classifying_images(results)

    adjust_results4_isadog(results, in_arg.dogfile)

    check_classifying_labels_as_dogs(results)

    results_stats = calculates_results_stats(results)

    check_calculating_results(results, results_stats)

    print_results(results, results_stats, in_arg.arch, True, True)

    end_time = time()

    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 4
0
def main():

    start_time = time()

    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results
    check_creating_pet_image_labels(results)
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results
    check_classifying_images(results)

    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    print_results(results, results_stats, in_arg.arch, True, True)

    end_time = time()

    tot_time = end_time - start_time  #calculate difference between end time and start time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 5
0
def main():
    # Measures total program runtime by collecting start time
    start_time = time()

    # Function that retrieves 3 Command Line Arugments from user's input
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg -
    # Remove the # from in front of the function call after you have
    # coded get_input_args to check your code
    check_command_line_arguments(in_arg)

    # Creates a dictionary that contains the results - called results
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results
    # Remove the # from in front of the function call after you have
    # coded get_pet_labels to check your code
    check_creating_pet_image_labels(results)

    # Creates Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary - results
    # Remove the # from in front of the function call after you have
    # coded classify_images to check your code
    check_classifying_images(results)

    # Adjusts the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    # Remove the # from in front of the function call after you have
    # coded adjust_results4_isadog to check your code
    check_classifying_labels_as_dogs(results)

    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary - results_stats
    # Remove the # from in front of the function call after you have
    # coded calculates_results_stats to check your code
    check_calculating_results(results, results_stats)

    # Prints summary results, incorrect classifications of dogs
    # and breeds if requested
    print_results(results, results_stats, in_arg.arch, True, True)

    # Measure total program runtime by collecting end time
    end_time = time()

    # Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time
    print("\n** Total Elapsed Runtime:",
          str(int((tot_time / 3600))) + ":" + str(int((tot_time % 3600) / 60)) + ":"
          + str(int((tot_time % 3600) % 60)))
Exemplo n.º 6
0
def main():

    start_time = time()
    in_arg = get_input_args()
    # Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)
    # this dictionary is returned from the function call as the variable results
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results
    check_creating_pet_image_labels(results)

    classify_images(in_arg.dir, results, in_arg.arch)
    check_classifying_images(results)

    adjust_results4_isadog(results, in_arg.dogfile)

    check_classifying_labels_as_dogs(results)

    results_stats = calculates_results_stats(results)

    check_calculating_results(results, results_stats)

    print_results(results, results_stats, in_arg.arch, True, True)

    end_time = time()

    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 7
0
def main():
    # Measures total program runtime by collecting start time
    start_time = time()

    # Retrieve the 3 Command Line Arugments from user as input from
    # the user running the program from a terminal window. Returns
    # the collection of these command line arguments from the function
    # call as the variable in_arg
    in_arg = get_input_args()

    # Checks command line arguments using in_arg
    check_command_line_arguments(in_arg)

    # Create the results dictionary that contains the results, this dictionary
    # is returned from the function call
    results = get_pet_labels(in_arg.dir)

    # Check Pet Images in the results Dictionary using results
    check_creating_pet_image_labels(results)

    # Create Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Check Results Dictionary using results.
    check_classifying_images(results)

    # Adjust the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify images as real animal (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Check the Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)

    # Create the results statistics dictionary that contains a
    # summary of the results statistics (this includes counts & percentages).
    # Calculates results of run and add statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Check the Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    # Print summary results, incorrect classifications of animals (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)

    # Measure total program runtime by collecting end time
    end_time = time()

    # Compute overall runtime in seconds & prints it in hh:mm:ss format
    # calculate difference between end time and start time
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 8
0
def main():
    # Measures total program runtime by collecting start time
    start_time = time()

    # This function retrieves 3 Command Line Arguments as input from
    # the user running the program from a terminal window.
    in_arg = get_input_args()
    check_command_line_arguments(in_arg)

    # Define get_pet_labels function within the file get_pet_labels.py
    results = get_pet_labels(in_arg.dir)
    check_creating_pet_image_labels(results)

    # Creates Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)
    check_classifying_images(results)

    # Adjusts the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)
    check_classifying_labels_as_dogs(results)

    # Creates the results statistics dictionary that contains counts & percentages.
    results_stats = calculates_results_stats(results)
    check_calculating_results(results, results_stats)

    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)

    end_time = time()

    # Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(round(
                (tot_time % 3600) % 60)))
    final_results = """
    *** ----------------------------------Project Results -------------------------------------------- ***
    Given our results, the "best" model architecture is VGG.
    It out-performed both of the other architectures when considering both objectives 1 and 2.
    ResNet did classify dog breeds better than AlexNet,
    but only VGG and AlexNet were able to classify "dogs" and "not-a-dog"with 100% accuracy.
    The model VGG was the one that was able to classify "dogs" and "not-a-dog" with 100% accuracy and
    had the best performance regarding breed classification with 93.3% accuracy.
    If short runtime is of essence, one could argue that ResNet is preferrable to VGG.
    The resulting loss in accuracy in the dog breed classification is only 3.6% (VGG: 93.3% and ResNet: 89.7%).
    There is also some loss in accuracy predicting not-a-dog images of 9.1% (VGG: 100% and ResNet: 90.9%).
    *** ---------------------------------------------------------------------------------------------- ***
    """
    print(final_results)
Exemplo n.º 9
0
def main():
    # Measures total program runtime by collecting start time
    start_time = time()

    # Use get_input_args() to retrieve 3 Command Line Arugments from user as input from
    # the user running the program from a terminal window. Returns
    # the collection of these command line arguments from the function call as
    # the variable in_arg
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)

    # Initialize the results dictionary that contains the results
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results
    check_creating_pet_image_labels(results)

    # Create Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results
    check_classifying_images(results)

    # Adjust the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)

    # Calculate results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    # Print summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)

    # Measure total program runtime by collecting end time
    end_time = time()

    # Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time

    print("\nTotal elasped time: " + formatted_time(tot_time))
Exemplo n.º 10
0
def main():
    # start the timer and parse any args from the user
    start_time = time()
    in_arg = get_input_args()
    check_command_line_arguments(in_arg)

    # infer the correct answers from the image file names
    results = get_pet_labels(in_arg.dir)
    check_creating_pet_image_labels(results)

    # predict the result for each image, for the given architecture
    classify_images(in_arg.dir, results, in_arg.arch)
    check_classifying_images(results)

    # aggregate the results to dog not-dog level
    adjust_results4_isadog(results, in_arg.dogfile)
    check_classifying_labels_as_dogs(results)

    # calculate accuracy and some other aggregate statistics
    results_stats = calculates_results_stats(results)
    check_calculating_results(results, results_stats)

    # print the final results for this architecture and stop the timer
    print_results(results, results_stats, in_arg.arch, True, True)
    end_time = time()

    tot_time = (end_time - start_time)
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))

    import pickle
    with open("results_stats.pickle", "wb") as f:
        pickle.dump(results_stats, f)
    print()
    print()
    print("*******************************")
    print()
    print()
    print("{}       {}     {}       {}       {}".format(
        "Architecture", "Not a Dog", "Dog", "Breed", "Label"))

    print("{}{}{:.2f}       {:.2f}     {:.2f}       {:.2f}".format(
        in_arg.arch, " " * (19 - len(in_arg.arch)),
        results_stats['pct_correct_notdogs'],
        results_stats['pct_correct_dogs'], results_stats['pct_correct_breed'],
        results_stats['pct_match']))

    print()
    print()
    print("*******************************")
Exemplo n.º 11
0
 def test_calculates_results_stats(self):
     results_stats = calculates_results_stats(results_dic)
     self.assertEqual(results_stats['n_images'], 4)
     self.assertEqual(results_stats['n_correct_dogs'], 2)
     self.assertEqual(results_stats['n_dogs_img'], 3)
     self.assertEqual(results_stats['n_correct_notdogs'], 1)
     self.assertEqual(results_stats['n_notdogs_img'], 1)
     self.assertEqual(results_stats['n_correct_breed'], 1)
     self.assertEqual(results_stats['n_matches'], 2)
     self.assertEqual(results_stats['pct_correct_dogs'], 2/3 * 100)
     self.assertEqual(results_stats['pct_correct_notdogs'], 1/1 * 100)
     self.assertEqual(results_stats['pct_correct_breed'], 1/3 * 100)
     self.assertEqual(results_stats['pct_match'], 2/4 * 100)
Exemplo n.º 12
0
def main():
    # log start time
    start_time = time()
    
    # get input
    in_arg = get_input_args()
    
    # check input
    check_command_line_arguments(in_arg)
    
    # get pet labels
    results = get_pet_labels(in_arg.dir)
    
    # check pet labels
    check_creating_pet_image_labels(results)
    
    # classify images
    classify_images(in_arg.dir, results, in_arg.arch)

    # check image classification   
    check_classifying_images(results)    

    # adjust results for dogs
    adjust_results4_isadog(results, in_arg.dogfile)

    # check adjusted results for dogs
    check_classifying_labels_as_dogs(results)

    # get results stats
    results_stats = calculates_results_stats(results)

    # check results stats
    check_calculating_results(results, results_stats)


    # TODO 6: Define print_results function within the file print_results.py
    # Once the print_results function has been defined replace 'None' 
    # in the function call with in_arg.arch  Once you have done the 
    # replacements your function call should look like this: 
    #      print_results(results, results_stats, in_arg.arch, True, True)
    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    
    print_results(results, results_stats, in_arg.arch, True, True)
    
    end_time = time()
    
    tot_time = end_time - start_time
    print("\n** Total Elapsed Runtime:",
          str(int((tot_time/3600)))+":"+str(int((tot_time%3600)/60))+":"
          +str(int((tot_time%3600)%60)) )
Exemplo n.º 13
0
def main():
    # Record the start time of main function
    start_time = time()
    
    # Get input arguments
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg  
    check_command_line_arguments(in_arg)

    # Creates the results dictionary that contains the results
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results    
    check_creating_pet_image_labels(results)

    # Creates Classifier Labels with classifier function, Compares Labels, 
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results    
    check_classifying_images(results)    

    # Adjusts the results dictionary to determine if classifier correctly 
    # classified images as 'a dog' or 'not a dog'. This demonstrates if 
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)
 
    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)

    # Record the end time of main function
    end_time = time()

    # Calculate the total runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time
    print("\n** Total Elapsed Runtime:",
          str(int((tot_time/3600)))+":"+str(int((tot_time%3600)/60))+":"
          +str(int((tot_time%3600)%60)) )
def main():
    
    start_time = time()
    in_arg = get_input_args()
    check_command_line_arguments(in_arg)
    results = get_pet_labels(in_arg.dir) 
    check_creating_pet_image_labels(results) 
    classify_images(in_arg.dir, results, in_arg.arch)
    check_classifying_images(results)
    adjust_results4_isadog(results, in_arg.dogfile)
    check_classifying_labels_as_dogs(results)
    results_stats = calculates_results_stats(results)
    check_calculating_results(results, results_stats)
    print_results(results, results_stats, in_arg.arch, True, True)
def main():
    # Measures total program runtime by collecting start time
    start_time = time()

    # Creates & retrieves Command Line Arugments
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)

    # Creates Pet Image Labels by creating a dictionary
    answers_dic = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images Dictionary- answers_dic
    check_creating_pet_image_labels(answers_dic)

    # Creates Classifier Labels with classifier function, Compares Labels,
    # and creates a results dictionary
    result_dic = classify_images(in_arg.dir, answers_dic, in_arg.arch)

    # Function that checks Results Dictionary - result_dic
    check_classifying_images(result_dic)

    # Adjusts the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(result_dic, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment- result_dic
    check_classifying_labels_as_dogs(result_dic)

    # Calculates results of run and puts statistics in results_stats_dic
    results_stats_dic = calculates_results_stats(result_dic)

    # Function that checks Results Stats Dictionary - results_stats_dic
    check_calculating_results(result_dic, results_stats_dic)

    # Prints summary results, incorrect classifications of dogs
    # and breeds if requested
    print_results(result_dic, results_stats_dic, in_arg.arch, True, True)

    # Measure total program runtime by collecting end time
    end_time = time()

    # Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 16
0
def main():
    start_time = time()  # start_time from time module (0)
    #1
    in_arg = get_input_args()  #read command line args, using argparse mod(1)
    check_command_line_arguments(in_arg)  #prints command line arguments (1)
    #2
    results = get_pet_labels(
        in_arg.dir
    )  #creates dictionary with key: file_name & value: [pet_label]
    check_creating_pet_image_labels(results)  # prints 10 of key value pairs
    #3
    classify_images(in_arg.dir, results, in_arg.arch)
    check_classifying_images(results)
    adjust_results4_isadog(results, in_arg.dogfile)
    check_classifying_labels_as_dogs(results)
    results_stats = calculates_results_stats(results)
    check_calculating_results(results, results_stats)
    print_results(results, results_stats, in_arg.arch, True, True)

    #python check_images.py --dir pet_images/ --arch resnet --dogfile dognames.txt --> 6 seconds, but pct_correct_dogs is wrong
    #python check_images.py --dir pet_images/ --arch alexnet --dogfile dognames.txt --> 3 seconds
    #python check_images.py --dir pet_images/ --arch vgg --dogfile dognames.txt --> 37 seconds

    end_time = time()
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))

    table1 = PrettyTable()
    table1.field_names = [
        "# Total Images", "# Dog Images", "# Not-a-Dog Images"
    ]
    table1.add_row([40, 30, 10])
    print(table1)
    print("\n\n\n")
    table2 = PrettyTable()
    table2.field_names = [
        "CNN Model Architecture: ", "% Not-a-Dog Correct", "% Dogs Corrects",
        "% Breeds Correct", "% Match Labels", "Runtime (seconds)"
    ]
    table2.add_row(["ResNet", "90%", "100%", "90%", "82.5%", 6])
    table2.add_row(["AlexNet", "100%", "100%", "80%", "75%", 3])
    table2.add_row(["VGG", "100%", "100%", "93.3%", "87.5%", 35])
    print(table2)

    print(
        "The model VGG was the one that was able to classify 'dogs' and 'not-a-dog' with 100% accuracy and had the best performance regarding breed classification with 93.3% accuracy. The Model AlexNet was the most efficient with the fastest runtime at only 3 seconds but still images 100% accuracy for identifying dogs correctly"
    )
def main():

    start_time = time()

    # This function retrieves 3 Command Line Arugments from user as input from
    # the user running the program from a terminal window.
    in_arg = get_input_args()

    #Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)

    #Creates the results dictionary that contains the results
    results = get_pet_labels(in_arg.dir)

    #Function that checks Pet Images in the results Dictionary using results
    check_creating_pet_image_labels(results)

    #Creates Classifier Labels with classifier function, Compares Labels,
    #and adds these results to the results dictionary
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results
    check_classifying_images(results)

    #Adjusts the results dictionary to determine if classifier correctly classified images as 'a dog' or 'not a dog'.
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)

    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)

    end_time = time()

    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 18
0
def main():
    # Start measuring the time of program running
    start_time = time()

    # Get command line arguments
    in_arg = get_input_args()

    # Check command line arguments
    check_command_line_arguments(in_arg)

    # Get pet labels as Dictionary of filename: list of one label
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results
    check_creating_pet_image_labels(results)

    # Classify images by adding classifier label and comparison label
    # for each list in key:object pairs in result Dictionary
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results
    check_classifying_images(results)

    # Adjusts the results dictionary to determine if classifier correctly classified images 'as a dog' or 'not a dog'
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)

    # Calculates results of run and puts statistics in the Results Statistics
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    # Print results
    print_results(results, results_stats, in_arg.arch, True, True)

    # End measuring the time of program running
    end_time = time()

    # Print total time of program running
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 19
0
def main():
    start_time = time()
    in_arg = get_input_args()
    results = get_pet_labels(in_arg.dir)

    classify_images(in_arg.dir, results, in_arg.arch)
    adjust_results4_isadog(results, in_arg.dogfile)

    results_stats = calculates_results_stats(results)
    print_results(results, results_stats, in_arg.arch, True, True)

    end_time = time()
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 20
0
def main():
    start_time = timer()

    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg
    if in_arg.verbose:
        check_command_line_arguments(in_arg)

    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results
    if in_arg.verbose:
        check_creating_pet_image_labels(results)

    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results
    if in_arg.verbose:
        check_classifying_images(results)

    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    if in_arg.verbose:
        check_classifying_labels_as_dogs(results)

    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    if in_arg.verbose:
        check_calculating_results(results, results_stats)

    print_results(results, results_stats, in_arg.arch, True, True)

    end_time = timer()

    tot_time = end_time - start_time
    print("\n[*] Total Elapsed Runtime: {:02d}:{:02d}:{}".format(
        int(tot_time / 3600),  # hours
        int(tot_time % 3600 / 60),  # minutes
        round(tot_time % 3600 % 60, 5)))  # seconds

    if in_arg.compare:
        table_comparison(results_stats)
def main():
    # Measures total program runtime by collecting start time
    start_time = time()

    # This function retrieves 3 Command Line Arugments from user as input from
    # the user running the program from a terminal window. This function returns
    # the collection of these command line arguments from the function call as
    # the variable in_arg
    in_arg = get_input_args()
    check_command_line_arguments(in_arg)

    # This function creates the results dictionary that contains the results,
    # this dictionary is returned from the function call as the variable results
    results = get_pet_labels(in_arg.dir)
    check_creating_pet_image_labels(results)

    # Creates Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)
    check_classifying_images(results)

    # Adjusts the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)
    check_classifying_labels_as_dogs(results)

    # Called function creates the results statistics dictionary that contains a
    # summary of the results statistics (this includes counts & percentages). This
    # dictionary is returned from the function call as the variable results_stats
    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)
    check_calculating_results(results, results_stats)

    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)

    end_time = time()
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 22
0
def main():
    # TODO 0: Measures total program runtime by collecting start time
    start_time = time()

    # creates and retrieves command Line Arguments
    in_arg = get_input_args()
    # Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)
    # Creates pet image labels by creating a dictionary
    answers_dic = get_pet_labels(in_arg.dir)

    check_creating_pet_image_labels(answers_dic)
    # Creates classifier labels with classifier function, compares labbels and createsa results
    # dictionary
    result_dic = classify_images(in_arg.dir, answers_dic, in_arg.arch)
    # Function that checks results dictionary result_dic
    check_classifying_images(result_dic)
    # Adjusts the results dictionary to determine if classifier correctly classified
    # images 'a dog'
    # or 'not a dog'
    adjust_results4_isadog(result_dic, in_arg.dogfile)
    # Function that checks results dictionary for is-a -dog adjustment - result-dic
    check_classifying_labels_as_dogs(result_dic)
    # Calculates results of run and puts statistics in results_stats_dic
    results_stats_dic = calculates_results_stats(result_dic)
    # Function that checks results stats dictionary - results_stats_dic
    check_calculating_results(result_dic, results_stats_dic)
    # Prints Summary results, incorrect classifications of dogs and breeds if requested
    print_results(result_dic, results_stats_dic, in_arg.arch, True, True)
    # Measure total program runtime by collecting end time
    end_time = time()
    # Computes overall runtime in seconds and prints it hh:mm:ss format
    tot_time = end_time - start_time
    print(
        '\n** Total elapsed runtime:',
        str(int((tot_time / 3600))) + ':' + str(int(
            (tot_time % 3600) / 60)) + ':' + str(int((tot_time % 3600) % 60)))
Exemplo n.º 23
0
def main():
    start_time = time()  # Collecting start time

    in_arg = get_input_args()  # This function returns command line arguments
    check_command_line_arguments(in_arg)  # Checks command line argument

    results = get_pet_labels(in_arg.dir)  # Creates the results dictionary
    check_creating_pet_image_labels(
        results)  # Checks pet images in the results Dictionary

    # Creates Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)
    check_classifying_images(
        results)  # Checks Results Dictionary using results

    adjust_results4_isadog(results,
                           in_arg.dogfile)  # Adjusts the results dictionary
    check_classifying_labels_as_dogs(
        results)  # Checks Results Dictionary for is-a-dog adjustment

    results_stats = calculates_results_stats(
        results)  # Calculates results of run
    check_calculating_results(
        results, results_stats)  # Checks Results Statistics Dictionary

    print_results(results, results_stats, in_arg.arch, True,
                  True)  #Prints summary results

    end_time = time()  # Collecting end time

    # Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))
Exemplo n.º 24
0
def main():
    
    #TODO 0 ------------------------------------------------------------------
    start_time = time.time() 
    
    # Todo 1
    in_arg = get_input_args()
    check_command_line_arguments(in_arg)
    
    
    
    #TODO 2
    results_dic = get_pet_labels(in_arg.dir)
    
    #TODO 3
    results = classify_images(in_arg.dir, results_dic, in_arg.arch) #updated Dict
    
    
    #TODO 4
    results_dic= adjust_results4_isadog(results, in_arg.dogfile)
    
    
    # TODO 5
    results_stats = calculates_results_stats(results) 
    
    
    # TODO 6
    print_results(results_dic, results_stats, in_arg.arch, True, True) 
    
    
    #TODO 0
    end_time = time.time()
    tot_time = end_time - start_time 
    print("\n** Total Elapsed Runtime:",
          str(int((tot_time/3600)))+":"+str(int((tot_time%3600)/60))+":"
          +str(int((tot_time%3600)%60)) )
Exemplo n.º 25
0
def main():
    # TODO 0: Measures total program runtime by collecting start time
    start_time = time()
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)

    # TODO 2: Define get_pet_labels function within the file get_pet_labels.py
    # Once the get_pet_labels function has been defined replace 'None'
    # in the function call with in_arg.dir  Once you have done the replacements
    # your function call should look like this:
    #             get_pet_labels(in_arg.dir)
    # This function creates the results dictionary that contains the results,
    # this dictionary is returned from the function call as the variable results
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results
    check_creating_pet_image_labels(results)

    # TODO 3: Define classify_images function within the file classiy_images.py
    # Once the classify_images function has been defined replace first 'None'
    # in the function call with in_arg.dir and replace the last 'None' in the
    # function call with in_arg.arch  Once you have done the replacements your
    # function call should look like this:
    #             classify_images(in_arg.dir, results, in_arg.arch)
    # Creates Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results
    check_classifying_images(results)

    # TODO 4: Define adjust_results4_isadog function within the file adjust_results4_isadog.py
    # Once the adjust_results4_isadog function has been defined replace 'None'
    # in the function call with in_arg.dogfile  Once you have done the
    # replacements your function call should look like this:
    #          adjust_results4_isadog(results, in_arg.dogfile)
    # Adjusts the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)

    # TODO 5: Define calculates_results_stats function within the file calculates_results_stats.py
    # This function creates the results statistics dictionary that contains a
    # summary of the results statistics (this includes counts & percentages). This
    # dictionary is returned from the function call as the variable results_stats
    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    # TODO 6: Define print_results function within the file print_results.py
    # Once the print_results function has been defined replace 'None'
    # in the function call with in_arg.arch  Once you have done the
    # replacements your function call should look like this:
    #      print_results(results, results_stats, in_arg.arch, True, True)
    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)

    # TODO 0: Measure total program runtime by collecting end time
    end_time = time()

    # TODO 0: Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))

    import pickle
    with open("results_stats.pickle", "wb") as f:
        pickle.dump(results_stats, f)
        print()
        print()
        print("***** FINAL RESULTS *****")
        print()
        print()
        print("{}       {}          {}       {}       {}".format(
            "Architecture", "~Dog", "Dog", "Breed", "Label"))
        print("{}{}{:.2f}       {:.2f}     {:.2f}       {:.2f}".format(
            in_arg.arch, " " * (19 - len(in_arg.arch)),
            results_stats['pct_correct_notdogs'],
            results_stats['pct_correct_dogs'],
            results_stats['pct_correct_breed'], results_stats['pct_match']))

        print()
        print()
        print("***************************")
Exemplo n.º 26
0
def main():
    # TODO 0: Measures total program runtime by collecting start time
    # start_time from time module at default time
    start_time = time()

    # TODO 1: Define get_input_args function within the file get_input_args.py
    # This function retrieves 3 Command Line Arugments from user as input from
    # the user running the program from a terminal window. This function returns
    # the collection of these command line arguments from the function call as
    # the variable in_arg

    #read command line args
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)

    # TODO 2: Define get_pet_labels function within the file get_pet_labels.py
    # Once the get_pet_labels function has been defined replace 'None'
    # in the function call with in_arg.dir  Once you have done the replacements
    # your function call should look like this:
    #             get_pet_labels(in_arg.dir)
    # This function creates the results dictionary that contains the results,
    # this dictionary is returned from the function call as the variable results

    # This function creates the results dictionary that contains the results,
    results = get_pet_labels(in_arg.dir)
    print(results)
    # Function that checks Pet Images in the results Dictionary using results
    # Prints first 10 key-value pairs
    check_creating_pet_image_labels(results)

    # TODO 3: Define classify_images function within the file classiy_images.py
    # Once the classify_images function has been defined replace first 'None'
    # in the function call with in_arg.dir and replace the last 'None' in the
    # function call with in_arg.arch  Once you have done the replacements your
    # function call should look like this:
    #             classify_images(in_arg.dir, results, in_arg.arch)
    # Creates Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results
    check_classifying_images(results)

    # TODO 4: Define adjust_results4_isadog function within the file adjust_results4_isadog.py
    # Once the adjust_results4_isadog function has been defined replace 'None'
    # in the function call with in_arg.dogfile  Once you have done the
    # replacements your function call should look like this:
    #          adjust_results4_isadog(results, in_arg.dogfile)
    # Adjusts the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)

    # TODO 5: Define calculates_results_stats function within the file calculates_results_stats.py
    # This function creates the results statistics dictionary that contains a
    # summary of the results statistics (this includes counts & percentages). This
    # dictionary is returned from the function call as the variable results_stats
    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    # TODO 6: Define print_results function within the file print_results.py
    # Once the print_results function has been defined replace 'None'
    # in the function call with in_arg.arch  Once you have done the
    # replacements your function call should look like this:
    #      print_results(results, results_stats, in_arg.arch, True, True)
    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)

    # TODO 0: Measure total program runtime by collecting end time
    end_time = end_time = time()

    # TODO 0: Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time  #calculate difference between end time and start time
    print(
        "\n** Total Elapsed Runtime:",
        str(int((tot_time / 3600))) + ":" + str(int(
            (tot_time % 3600) / 60)) + ":" + str(int((tot_time % 3600) % 60)))

    tableA = [["# Total Images", 40], ["# Dog Images", 30],
              ["# Not-a-Dog Images", 10]]
    headers = ["", ""]
    print(tabulate(tableA, headers, tablefmt="grid"))

    print("\n\n\n")
    tableB = [["ResNet", "90%", "100%", "90%", "82.5%", 6],
              ["AlexNet", "100%", "100%", "80%", "75%", 3],
              ["VGG", "100%", "100%", "93.3%", "87.5%", 35]]
    headers = [
        "CNN Model Architecture: ", "% Not-a-Dog Correct", "% Dogs Corrects",
        "% Breeds Correct", "% Match    Labels", "Runtime (seconds)"
    ]
    print(tabulate(tableB, headers, tablefmt="grid"))
    print(
        "Given our results, the best model architecture is VGG,The model VGG was the one that was able to classify 'dogs' and 'not-a-dog' with 100% accuracy and had the best performance regarding breed classification with 93.3% accuracy. The Model AlexNet was the most efficient with the fastest runtime at only 3 seconds but still images 100% accuracy for identifying dogs correctly"
    )
def main():
    # TODO 0: Measures total program runtime by collecting start time
    start_time = time()
    
    # TODO 1: Define get_input_args function within the file get_input_args.py
    # This function retrieves 3 Command Line Arugments from user as input from
    # the user running the program from a terminal window. This function returns
    # the collection of these command line arguments from the function call as
    # the variable in_arg
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg  
    check_command_line_arguments(in_arg)

    
    # TODO 2: Define get_pet_labels function within the file get_pet_labels.py
    # Once the get_pet_labels function has been defined replace 'None' 
    # in the function call with in_arg.dir  Once you have done the replacements
    # your function call should look like this: 
    #             get_pet_labels(in_arg.dir)
    # This function creates the results dictionary that contains the results, 
    # this dictionary is returned from the function call as the variable results
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results    
    check_creating_pet_image_labels(results)


    # TODO 3: Define classify_images function within the file classiy_images.py
    # Once the classify_images function has been defined replace first 'None' 
    # in the function call with in_arg.dir and replace the last 'None' in the
    # function call with in_arg.arch  Once you have done the replacements your
    # function call should look like this: 
    #             classify_images(in_arg.dir, results, in_arg.arch)
    # Creates Classifier Labels with classifier function, Compares Labels, 
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results    
    check_classifying_images(results)    

    
    # TODO 4: Define adjust_results4_isadog function within the file adjust_results4_isadog.py
    # Once the adjust_results4_isadog function has been defined replace 'None' 
    # in the function call with in_arg.dogfile  Once you have done the 
    # replacements your function call should look like this: 
    #          adjust_results4_isadog(results, in_arg.dogfile)
    # Adjusts the results dictionary to determine if classifier correctly 
    # classified images as 'a dog' or 'not a dog'. This demonstrates if 
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)


    # TODO 5: Define calculates_results_stats function within the file calculates_results_stats.py
    # This function creates the results statistics dictionary that contains a
    # summary of the results statistics (this includes counts & percentages). This
    # dictionary is returned from the function call as the variable results_stats    
    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)


    # TODO 6: Define print_results function within the file print_results.py
    # Once the print_results function has been defined replace 'None' 
    # in the function call with in_arg.arch  Once you have done the 
    # replacements your function call should look like this: 
    #      print_results(results, results_stats, in_arg.arch, True, True)
    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg, True, True)
    
    # TODO 0: Measure total program runtime by collecting end time
    end_time = time()
    
    # TODO 0: Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = start_time + end_time#calculate difference between end time and start time
    print("\n** Total Elapsed Runtime:",
          str(int((tot_time/3600)))+":"+str(int((tot_time%3600)/60))+":"
          +str(int((tot_time%3600)%60)) )
Exemplo n.º 28
0
def main():
    # TODO 0: Measures total program runtime by collecting start time
    start_time = time()

    # TODO 1: Define get_input_args function within the file get_input_args.py
    # This function retrieves 3 Command Line Arugments from user as input from
    # the user running the program from a terminal window. This function returns
    # the collection of these command line arguments from the function call as
    # the variable in_arg
    #*** Implemented in VS CODE as launch.json configuration choice for each model
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg
    check_command_line_arguments(in_arg)

    # From pathlib use Path to convert the relative path to an absolute.
    # There is some discussion that .absolute() is hidden and .resolve() should be used, but
    # test results from the field suggest that absolute works and resolve does not.  Another
    # suggestion was to use Path.cwd() / path.
    # https://discuss.python.org/t/pathlib-absolute-vs-resolve/2573
    in_arg.dir = Path(in_arg.dir).absolute()

    # TODO 2: Define get_pet_labels function within the file get_pet_labels.py
    # Once the get_pet_labels function has been defined replace 'None'
    # in the function call with in_arg.dir  Once you have done the replacements
    # your function call should look like this:
    #             get_pet_labels(in_arg.dir)
    # This function creates the results dictionary that contains the results,
    # this dictionary is returned from the function call as the variable results

    # According to get_pet_labels function documentation, the image.dir argument passed
    # in is supposed to be a 'full' path, while the command line path argument can be
    # a relative path, that's why in_arg.dir is changed to a full path above
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results
    check_creating_pet_image_labels(results)

    # TODO 3: Define classify_images function within the file classiy_images.py
    # Once the classify_images function has been defined replace first 'None'
    # in the function call with in_arg.dir and replace the last 'None' in the
    # function call with in_arg.arch  Once you have done the replacements your
    # function call should look like this:
    #             classify_images(in_arg.dir, results, in_arg.arch)
    # Creates Classifier Labels with classifier function, Compares Labels,
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results
    check_classifying_images(results)

    # TODO 4: Define adjust_results4_isadog function within the file adjust_results4_isadog.py
    # Once the adjust_results4_isadog function has been defined replace 'None'
    # in the function call with in_arg.dogfile  Once you have done the
    # replacements your function call should look like this:
    #          adjust_results4_isadog(results, in_arg.dogfile)
    # Adjusts the results dictionary to determine if classifier correctly
    # classified images as 'a dog' or 'not a dog'. This demonstrates if
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)

    # TODO 5: Define calculates_results_stats function within the file calculates_results_stats.py
    # This function creates the results statistics dictionary that contains a
    # summary of the results statistics (this includes counts & percentages). This
    # dictionary is returned from the function call as the variable results_stats
    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)

    # TODO 6: Define print_results function within the file print_results.py
    # Once the print_results function has been defined replace 'None'
    # in the function call with in_arg.arch  Once you have done the
    # replacements your function call should look like this:
    #      print_results(results, results_stats, in_arg.arch, True, True)
    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)

    print_results(results, results_stats, in_arg.arch, in_arg.incorrect_dog,
                  in_arg.incorrect_breed)

    # TODO 0: Measure total program runtime by collecting end time
    # TODO 0: Computes overall runtime in seconds & prints it in hh:mm:ss format
    # From: https://stackoverflow.com/questions/7999935/python-datetime-to-string-without-microsecond-component

    hours, remainder = divmod(time() - start_time, 3600)
    minutes, seconds = divmod(remainder, 60)
    print('\nExecution time {:02}:{:02}:{:02}'.format(int(hours), int(minutes),
                                                      int(seconds)))
Exemplo n.º 29
0
   
    classify_images(None, results, None)

    
    check_classifying_images(results)    

    
     
    adjust_results4_isadog(results, None)

        check_classifying_labels_as_dogs(results)


    
    results_stats = calculates_results_stats(results)

    
    check_calculating_results(results, results_stats)


    
    print_results(results, results_stats, None, True, True)
    
    
    end_time = time()
    
    
    tot_time = end_time - start_time
    print("\n** Total Elapsed Runtime:",
          str(int((tot_time/3600)))+":"+str(int((tot_time%3600)/60))+":"
Exemplo n.º 30
0
def main():
    # TODO 0: Measures total program runtime by collecting start time
    
    start_time = time()
   # for i in range(0,5):
      #  sleep(1)
    


    
    # TODO 1: Define get_input_args function within the file get_input_args.py
    # This function retrieves 3 Command Line Arugments from user as input from
    # the user running the program from a terminal window. This function returns
    # the collection of these command line arguments from the function call as
    # the variable in_arg
    in_arg = get_input_args()

    # Function that checks command line arguments using in_arg  
    check_command_line_arguments(in_arg)

    
    # TODO 2: Define get_pet_labels function within the file get_pet_labels.py
    # Once the get_pet_labels function has been defined replace 'None' 
    # in the function call with in_arg.dir  Once you have done the replacements
    # your function call should look like this: 
    #             get_pet_labels(in_arg.dir)
    # This function creates the results dictionary that contains the results, 
    # this dictionary is returned from the function call as the variable results
    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results    
    check_creating_pet_image_labels(results)


    # TODO 3: Define classify_images function within the file classiy_images.py
    # Once the classify_images function has been defined replace first 'None' 
    # in the function call with in_arg.dir and replace the last 'None' in the
    # function call with in_arg.arch  Once you have done the replacements your
    # function call should look like this: 
    #             classify_images(in_arg.dir, results, in_arg.arch)
    # Creates Classifier Labels with classifier function, Compares Labels, 
    # and adds these results to the results dictionary - results
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results    
    check_classifying_images(results)    

    
    # TODO 4: Define adjust_results4_isadog function within the file adjust_results4_isadog.py
    # Once the adjust_results4_isadog function has been defined replace 'None' 
    # in the function call with in_arg.dogfile  Once you have done the 
    # replacements your function call should look like this: 
    #          adjust_results4_isadog(results, in_arg.dogfile)
    # Adjusts the results dictionary to determine if classifier correctly 
    # classified images as 'a dog' or 'not a dog'. This demonstrates if 
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)


    # TODO 5: Define calculates_results_stats function within the file calculates_results_stats.py
    # This function creates the results statistics dictionary that contains a
    # summary of the results statistics (this includes counts & percentages). This
    # dictionary is returned from the function call as the variable results_stats    
    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)


    # TODO 6: Define print_results function within the file print_results.py
    # Once the print_results function has been defined replace 'None' 
    # in the function call with in_arg.arch  Once you have done the 
    # replacements your function call should look like this: 
    #      print_results(results, results_stats, in_arg.arch, True, True)
    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)
    
    # TODO 0: Measure total program runtime by collecting end time
    end_time = time()
    
    # TODO 0: Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time
    print("\n** Total Elapsed Runtime:",
          str(int((tot_time/3600)))+":"+str(int((tot_time%3600)/60))+":"
          +str(int((tot_time%3600)%60)) )
Exemplo n.º 31
0
def main():
    #  Measures total program runtime by collecting start time
    start_time = time()
    
    in_arg = get_input_args()
    
    print("Command Line Arguments:\n    dir =", in_arg.dir, "\n    arch =", in_arg.arch, "\n    dogfile =", in_arg.dogfile)

    # Function that checks command line arguments using in_arg  
    check_command_line_arguments(in_arg)

    results = get_pet_labels(in_arg.dir)

    # Function that checks Pet Images in the results Dictionary using results    
    check_creating_pet_image_labels(results)
    
    classify_images(in_arg.dir, results, in_arg.arch)

    # Function that checks Results Dictionary using results    
    check_classifying_images(results)    

    
    # TODO 4: Define adjust_results4_isadog function within the file adjust_results4_isadog.py
    # Once the adjust_results4_isadog function has been defined replace 'None' 
    # in the function call with in_arg.dogfile  Once you have done the 
    # replacements your function call should look like this: 
    #          adjust_results4_isadog(results, in_arg.dogfile)
    # Adjusts the results dictionary to determine if classifier correctly 
    # classified images as 'a dog' or 'not a dog'. This demonstrates if 
    # model can correctly classify dog images as dogs (regardless of breed)
    adjust_results4_isadog(results, in_arg.dogfile)

    # Function that checks Results Dictionary for is-a-dog adjustment using results
    check_classifying_labels_as_dogs(results)


    # TODO 5: Define calculates_results_stats function within the file calculates_results_stats.py
    # This function creates the results statistics dictionary that contains a
    # summary of the results statistics (this includes counts & percentages). This
    # dictionary is returned from the function call as the variable results_stats    
    # Calculates results of run and puts statistics in the Results Statistics
    # Dictionary - called results_stats
    results_stats = calculates_results_stats(results)

    # Function that checks Results Statistics Dictionary using results_stats
    check_calculating_results(results, results_stats)


    # TODO 6: Define print_results function within the file print_results.py
    # Once the print_results function has been defined replace 'None' 
    # in the function call with in_arg.arch  Once you have done the 
    # replacements your function call should look like this: 
    #      print_results(results, results_stats, in_arg.arch, True, True)
    # Prints summary results, incorrect classifications of dogs (if requested)
    # and incorrectly classified breeds (if requested)
    print_results(results, results_stats, in_arg.arch, True, True)
    
    #Check Time to code
    #sleep(10)
    # TODO 0: Measure total program runtime by collecting end time
    end_time = time()
    
    # TODO 0: Computes overall runtime in seconds & prints it in hh:mm:ss format
    tot_time = end_time - start_time #calculate difference between end time and start time
    print("\n** Total Elapsed Runtime:",
          str(int((tot_time/3600)))+":"+str(int((tot_time%3600)/60))+":"
          +str(int((tot_time%3600)%60)) )