/Deep_learning--image-classification

Image classification project using tensorflow

Primary LanguageJupyter Notebook

Image classification on Cifar-10 dataset

This project is my practice on using the tensorflow library to train a CNN network on the cifar-10 dataset.

The accuracy can reach 72%, which is not too bad for such a shallow model (only two CNN + maxpool layers and two fully connected layers and dropout layer)

How to run this project on floydhub.com

In order to run this code and train the CNN using the cifar-10, you will need gpu. One of the convenient way is to use floydhub, and the details are as follows.

  1. Create an account on floydhub.com (don't forget to confirm your email). You will automatically receive 100 free GPU hours.

  2. Install the floyd command on your computer:

     pip install -U floyd-cli
    

    Do this even if you already installed floyd-cli before, just to make sure you have the most recent version (Its pace of development is fast!).

  3. Associate the command with your Floyd account:

     floyd login
    

    (a page with authentication token will open; you will need to copy the token into your terminal)

  4. Clone this repository:

     git clone https://github.com/xiaomaogy/Deep_learning--image-classification.git
    
  5. Enter the folder for the image classification project:

     cd Deep_learning--image-classification
    
  6. Initiate a Floyd project:

     floyd init image_classification
    
  7. Run the project:

     floyd run --gpu --env tensorflow --mode jupyter --data diSgciLH4WA7HpcHNasP9j
    

    It will be run on a machine with GPU (--gpu), using a Tenserflow environment (--env tensorflow), as a Jupyter notebook (--mode jupyter), with Floyd's built-in cifar-10 dataset available (--data diSgciLH4WA7HpcHNasP9j).

  8. Wait for the Jupyter notebook to become available and then access the URL displayed in the terminal (described as "path to jupyter notebook"). You will see the notebook.

  9. Remember to explicitly stop the experiment when you are not using the notebook. As long as it runs (even in the background) it will cost GPU hours. You can stop an experiment in the "Experiments" section on floyd.com or using the floyd stop command:

     floyd stop ID
    

    (where ID is the "RUN ID" displayed in the terminal when you run the project; if you lost it you can also find it in the "Experiments" section on floyd.com)

Important: When you run a project it will always start from scratch (i.e. from the state present locally on your computer). If you made changes in the remote jupiter notebook during a previous run, the changes will not be present in subsequent runs. To make them permanent you need to add the changes to your local project folder. When running the notebook you can download them directly from Jupyter - File / Download / Notebook. After downloading it, just replace your local dlnd_image_classification.ipynb file with the newly downloaded one.

Alternatively, If you already stoped the experiment, you can still download the file using the floyd output command:

floyd output ID

(where ID is the "RUN ID" displayed in the terminal when you run the project; if you lost it you can also find it in the "Experiments" section on floyd.com)

Just run the command above, download dlnd_image_classification.ipynb and replace your local version with the newly downloaded one.