text_plain_output_1.png
from keras.preprocessing.image import ImageDataGenerator,load_img

from tensorflow import keras

from tensorflow.keras.layers import Dense,Flatten

from tensorflow.keras.models import Sequential

train_gen = ImageDataGenerator(rescale=1 / 255.0, validation_split=0.3)
train_data = train_gen.flow_from_directory('/kaggle/input/rice-image-dataset/Rice_Image_Dataset/', target_size=(64, 64), batch_size=1, class_mode='categorical', shuffle=False, subset='training')

test_data = train_gen.flow_from_directory('/kaggle/input/rice-image-dataset/Rice_Image_Dataset/', target_size=(64, 64), batch_size=1, class_mode='categorical', shuffle=False, subset='validation')

train_data.class_indices

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Flatten
model = Sequential()
model.add(Flatten(input_shape=(64, 64, 3)))
model.add(Dense(40, activation='sigmoid'))
model.add(Dense(5, activation='relu'))
model.add(Dense(5, activation='softmax'))
model.summary()

model.compile(loss='categorical_crossentropy', optimizer='adam', metrics='accuracy')

model.fit(train_data, validation_data=test_data, epochs=2)

model = keras.models.load_model('../input/rice-classification/cnn_model.h5')
model.summary()

model.evaluate(test_data)

predict1 = model.predict(test_data).argmax(axis=1)
predict1