0
$\begingroup$
from keras.models import load_model
from keras.preprocessing import image
import matplotlib.pyplot as plt
import numpy as np
import math
import cv2
import numpy as np
import matplotlib.pyplot as plt
from keras.models import model_from_json
import json

img_width, img_height = 150, 150
with open('model_architecture.json', 'r') as f:
    model = model_from_json(f.read())


model.load_weights('second_try.h5')
model.compile(optimizer='rmsprop', loss='binary_crossentropy', metrics=['accuracy'])
image = cv2.imread('/home/hduser/Desktop/IITDPalmprint/training_data/class1/002_5.bmp', 0).astype(np.float32) / 255
plt.title('image')

kernel = cv2.getGaborKernel((121, 121), 4.0, 0, 10.0, 0.5, 0, cv2.CV_32F)
kernel /= math.sqrt((kernel * kernel).sum())
img1 = cv2.filter2D(image, -1, kernel)
x = image.img_to_array(img1)
$\endgroup$

1 Answer 1

1
$\begingroup$

You are using the variable name image in your code, while you also import a module named image. This conflict results in trying to find img_to_array method in the variable rather than in the module.

Use a different name for you image variable, or directly import the img_to_array function:

from keras.preprocessing.image import img_to_array
[...]
x = img_to_array(img1)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.