1) We select an Neural Network architecture and train it for a centrain number of times using GPU and then saves the model for further use.
2) We load the saved model and provide it with an image to for testing the classification model. The project also utilizes transfer learning to import already trained classifiers from the PyTorch package while modifying the classifier attribute of each package.
These are the files included as part of the project and what each contains:
- Image Classifier Project.ipynb: This is the Jupyter notebook where I conducted all my activities, including a little more than what is included in the predict.py and train.py files.
- Image Classifier Project.html: Same as the file above, except in HTML form.
- train.py: This file accepts inputs from the command line prompt and takes the work from the Jupyter notebook for the following activities:
- Creating the Datasets
- Creating the Architecture
- Training the model
- Saving the Model
- predict.py: This file accepts inputs from the command line prompt and takes the work from the Jupyter notebook for the following activities
- Loading the Model
- Class Prediction
- Train a new network on a data set with train.py
- Basic usage: python train.py (file should be in data_directory)
- Prints out training loss, validation loss, and validation accuracy as the network trains
- Other params for different purpose:
- Set directory to save checkpoints :"python train.py data_dir --save_dir save_directory"
- Choose architecture :"python train.py data_dir --arch "vgg13" "
- Set hyperparameters :"python train.py data_dir --learning_rate 0.01 --hidden_units 512 --epochs 20"
- Use GPU for training :"python train.py data_dir --gpu"
- Predict flower name from an image with predict.py along with the probability of that name. That is, you'll pass in a single image /path/to/image and return the flower name and class probability.
- Basic usage: python predict.py /path/to/image checkpoint
- Options:
-
- Return top KK most likely classes :"predict.py input checkpoint --top_k 3"
- Use a mapping of categories to real names :"python predict.py input checkpoint --category_names cat_to_name.json"
- Use GPU for inference :"python predict.py input checkpoint --gpu"