简体   繁体   English

android studio中如何使用.h5文件?

[英]How to use .h5 file in android studio?

I'm trying to make a chatbot in my android app, so I made it with python(with Keras and.h5 trained model) and linked it with android using chaquo but I'm still facing this error.我正在尝试在我的 android 应用程序中创建一个聊天机器人,所以我使用 python(使用 Keras 和.h5 训练模型)将其与 android 使用 chaquo 链接,但我仍然面临此错误。 (I'm totally beginner), any help plz! (我完全是初学者),请帮忙!

com.chaquo.python.PyException: OSError: Unable to open file (unable to open file: name = 'chatbot_model.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

I just notice that this is not just related to.h5 file, I add to a python directory all files beside.py file, and android can not see or open any file except.py file我只是注意到这不仅仅与.h5文件有关,我将所有文件beside.py文件都添加到python目录中,而android除了.py文件之外看不到或打开任何文件

The current directory on Android is undefined, so you need to use the absolute path of your data file, as described in the Chaquopy documentation : Android 上的当前目录未定义,因此您需要使用数据文件的绝对路径,如Chaquopy 文档中所述:

For example, if the data file is in the same directory as the Python file:例如,如果数据文件与 Python 文件位于同一目录中:

 from os.path import dirname, join filename = join(dirname(__file__), "filename.txt")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM