我有一些代码要部署模型在流光。我只是上传所有文件到github,并分享它在流光应用程序。这是一些代码
if str(course) == 'Multi-layer Perceptron':
file = open("MLP.pkl",'rb')
if str(course) == 'Logistic classifier':
file = open("log_classifier.pkl",'rb')
if str(course) == 'K-neighbour':
file = open("Kneighbor_classifier.pkl",'rb')
f str(course) == 'Naivebayes':
file = open("naivebayes_classifier.pkl",'rb')
model = pickle.load(f)它在当地运行得很好。但是在流光中它有一些bug
ModuleNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs.
Traceback:
File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.py", line 354, in _run_script
exec(code, module.__dict__)
File "/app/nm-khdl/streamlit_app.py", line 45, in <module>
model = pickle.load(file)这是我第一次在流光上工作。所以,谢谢你的阅读!祝您今天愉快!
发布于 2022-01-28 17:25:23
我也有过同样的问题。当我将我的模型保存在scikit-learn中时,泡菜文件依赖于它的结构。
另外,我并没有在python文件中为这个web应用程序streamlit导入sckilearn。因此,使用pipreqs ./生成基于此项目导入的pip requirements.txt文件不包括sklearn。
因此,我必须手动将其包含在requirements.txt:scikit-learn==0.24.2中。
numpy==1.22.0
pandas==1.3.4
plotly==5.5.0
streamlit==1.3.0
scikit-learn==0.24.2发布于 2022-03-29 21:05:37
我有同样的错误,而且很容易修复。
只需创建一个新的txt文件即可。内部,键入
scikit-learn将其保存为与requirements.txt文件相同的目录中的script_runner.py。
瞧,这样就行了。
https://stackoverflow.com/questions/70633236
复制相似问题