elizabethts / deploy-mlm-flask-heroku Goto Github PK
View Code? Open in Web Editor NEWDeploy a ML model with Flask to Heroku
License: MIT License
Deploy a ML model with Flask to Heroku
License: MIT License
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.