GithubHelp home page GithubHelp logo

eaz / nazar-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from speks7/nazar-server

0.0 0.0 0.0 78.31 MB

Heroku deployed Flask + Bottle server used by nazar app to classify images after converting base64 text to image & going through the tensorflow InceptionV3 trained frozen graph to send predicted name along with octopart description and details

Home Page: https://goo.gl/Af4sDD

License: Apache License 2.0

Shell 1.26% Python 98.74%

nazar-server's Introduction

Nazar-server

icon

Electronic component detection system server for: Nazar App

Description

Tensorflow image classifier with a rest api server to fetch the response from the picture taken using Nazar Application (but lacks HTML UI and only response fetch)

You can use the repository to train yaour dataset using the script and then use the classify.py file to classify the images along with fetching Octopart descriptions for identified components.

Installation

Clone the source locally:

$ git clone https://github.com/aryaminus/nazar-server/
$ cd nazar

Install all dependencies of this project

$ pip install -r requirements.txt

You are okay to execute python script now !

Training (optional)

By default, where you have cloned the repository you have a tf_files/data. This is where the magic begins, you need to gather enough image to create a dataset of several collections. Yes you can not do just one dataset.

You should have something like that :

├── classify.py
├── requierments.txt
├── retrain.py
├── tf_files
│   ├── data
│   │   ├── register
│   │   │   ├── 00.jpeg
│   │   │   ├── 01.jpeg
│   │   │   ├── 02.jpeg
│   │   │   ├── 03.jpeg
│   │   │   ...
│   │   └── capacitor
│   │       ├── 00.jpeg
│   │       ├── 01.jpeg
│   │       ├── 02.jpeg
│   │       ...
└── train_data.sh

If you have already some dataset to another folder you can edit variable in the train_data.sh :

WORKING_DIR="tf_files"

BOTTLENECK_DIR="$WORKING_DIR/bottlenecks"
STEPS=5000
MODEL_DIR="$WORKING_DIR/inception"
OUTPUT_GRAPH="$WORKING_DIR/retrained_graph.pb"
OUTPUT_LABELS="$WORKING_DIR/retrained_labels.txt"
DATA_FOLDER="$WORKING_DIR/data"
SUM_FOLDER="$WORKING_DIR/retrain_logs"
...

And in the classify.py

...
WORKING_DIRECTORY="tf_files"
TMP_DIRECTORY = "tmp"
TRAINED_LABELS="%s/retrained_labels.txt" % (WORKING_DIRECTORY)
RETRAINED_GRAPH="%s/retrained_graph.pb" % (WORKING_DIRECTORY)
...

Then all is done just run sh train_data.sh

You will see something like that : https://i.imgur.com/HxzXqz7.png And the end output is something like this :

INFO:tensorflow:Final test accuracy = 92.31% (N=1000)
INFO:tensorflow:Froze 2 variables.
Converted 2 variables to const ops.

Classify an image

To classify an image you need to run python classify.py in background (with systemctl for instance or screen). Then to check if you have access to the api just do curl http://0.0.0.:8080/status/.

To check from local server type in terminal :

curl -POST -H "Content-type: application/json" -d 
'{
  "data": [{
    "image64" : "base_64_encoded_textbase_64_encoded_text"
  }]
}'
'0.0.0.0:8080/classify_image/'

To check from the heroku server type in terminal :

curl -POST -H "Content-type: application/json" -d 
'{
  "data": [{
    "image64" : "data:image/png;base64,base_64_encoded_text"
  }]
}'
'nazar-server.herokuapp.com/classify_image/'

where the given image64 has extra layer of data:image/png;base64, for base_64_encoded_text

Contributing

  1. Fork it (https://github.com/aryaminus/nazar-server/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

nazar-server's People

Contributors

aryaminus avatar psuzn 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.