簡體   English   中英

我可以同時用兩個圖像數據集訓練一個 CNN model

[英]Can I train a CNN model with Two Image dataset at the same time

我想同時用兩個圖像數據集訓練一個 CNN model。

Dataset1(RGB-Images[size(64,64,3)]) ->class-1:Fire Class-2:Non_Fire Dataset2(gray_scale-image[size(120,120,1)])->class-1:Fire Class -2:Non_Fire

Model output:火(類)或非火(類)

我的數據集鏈接:Dataset-1:

test_path1='/content/drive/MyDrive/Thesis_Dataset/Devide_Cnn/gt/test'
train_path1='/content/drive/MyDrive/Thesis_Dataset/Devide_Cnn/gt/train'
valid_path1='/content/drive/MyDrive/Thesis_Dataset/Devide_Cnn/gt/valid'

數據集 2:

test_path2='/content/drive/MyDrive/Thesis_Dataset/Devide_Cnn/rgb/test'
train_path2='/content/drive/MyDrive/Thesis_Dataset/Devide_Cnn/rgb/train'
valid_path2='/content/drive/MyDrive/Thesis_Dataset/Devide_Cnn/rgb/valid'

我從 stackoverflow 中找到了示例代碼,其中使用的兩個數據集是非圖像數據,因此我無法理解如何將此代碼應用於我自己的問題。

**誰能幫助我如何使用以下示例代碼對我的兩個數據集運行擬合操作?????????? *你也可以請有人告訴我這種方法是否有助於准確性嗎?

來自 stackoverflow 的示例代碼:(告訴我如何為我的兩個給定圖像數據集運行 fit 操作)

from keras.layers import Conv2D, MaxPooling2D, Input, Dense, Flatten, concatenate
from keras.models import Model
import numpy as np

img_input = Input(shape=(64, 64, 1))  ## branch 1 with image input
x = Conv2D(64, (3, 3))(img_input)
x = Conv2D(64, (3, 3))(x)
x = MaxPooling2D((2, 2))(x)
x = Flatten()(x)
out_a = Dense(64)(x)

num_input = Input(shape=(7,))        ## branch 2 with numerical input
x1 = Dense(8, activation='relu')(num_input)
out_b = Dense(16, activation='relu')(x1)

concatenated = concatenate([out_a, out_b])    ## concatenate the two branches
out = Dense(4, activation='softmax')(concatenated)
model = Model([img_input, num_input], out)
print(model.summary())
model.compile('sgd', 'categorical_crossentropy', ['accuracy'])

### Just for sanity check
X = [np.zeros((1,64,64,1)), np.zeros((1,7))]
y = np.ones((1,4))
model.fit(X, y)
print(model.predict(X))

我認為您可以使用 pandas 數據框,將 Dataset1 和 Dataset2 導入單個數據框,然后將其傳遞到網絡,如果兩個數據集具有完全相同的數據,則可以直接合並兩個數據集。 為了准確性,您必須先提高數據質量,然后再使用神經網絡。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM