TODO: Add Argument parsing
--dir -> pet images folder --arch -> CNN Architecture --dogfile -> File with Dog Names
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# */AIPND-revision/intropyproject-classify-pet-images/get_input_args.py
|
# */AIPND-revision/intropyproject-classify-pet-images/get_input_args.py
|
||||||
#
|
#
|
||||||
# PROGRAMMER:
|
# PROGRAMMER:
|
||||||
# DATE CREATED:
|
# DATE CREATED:
|
||||||
# REVISED DATE:
|
# REVISED DATE:
|
||||||
# PURPOSE: Create a function that retrieves the following 3 command line inputs
|
# PURPOSE: Create a function that retrieves the following 3 command line inputs
|
||||||
# from the user using the Argparse Python module. If the user fails to
|
# from the user using the Argparse Python module. If the user fails to
|
||||||
# provide some or all of the 3 inputs, then the default values are
|
# provide some or all of the 3 inputs, then the default values are
|
||||||
# used for the missing inputs. Command Line Arguments:
|
# used for the missing inputs. Command Line Arguments:
|
||||||
# 1. Image Folder as --dir with default value 'pet_images'
|
# 1. Image Folder as --dir with default value 'pet_images'
|
||||||
@@ -17,17 +17,18 @@
|
|||||||
# Imports python modules
|
# Imports python modules
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
# TODO 1: Define get_input_args function below please be certain to replace None
|
# TODO 1: Define get_input_args function below please be certain to replace None
|
||||||
# in the return statement with parser.parse_args() parsed argument
|
# in the return statement with parser.parse_args() parsed argument
|
||||||
# collection that you created with this function
|
# collection that you created with this function
|
||||||
#
|
#
|
||||||
def get_input_args():
|
def get_input_args():
|
||||||
"""
|
"""
|
||||||
Retrieves and parses the 3 command line arguments provided by the user when
|
Retrieves and parses the 3 command line arguments provided by the user when
|
||||||
they run the program from a terminal window. This function uses Python's
|
they run the program from a terminal window. This function uses Python's
|
||||||
argparse module to created and defined these 3 command line arguments. If
|
argparse module to created and defined these 3 command line arguments. If
|
||||||
the user fails to provide some or all of the 3 arguments, then the default
|
the user fails to provide some or all of the 3 arguments, then the default
|
||||||
values are used for the missing arguments.
|
values are used for the missing arguments.
|
||||||
Command Line Arguments:
|
Command Line Arguments:
|
||||||
1. Image Folder as --dir with default value 'pet_images'
|
1. Image Folder as --dir with default value 'pet_images'
|
||||||
2. CNN Model Architecture as --arch with default value 'vgg'
|
2. CNN Model Architecture as --arch with default value 'vgg'
|
||||||
@@ -36,13 +37,20 @@ def get_input_args():
|
|||||||
Parameters:
|
Parameters:
|
||||||
None - simply using argparse module to create & store command line arguments
|
None - simply using argparse module to create & store command line arguments
|
||||||
Returns:
|
Returns:
|
||||||
parse_args() -data structure that stores the command line arguments object
|
parse_args() -data structure that stores the command line arguments object
|
||||||
"""
|
"""
|
||||||
# Create Parse using ArgumentParser
|
# Create Parse using ArgumentParser
|
||||||
|
parser = argparse.ArgumentParser(description="Identify dog breeds in images")
|
||||||
|
|
||||||
# Create 3 command line arguments as mentioned above using add_argument() from ArguementParser method
|
# Create 3 command line arguments as mentioned above using add_argument() from ArguementParser method
|
||||||
|
parser.add_argument(
|
||||||
|
"-d", "--dir", default="pet_images/", help="path to the pet images folder"
|
||||||
# Replace None with parser.parse_args() parsed argument collection that
|
)
|
||||||
# you created with this function
|
parser.add_argument("-a", "--arch", default="vgg", help="CNN Model Architecture")
|
||||||
return None
|
parser.add_argument(
|
||||||
|
"-f", "--dogfile", default="dognames.txt", help="Textfile with Dog Names"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Replace None with parser.parse_args() parsed argument collection that
|
||||||
|
# you created with this function
|
||||||
|
return parser.parse_args()
|
||||||
|
|||||||
Reference in New Issue
Block a user