Skip to content

Instantly share code, notes, and snippets.

@tanmayymishra
Created September 21, 2021 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanmayymishra/7c386605c85c8f4708f39369f7762220 to your computer and use it in GitHub Desktop.
Save tanmayymishra/7c386605c85c8f4708f39369f7762220 to your computer and use it in GitHub Desktop.
tyre
tyre = ["Flat Tyre","Full Tyre","No Tyre"]
def Single_Image_Prediction(file):
#image = load_img(file, color_mode='rgb', target_size=(128, 128))
image= file
plt.imshow(image,cmap= 'gray')
plt.show()
print(image.shape)
# cv.imshow('image',file)
# cv.waitKey(0)
# cv.destroyAllWimdows()
# image = cv.cvtColor(image, cv.COLOR_RGB2GRAY)
img_arr = img_to_array(image)
# img_arr = img_arr/255.
np_image = np.expand_dims(img_arr, axis=0)
return np_image
image = Single_Image_Prediction(val_generator[0][0][11])
pred_value = model.predict(image)
print(pred_value)
index_value = np.argmax(pred_value,axis=1) #For categorical model
print(tyre[index_value[0]])
image = Single_Image_Prediction(val_generator[0][0][12])
pred_value = model.predict(image)
print(pred_value)
index_value = np.argmax(pred_value,axis=1) #For categorical model
print(tyre[index_value[0]])
image = Single_Image_Prediction(val_generator[0][0][0])
pred_value = model.predict(image)
print(pred_value)
index_value = np.argmax(pred_value,axis=1) #For categorical model
print(tyre[index_value[0]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment