share.streamlit 找不到 pkl 文件

share.streamlit can't find pkl file

我有一个在本地主机上运行良好的 streamlit 应用程序。但是部署到share.streamlit时,不断弹出FileNotFoundError 我已经将应用更改为使用 Python 3.9(这与我在本地计算机上使用的版本相同)。 这是回购协议的 link:https://github.com/leminhds/breast-cancer-diabetes-and-liver-disease-predictor 这是应用程序的 link:https://share.streamlit.io/leminhds/breast-cancer-diabetes-and-liver-disease-predictor/app/app.py

任何帮助将不胜感激,因为过去几个小时我一直在尝试重命名路径、重新定位 pkl 文件的不同组合,但没有任何效果。谢谢

这个问题是因为我使用的是相对路径。当上传到 Share.streamlit 时,它不再起作用了。

为了克服这个问题,我只是使用pathlib 模块来查找github 上文件夹的根目录。示例:

from pathlib import Path

pkl_path = Path(__file__).parents[1] / 'pages/liver_model.pkl'