Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- test_image = cv2.imread(r'C:UsersShahinur ShakibDownloadsspyder2Datasetstest_setDogelephant.jpg')
- test_image=cv2.cvtColor(test_image, cv2.COLOR_BGR2GRAY)
- test_image=cv2.resize(test_image,(200,200))
- test_image = np.array(test_image)
- test_image = test_image.astype('float32')
- test_image /= 255
- print (test_image.shape)
- if img_channels==1:
- if K.image_dim_ordering()=='th':
- test_image= np.expand_dims(test_image, axis=0)
- test_image= np.expand_dims(test_image, axis=0)
- print (test_image.shape)
- else:
- test_image= np.expand_dims(test_image, axis=3)
- test_image= np.expand_dims(test_image, axis=0)
- print (test_image.shape)
- else:
- if K.image_dim_ordering()=='th':
- test_image=np.rollaxis(test_image,2,0)
- test_image= np.expand_dims(test_image, axis=0)
- print (test_image.shape)
- else:
- test_image= np.expand_dims(test_image, axis=0)
- print (test_image.shape)
- print((model.predict(test_image)))
- print(model.predict_classes(test_image))
- result=model.predict_classes(test_image)
- if(result==0):
- print("Cat")
- elif(result==1):
- print("Dog")
- elif(result==2):
- print("Elephant")
- elif(result==3):
- print("Hen")
- elif(result==4):
- print("Horse")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement