Created
October 31, 2018 08:38
-
-
Save ferhat00/30ccc9fb48ccb0921fdd3c5c4f91c91d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def load_image(img_path, show=False): | |
| img = image.load_img(img_path, target_size=(150, 150)) | |
| img_tensor = image.img_to_array(img) # (height, width, channels) | |
| img_tensor = np.expand_dims(img_tensor, axis=0) # (1, height, width, channels), add a dimension because the model expects this shape: (batch_size, height, width, channels) | |
| img_tensor /= 255. # imshow expects values in the range [0, 1] | |
| if show: | |
| plt.imshow(img_tensor[0]) | |
| plt.axis('off') | |
| plt.show() | |
| return img_tensor | |
| #img_path = 'C:/Users/Ferhat/Python Code/Workshop/Tensoorflow transfer learning/blue_tit.jpg' | |
| img_path = 'C:/Users/Ferhat/Python Code/Workshop/Tensoorflow transfer learning/crow.jpg' | |
| new_image = load_image(img_path) | |
| pred = model.predict(new_image) | |
| pred |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment