Keras深度学习模型到android [英] Keras deep learning model to android
问题描述
我正在为Android开发一个实时对象分类应用程序.首先,我使用"keras"创建了一个深度学习模型,并且已经将训练过的模型保存为"model.h5"文件.我想知道如何在android中使用该模型进行图像分类.
I'm developing a real-time object classification app for android. First I created a deep learning model using "keras" and I already have trained model saved as "model.h5" file. I would like to know how can I use that model in android for image classification.
推荐答案
您不能将Keras直接导出到Android,但必须保存模型
You cant export Keras directly to Android but you have to save the model
-
将Tensflow配置为您的Keras后端.
Configure Tensflow as your Keras backend.
使用model.save(filepath)
保存模型权重(您已经完成此操作)
Save model wights using model.save(filepath)
(you already done this)
然后使用以下解决方案之一加载它:
Then load it with one of the following solutions:
解决方案1:在Tensflow中导入模型
1-建立Tensorflow模型
1- Build Tensorflow model
- 从keras模型中构建张量流模型使用此代码 (链接已更新)
- Build tensorflow model from keras model use this code (link updated)
2-构建Android应用并调用tensflow.检查此教程以及来自Google的官方演示它.
2- Build Android app and call tensflow. check this tutorial and this official demo from google to learn how to do it.
解决方案2:使用Java导入模型
1- deeplearning4j一个Java库允许导入keras模型:教程链接
2-在Android中使用deeplearning4j:这很容易,因为您在Java世界中.查看本教程
Solution 2: Import model in java
1- deeplearning4j a java library allow to import keras model: tutorial link
2- Use deeplearning4j in Android: it is easy since you are in java world. check this tutorial
这篇关于Keras深度学习模型到android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!