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)))
Esempio n. 2
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)))
Esempio n. 3
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)
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("*******************************")
Esempio n. 5
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)))
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)) )