Project - How to Deploy an Image Classification Model using Flask

15 / 15

Opening the Web App

Hola! It's time to run the web app we created.

INSTRUCTIONS
  • Make sure you are in the directory Image-Classification-App since the app.py file present in this directory. You could check your present working directory using the command:

    pwd
    

    This command should output the path:

    /home/$USER/Image-Classification-App
    

    If the path displayed is not the same as the above, switch to the Image-Classification-App using

    cd ~
    cd Image-Classification-App
    
  • Before running the web app, let us have a look at the 1000 classes on which our pre-trained model was trained.

    cat /cxldata/dlcourse/1000_imagenet_classes_file.txt
    

    Remember, when we open the web app(the steps which we would perform next), we need to upload the images of classes that are a part of these 1000 classes, as the model is trained to classify the images of these classes only.

  • Since there are multiple hosts on which users work. It is important to find out what is the public name of the host you going to start the server. Find out the local IP address of the host using the command ifconfig eth0|grep "inet ". Note down the IP address from it.

  • Now, open [https://cloudxlab.com/my-lab#ip-mappings] in a new tab and find the public hostname for the IP address.

  • Now go to the console, and execute the following command:

    python app.py
    

    It might take some seconds for the server to start.

  • Now go to your favorite browser (preferably Google Chrome), and go to http://host:port. In my case it is f.cloudxlab.com and the port is 4100. So, for me the link is: http://f.cloudxlab.com:4100/. For you it could be http://e.cloudxlab.com:4100/

  • To stop the server from running, we could use the CTRL+C keys on the keyboard.

Note:

  • If you are facing any issues related to the disk quota, please follow the instructions mentioned here.

  • After using the project, before you leave, here is a small tip for you to save you disk quota:

    • The virtual environment we created holds a lot of packages. We could check the amount of memory used by the virtual environment folder using the following commands in the console:

      cd ~
      cd Image-Classification-App
      du -ah Img-Class-Env
      

    This command du -ah Img-Class-Env lists the amount of space occupied by each file in the Img-Class-Env directory. The last line shows the memory consumed by the directory Img-Class-Env. We could observe that the environment folder occupies a lot of space on the disk.

    • So, we shall remove this folder from our project directory. To remove the virtual environment folder, first we deactivate the environment and use rm -r to delete the directory.

      deactivate
      cd ~
      cd Image-Classification-App
      rm -r Img-Class-Env
      

Note:- This project is a prerequisite for another project titled "How to Build a Low-latency Web App". Therefore, please do not delete the virtual environment if you intend to proceed with the other project.

In the future, when we want to run this web app again, we just need to (1)switch to the directory Image-Classification-App and create the virtual environment again in this project directory, (2) activate the virtual environment (3) install the necessary packages (4) and run the app, as mentioned in the corresponding slides.

See Answer

No hints are availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...