Keras 深度学习模型到安卓 [英] Keras deep learning model to android

查看:45
本文介绍了Keras 深度学习模型到安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 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

  • 将 Tensorflow 配置为您的 Keras 后端.

  • Configure Tensorflow 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:

方案一:在 Tensflow 中导入模型

1- 构建 Tensorflow 模型

1- Build Tensorflow model

  • Build tensorflow model from keras model use this code (link updated)

2- 构建 Android 应用程序并调用 Tensorflow.检查这个教程 和谷歌的这个 官方演示 学习如何做

2- Build Android app and call Tensorflow. check this tutorial and this official demo from google to learn how to do it.

方案二:在java中导入模型
1- deeplearning4j 一个允许导入 keras 模型的 Java 库:教程链接
2- 在 Android 中使用 deeplearning4j:因为您在 Java 世界中,所以很容易.检查本教程

这篇关于Keras 深度学习模型到安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆