Coder Social home page Coder Social logo

elizabethts / deploy-mlm-flask-heroku Goto Github PK

View Code? Open in Web Editor NEW
25.0 25.0 91.0 42 KB

Deploy a ML model with Flask to Heroku

Home Page: https://towardsdatascience.com/create-an-api-to-deploy-machine-learning-models-using-flask-and-heroku-67a011800c50

License: MIT License

Jupyter Notebook 93.98% Python 6.02%

deploy-mlm-flask-heroku's People

Contributors

elizabethts avatar neozenith 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

Watchers

 avatar  avatar

deploy-mlm-flask-heroku's Issues

How to pass string as input

My model takes website url as input and predicts its category and give the output as category name. when i am trying to pass

data = {"url" : "www.google.com"}

I get response as 400

And also my model takes list as input

For example it takes model.predict(['www.google.com'])

so in the app.py file how should I pass my function.

currently it is
`def predict():
# get data
data = request.get_json(force=True)

# convert data into dataframe
#data = data.update(data.items())
#data_df = pd.DataFrame.from_dict(data)

# predictions
result = model.predict([data])

# send back to browser
output = {'results': (result)}

# return data
return jsonify(results=output)`

Thanks.

ModuleNotFoundError: No module name d 'sklearn.linear_model._logistic'

My flask app is deployed successfully on heroku but as soon as I am trying to make a post request to the server on heroku it is giving me an error . The logs are attached below. Can you please help me with this?

2020-03-05T09:21:49.428537+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/util.py", line 350, in import_app
2020-03-05T09:21:49.428537+00:00 app[web.1]: import(module)
2020-03-05T09:21:49.428537+00:00 app[web.1]: File "/app/app.py", line 35, in
2020-03-05T09:21:49.428538+00:00 app[web.1]: model = pickle.load(open('model.pkl
','rb'))
2020-03-05T09:21:49.428538+00:00 app[web.1]: ModuleNotFoundError: No module name
d 'sklearn.linear_model.logistic'
2020-03-05T09:21:49.429456+00:00 app[web.1]: [2020-03-05 09:21:49 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2020-03-05T09:21:49.592805+00:00 app[web.1]: Traceback (most recent call last):
2020-03-05T09:21:49.592814+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/arbiter.py", line 210, in run
2020-03-05T09:21:49.593114+00:00 app[web.1]: self.sleep()
2020-03-05T09:21:49.593117+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/arbiter.py", line 360, in sleep
2020-03-05T09:21:49.593345+00:00 app[web.1]: ready = select.select([self.PIPE[0]
], [], [], 1.0)
2020-03-05T09:21:49.593348+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2020-03-05T09:21:49.593476+00:00 app[web.1]: self.reap_workers()
2020-03-05T09:21:49.593479+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2020-03-05T09:21:49.593721+00:00 app[web.1]: raise HaltServer(reason, self.WORKE
R_BOOT_ERROR)
2020-03-05T09:21:49.593765+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltSe
rver 'Worker failed to boot.' 3>
2020-03-05T09:21:49.593769+00:00 app[web.1]:
2020-03-05T09:21:49.593769+00:00 app[web.1]: During handling of the above except
ion, another exception occurred:
2020-03-05T09:21:49.593769+00:00 app[web.1]:
2020-03-05T09:21:49.593772+00:00 app[web.1]: Traceback (most recent call last):
2020-03-05T09:21:49.593803+00:00 app[web.1]: File "/app/.heroku/python/bin/gunic
orn", line 8, in
2020-03-05T09:21:49.593928+00:00 app[web.1]: sys.exit(run())
2020-03-05T09:21:49.593932+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/app/wsgiapp.py", line 61, in run
2020-03-05T09:21:49.594073+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS]
[APP_MODULE]").run()
2020-03-05T09:21:49.594077+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/app/base.py", line 223, in run
2020-03-05T09:21:49.594254+00:00 app[web.1]: super(Application, self).run()
2020-03-05T09:21:49.594255+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/app/base.py", line 72, in run
2020-03-05T09:21:49.594389+00:00 app[web.1]: Arbiter(self).run()
2020-03-05T09:21:49.594393+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/arbiter.py", line 232, in run
2020-03-05T09:21:49.594560+00:00 app[web.1]: self.halt(reason=inst.reason, exit

status=inst.exit_status)
2020-03-05T09:21:49.594564+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/arbiter.py", line 345, in halt
2020-03-05T09:21:49.594782+00:00 app[web.1]: self.stop()
2020-03-05T09:21:49.594786+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/arbiter.py", line 393, in stop
2020-03-05T09:21:49.595007+00:00 app[web.1]: time.sleep(0.1)
2020-03-05T09:21:49.595008+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2020-03-05T09:21:49.595178+00:00 app[web.1]: self.reap_workers()
2020-03-05T09:21:49.595179+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho
n3.6/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2020-03-05T09:21:49.595416+00:00 app[web.1]: raise HaltServer(reason, self.WORKE
R_BOOT_ERROR)
2020-03-05T09:21:49.595445+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltSe
rver 'Worker failed to boot.' 3>
2020-03-05T09:21:49.709280+00:00 heroku[web.1]: State changed from up to crashed

2020-03-05T09:21:49.690064+00:00 heroku[web.1]: Process exited with status 1
2020-03-05T09:22:17.508663+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=titanic-app-predictions.herokuapp.com request_id=
9af1c638-4c7e-4eab-ae1f-3a3f4018f71e fwd="103.251.141.154" dyno= connect= servic
e= status=503 bytes= protocol=https

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.