加载时找不到泡菜文件
我使用以下代码保存了与泡菜的分类器模型 -
import pickle
with open('model.pickle', 'wb') as fid:
pickle.dump(clf, fid)
这是我加载泡菜模型的corce.py文件,在部署期间调用了相同的文件。另请注意,所有这些文件(代码,腌制文件和相关文件)都位于同一目录中。
# Initialize the deployment environment
def init():
global obj
with open('./model.pickle', 'rb') as f:
obj = pickle.load(f)
这将存储在某些目录var/azureml-app
运行此部署代码后,这是我收到的错误 -
open('/mnt/batch/tasks/shared/LS_root/mounts/clusters/model.pickle', 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/batch/tasks/model.pickle'
I have saved a classifier model with pickle using the following code-
import pickle
with open('model.pickle', 'wb') as fid:
pickle.dump(clf, fid)
This is the score.py file where I am loading the pickle model and the same file is called during deployment. Also note that, all these files (code, pickle file and related files) are in the same directory.
# Initialize the deployment environment
def init():
global obj
with open('./model.pickle', 'rb') as f:
obj = pickle.load(f)
This is getting stored in some directory var/azureml-app
After running this deployment code, this is the error I am getting-
open('/mnt/batch/tasks/shared/LS_root/mounts/clusters/model.pickle', 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/batch/tasks/model.pickle'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想出了解决此错误的方法。
而不是按照
您需要加载模型来加载模型,因为
azureml_model_dir
将将其存储的模型的环境目录录取。这将解决错误。
I figured out the way to solve this error.
Instead of loading the model as
You need to load the model as
The
AZUREML_MODEL_DIR
will take the environment directory of the model where it is stored.This will solve the error.