Dhamala.Upendra
Dhamala.Upendra

Reputation: 59

Devanagari character recognition

I am trying to build a cnn model for my devanagari character recognition project. Everything is working fine except it show error at validation_data=valid_generator. It displays error like:

UnimplementedError:  Fused conv implementation does not support grouped convolutions for now.

My code is as follows:

from keras.utils import plot_model 
model.compile(
optimizer='adam', 
loss='categorical_crossentropy', 
metrics=['accuracy']) 
data_gen_train = ImageDataGenerator(rescale=1/255)

data_gen_valid = ImageDataGenerator(rescale=1/255)

train_generator = data_gen_train.flow_from_directory(directory="./train2", target_size=(32,32), 
batch_size=32, class_mode="binary")

valid_generator = data_gen_valid.flow_from_directory(directory="./valid2", target_size=(32,32), 
batch_size=32, class_mode="binary")

model.fit(
train_generator,
epochs = 3, 
steps_per_epoch=150,
validation_steps=150,
validation_data=valid_generator) 

Upvotes: 1

Views: 202

Answers (1)

user11530462
user11530462

Reputation:

Specifying the Solution here (Answer Section) even though it is present in the Comments Section, for the benefit of the Community.

The Error,

UnimplementedError:  Fused conv implementation does not support grouped convolutions for now.

arises if we pass the Number of Channels as 1 when the Image actually contains 3 Channels. UnimplementedError: Fused conv implementation does not support grouped convolutions for now.

The problem is resolved by changing the Number of Channels from 1 to 3 i.e., by changing the code from

inputs=Input(shape=(32,32,1))

to

inputs=Input(shape=(32,32,3))

Edit: Adding the Pre_Processing of Image during Predictions.

In order to predict on a New Image, please use the code mentioned below:

IMG_SIZE = 32
image = cv2.imread('ImageFileName.jpg')
image = cv2.resize(image, (IMG_SIZE, IMG_SIZE))
image = new_array / 255
image = image.reshape(-1, IMG_SIZE, IMG_SIZE, 3)

Hope this helps. Happy Learning!

Upvotes: 1

Related Questions