Giter VIP home page Giter VIP logo

how_to_deploy_a_keras_model_to_production's Introduction

How to Deploy a Keras Model to Production

Overview

This is the code for this video on Youtube by Siraj Raval. We're going to build a model that recognizes handwritten digit images (MNIST). Developed using TensorFlow and the super simple Keras Library. Wrapped into a Webapp using Flask Micro Framework.

Dependencies

sudo pip install -r requirements.txt

Usage

Once dependencies are installed, just run this to see it in your browser.

python app.py

That's it! It's serving a saved Keras model to you via Flask.

Credits

The credits for this code go to moinudeen. I've merely created a wrapper to get people started.

how_to_deploy_a_keras_model_to_production's People

Contributors

llsourcell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

how_to_deploy_a_keras_model_to_production's Issues

Invalid Syntax in file app.py

Traceback (most recent call last):
File "app.py", line 10, in
from flask import Flask, render_template,request
File "/home/abhay/anaconda2/lib/python2.7/site-packages/flask/init.py", line 19, in
from . import json
File "/home/abhay/anaconda2/lib/python2.7/site-packages/flask/json/init.py", line 25, in
import dataclasses
File "/home/abhay/anaconda2/lib/python2.7/site-packages/dataclasses.py", line 202
class InitVar(metaclass=_InitVarMeta):
^
SyntaxError: invalid syntax

Not found: Resource localhost/dense_2/bias/class tensorflow::Var does not exist.

Please help me out with this error ASAP!!
This is what comes after clicking the predict button

debug
debug2
[2020-05-09 06:02:15,424] ERROR in app: Exception on /predict/ [POST]
Traceback (most recent call last):
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\flask\app.py", line 2311, in wsgi_app
response = self.full_dispatch_request()
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\flask\app.py", line 1834, in full_dispatch_request
rv = self.handle_user_exception(e)
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\flask\app.py", line 1737, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\flask_compat.py", line 36, in reraise
raise value
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\flask\app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\flask\app.py", line 1818, in dispatch_request
return self.view_functionsrule.endpoint
File "C:\Users\hp\how_to_deploy_a_keras_model_to_production-master\app.py", line 75, in predict
out = model.predict(x)
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1113, in predict
self, x, batch_size=batch_size, verbose=verbose, steps=steps)
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\tensorflow\python\keras\engine\training_arrays.py", line 329, in model_iteration
batch_outs = f(ins_batch)
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\tensorflow\python\keras\backend.py", line 3076, in call
run_metadata=self.run_metadata)
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\tensorflow\python\client\session.py", line 1439, in call
run_metadata_ptr)
File "H:\anaconda3\envs\TejasEnv\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 528, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable dense_2/bias from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/dense_2/bias/class tensorflow::Var does not exist.
[[{{node dense_2/BiasAdd/ReadVariableOp}}]]

I am using Tensorflow 1.13.0 version

cannot use a string pattern on a bytes-like object

I get this error:
Traceback (most recent call last): File "C:\Users\Oussama\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "C:\Users\Oussama\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\Oussama\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\Oussama\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\_compat.py", line 33, in reraise raise value File "C:\Users\Oussama\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\Oussama\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "app.py", line 56, in predict convertImage(imgData) File "app.py", line 36, in convertImage imgstr = re.search(r'base64,(.*)',imgData1).group(1) File "C:\Users\Oussama\AppData\Local\Programs\Python\Python35\lib\re.py", line 173, in search return _compile(pattern, flags).search(string) TypeError: cannot use a string pattern on a bytes-like object

Use TF 13 instead of 11

TensorFlow version in the requirements file should updated to last version otherwise some functions won't work ( like convolution )

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.