Coder Social home page Coder Social logo

arianfotouhi / classifierapi Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 46.33 MB

A Docker app for PyTorch based image classifier and its API, for furniture industry applications.

Jupyter Notebook 65.27% Python 26.47% Dockerfile 0.47% CSS 3.57% HTML 4.21%
deep-learning docker flask python pytorch

classifierapi's Introduction

The project aims to build a Deep Learning based image classifier to distinguish chair, bed and sofa. Furthermore, it accompanies an API to receive the input image and return the result of classification.

In terms of the development stages, in the first step I made Classifier.ipynb that represents the neural network code. The program employs PyTorch framework wherein it has two convolutional layers (to extract features) following the two fully connected layers (to classify based on the features). It is noteworthy, in case of running the code on a certain machine, "root_dir" variable should be changed based on the path of the used machine. After introducing the network structure, the code aims to receive and preprocess the data to make it suitable for dataloader of PyTorch. Following that, Adam for the optimizer and CrossEntropyLoss for the loss are selected and the training phase commences. Finally, the train loss and test accuracy are measured. It should be noted the data consist of 100 images for each class (all made 300 images) and I allocated 80% to train and the rest to the test. As for the results, the test accuracy revolves around 78-83%  as I ran the code multiple times, and the model that I saved for the API is the 80% version.

Considering API building, I made API.py along with html and css files (in templates and static folder). API.py is based on Flask web framework and it receives the input images, by virtue of html page, then loads the deep learning model, and shows the result of classification. As I analyzed the results, it works reliably for most of the images while as the inputted images become more similar to a combination of two classes (e.g. a sofa that has a similar design to a bed) it may fail to predict. I deployed the code on a web host to make it easier to be reached. The web host is pythonanywhere.com and flask_app.py is the code that is used by the web host. Basically, it is similar to API.py while it has minor changes like different the file name. 

Furthermore, I appended a Dockerfile with aim of building a docker image. Respecting the docker file, it utilizes the requirements.txt file to provide the program dependencies, as it runs the pip install command. besides, it runs the application by CMD.

Last but not least, the action section of this GitHub repository is depicting a docker based workflow in which, as described in docker-image.yml, the workflow builds the docker image of the program then push it to the dockerhub account everytime based on CICD pipeline. 

classifierapi's People

Contributors

arianfotouhi avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.