简单的CNN模型四个图像输入可检测两个类别

我正在一个项目中,必须使用四个不同的图像作为输入。我将输入通过一个简单的模型运行并检测两个类。我在模型的实际设置中确实很挣扎。 不知道我是否走对了。由于我仍不确定模型的体系结构,因此我无法运行代码。下面的代码是我的模型当前的设置方式。我已经有所有图像了。我拍摄了一张图像并将其拆分为四张。然后使用这四个图像,检测两个类别之一。如果这没有任何意义,或者我对此采取了错误的指导,请提供帮助。'

# import the necessary packages
from keras.models import Sequential
from keras.layers.normalization import BatchNormalization
from keras.layers.convolutional import Conv2D
from keras.layers.convolutional import MaxPooling2D
from keras.layers.core import activation
from keras.layers.core import Dropout
from keras.layers.core import Dense
from keras.layers import flatten
from keras.layers import Input
from keras.models import Model
from keras.layers import Dense,LSTM,concatenate,Input,flatten

from keras.models import Sequential
from keras.preprocessing import image
from keras.layers import Dense,InputLayer,Conv2D,MaxPool2D,flatten
import keras

# define four sets of inputs
inputA = Input(shape=(200,200,3))
inputB = Input(shape=(200,3))
inputC = Input(shape=(200,3))
inputD = Input(shape=(200,3))

# merge all input images
merged = keras.layers.concatenate(axis=1)([inputA,inputB,inputC,inputD])
    
# the first branch operates on the first input through the fourth input
dense1 = keras.layers.Conv2D(16,(2,2),activation='relu')(merged)
output = keras.layers.Conv2D(16,activation='relu')(dense1)
 
# apply a FC layer and then a regression prediction on the
# combined outputs
z = keras.layers.Dense(128,activation="relu")(output)
z = keras.layers.Dense(9,activation="softmax")(z)


# then output a single value then our model will accept the inputs of the two branches and
# model = Model(inputs=[tt.output,y.output,t.output,w.output],outputs=z)
model.compile(loss='categorical_crossentropy',optimizer="adam",metrics=['accuracy'])
model.summary()

我认为模型已正确设置为使用四个图像作为输入运行,但是现在我需要设置类。我的想法是建立一个cnn,以查看同一棵树的四张不同图片。使用那四个图像来检测树的类型。我希望所有四个图像都适合一棵树。然后检测树。在检测到该树之后,移至另一棵树的下四张图像。

谢谢大家,我非常感谢您的所有投入和帮助。

zhuyanjunhunan 回答:简单的CNN模型四个图像输入可检测两个类别

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3070298.html

大家都在问