简体   繁体   English

卷积神经网络-如何在同一张图像上使用两个cnn模型

[英]convolutional neural network- how to use two cnn model on same image

I want to use two differently trained CNN (convolutional neural network) modules on the same image. 我想在同一张图片上使用两个训练有素的CNN(卷积神经网络)模块。 I trained the two modules, 1 for detection and one for classification. 我训练了两个模块,一个用于检测,一个用于分类。 Now, I want to use these two modules on the same image. 现在,我想在同一图像上使用这两个模块。 The code is in python using the keras and tensorflow libraries. 该代码在python中使用keras和tensorflow库。 Two different CNN on the same image 同一张图片上有两个不同的CNN

In tensorflow you need to explicitly specify the computational graph for both of your models. 在tensorflow中,您需要为两个模型明确指定计算图

# build two separate graphs `g1` and `g2`

tf.reset_default_graph()
with tf.Session(graph=g1) as session:
    result = sess.run(detect, feed_dict={x: test_x})
    print(result)

tf.reset_default_graph()
with tf.Session(graph=g2) as session:
    result = sess.run(recognize, feed_dict={x: test_x})
    print(result)

There are also some caveats when multiple graphs are built in one application, see this question . 在一个应用程序中构建多个图形时,也有一些警告,请参见此问题

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

相关问题 卷积神经网络中密集层和输出层的尺寸如何计算? - How to calculate dimensions of the dense and output layer in convolutional neural network? 如何使用CNN训练模型预测输入图像 - How to predict input image with cnn trained model 如何使用 scikit BaggingClassifier 和 keras 卷积神经网络作为基本估计器通过 keras-scikit 包装器进行装袋? - How to do bagging using scikit BaggingClassifier with keras Convolutional Neural Network as base estimator via keras-scikit wrapper? 神经网络 output 的两个错误 - two errors with neural network output 我可以在使用Keras的线性回归中使用神经网络吗? 如果是,如何? - Can I use a neural network on a linear regression using Keras? If yes , How? 如何使用张量流来构建CNN模型,其中每个“分支”都是独立的,直到在最后一步被加入为止? - How to use tensor flow to build a CNN model where each “branch” is separate until being joined at the last step? 在Raspberry Pi上加载经过训练的Keras神经网络模型 - Load a trained Keras neural network model on Raspberry Pi 更改卷积层 CNN 上的过滤器 - Python/TensorFlow - Change filter on convolutional layer CNN - Python/TensorFlow 开发后如何部署神经网络? - How to deploy a neural network after developing it? 如何从神经网络获得准确的预测 - How to get accurate predictions from a neural network
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM