Coder Social home page Coder Social logo

humorbei / tensorflowjsclientsideprediction Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mattkovtun/tensorflowjsclientsideprediction

0.0 0.0 0.0 5.84 MB

An example of a client side prediction made with TensorFlowJS

JavaScript 35.41% Python 22.02% CSS 24.20% HTML 18.37%

tensorflowjsclientsideprediction's Introduction

This example meant to show how to do a client side prediction for trained model

Reason

Imagine you created a model which does some great stuff and helps people. You put this model on a web, and daily usage is around 1000 queries, not a lot. The simple server can handle it, but one day this model was discovered by the public, and you started receiving 100k queries daily, the same server would probably die. So now you can either scale server and add more and more memory, or you can try rewriting prediction to the client side. In case you choose the second option here is a tutorial for you.

Components

Backend: Flask (I know that TFJS supports node now but for the sake of suitable preprocessing it's in python)

Preprocessing: cv2, numpy, any python library you want

Frontend: tensorflowjs (I have a script in head from cdn, made for python developers in order not to download a module)

Model

You can download my model or train a new one. Don't forget to convert it to an appropriate format for TFJS.

Usage

Simply run app.py, open link in browser
Upload files and press predict, if you select around 100-300 files, you can observe how browser instantly eats your CPU. :)

For more details please read:

https://medium.com/@mattkovtun/client-side-prediction-with-tensorflow-js-e143ed53235b

Enjoy!

tensorflowjsclientsideprediction's People

Contributors

mattkovtun 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.