-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_input_args.py
More file actions
75 lines (70 loc) · 2.89 KB
/
get_input_args.py
File metadata and controls
75 lines (70 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# */AIPND-revision/intropyproject-classify-pet-images/get_input_args.py
#
# PROGRAMMER: RobertJ Lambert
# DATE CREATED: 26/06/2020
# REVISED DATE:
# 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
# provide some or all of the 3 inputs, then the default values are
# used for the missing inputs. Command Line Arguments:
# 1. Image Folder as --dir with default value 'pet_images'
# 2. CNN Model Architecture as --arch with default value 'vgg'
# 3. Text File with Dog Names as --dogfile with default value 'dognames.txt'
#
##
# Imports python modules
import argparse
# TODO 1: Define get_input_args function below please be certain to replace None
# in the return statement with parser.parse_args() parsed argument
# collection that you created with this function
#
def get_input_args():
"""
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
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
values are used for the missing arguments.
Command Line Arguments:
1. Image Folder as --dir with default value 'pet_images'
2. CNN Model Architecture as --arch with default value 'vgg'
3. Text File with Dog Names as --dogfile with default value 'dognames.txt'
This function returns these arguments as an ArgumentParser object.
Parameters:
None - simply using argparse module to create & store command line arguments
Returns:
parse_args() -data structure that stores the command line arguments object
"""
# Create Parse using ArgumentParser
parser = argparse.ArgumentParser()
# Create 3 command line arguments as mentioned above using add_argument() from ArguementParser method
parser.add_argument(
"--dir",
type=str,
default="pet_images/",
help="path to the folder of pet images",
)
parser.add_argument(
"--arch", type=str, default="vgg", help="CNN model architecture to use"
)
parser.add_argument(
"--dogfile",
type=str,
default="dognames.txt",
help="the file path that contains list of dognames",
)
parser.add_argument(
"--incorrect-dogs", action="store_true", help="Set to False to not print"
)
parser.add_argument(
"--incorrect-breeds", action="store_true", help="Set to False to not print"
)
# Replace None with parser.parse_args() parsed argument collection that
# you created with this function
return parser.parse_args()
# in_args = get_input_args()
# for _, value in in_args._get_kwargs():
# if value is not None:
# print(value)