概述:
我正在尝试部署一个使用OpenCV和Tensorflow对人脸表情进行分类的网络应用程序。因此,一个人上传一张照片,应用程序会在人脸周围生成一个带有该人表情的边框。当我在本地机器上运行Streamlit应用程序时,它完全符合相同的requirements.txt。然而,该应用程序在Heroku上不断崩溃。
这是日志的输出:
2020-07-21T12:56:02.435384+00:00 heroku[web.1]: Starting process with command `sh setup.sh && streamlit run app.py`
2020-07-21T12:56:05.484243+00:00 app[web.1]:
2020-07-21T12:56:05.484269+00:00 app[web.1]: Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
2020-07-21T12:56:05.484271+00:00 app[web.1]: As a result, 'server.enableCORS' is being overridden to 'true'.
2020-07-21T12:56:05.484271+00:00 app[web.1]:
2020-07-21T12:56:05.484272+00:00 app[web.1]: More information:
2020-07-21T12:56:05.484272+00:00 app[web.1]: In order to protect against CSRF attacks, we send a cookie with each request.
2020-07-21T12:56:05.484273+00:00 app[web.1]: To do so, we must specify allowable origins, which places a restriction on
2020-07-21T12:56:05.484273+00:00 app[web.1]: cross-origin resource sharing.
2020-07-21T12:56:05.484273+00:00 app[web.1]:
2020-07-21T12:56:05.484274+00:00 app[web.1]: If cross origin resource sharing is required, please disable server.enableXsrfProtection.
2020-07-21T12:56:05.484279+00:00 app[web.1]:
2020-07-21T12:56:08.293129+00:00 app[web.1]:
2020-07-21T12:56:08.293160+00:00 app[web.1]: Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
2020-07-21T12:56:08.293161+00:00 app[web.1]: As a result, 'server.enableCORS' is being overridden to 'true'.
2020-07-21T12:56:08.293161+00:00 app[web.1]:
2020-07-21T12:56:08.293163+00:00 app[web.1]: More information:
2020-07-21T12:56:08.293164+00:00 app[web.1]: In order to protect against CSRF attacks, we send a cookie with each request.
2020-07-21T12:56:08.293164+00:00 app[web.1]: To do so, we must specify allowable origins, which places a restriction on
2020-07-21T12:56:08.293164+00:00 app[web.1]: cross-origin resource sharing.
2020-07-21T12:56:08.293165+00:00 app[web.1]:
2020-07-21T12:56:08.293165+00:00 app[web.1]: If cross origin resource sharing is required, please disable server.enableXsrfProtection.
2020-07-21T12:56:08.293166+00:00 app[web.1]:
2020-07-21T12:56:08.485342+00:00 app[web.1]: libgcc_s.so.1 must be installed for pthread_cancel to work
2020-07-21T12:56:08.537947+00:00 heroku[web.1]: Process exited with status 134
2020-07-21T12:58:42.417606+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fer-2013.herokuapp.com request_id=ad34f9af-1463-49a4-b60d-21e642a793cd fwd="122.175.13.11" dyno= connect= service= status=503 bytes= protocol=https
2020-07-21T12:58:44.741839+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fer-2013.herokuapp.com request_id=e483f00f-01e1-46f7-bc66-e8f1020c3638 fwd="122.175.13.11" dyno= connect= service= status=503 bytes= protocol=https
这是我的Procfile的输出:
web: sh setup.sh && streamlit run app.py
这是我的setup.sh:的输出
mkdir -p ~/.streamlit/
echo "
[server]n
headless = truen
port = $PORTn
enableCORS = falsen
n
" > ~/.streamlit/config.toml
以下是GitHub Repo的链接:https://github.com/Manas73/fer-2013
原来我的requirements.txt中有opencv python,我只是用opencv contrib python headless替换了它。它现在运行得很好。