MarckK / image_classifier

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image Classifier

This project trains an image classifier to recognize different species of flowers.

Prerequisites

The code for this project is written in Python 3.10, PyTorch 1.12, and torchvision 0.14. These are prerequisites for both the .ipynb and the .py files.

Command Line Application

  • Train a new network on a data set with train.py

    • Basic Usage : python train.py data_directory
    • Prints out the current epoch, training loss, validation loss, and validation accuracy as the model trains.
    • Options:
      • Choose model architecture (resnet50, vgg16, alexnet): python train.py data_dir --arch "resnet50"
      • Set hyperparameters: python train.py data_dir --lr 0.001 --hidden_units 250 --epochs 5
      • 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 K most likely classes: python predict.py input checkpoint ---top_k 5
      • Select file mapping 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

About


Languages

Language:Jupyter Notebook 99.5%Language:Python 0.5%