{"cells":[{"metadata":{"trusted":true,"_uuid":"4bb9cdac49472979c0742d993d5928760be25645"},"cell_type":"code","source":"img_paths = []\nimg_paths.append('../input/mister-banks-picture/mr_banks.jpg')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ae06e855867297c818d6b65fa96597a5fb1cac97"},"cell_type":"code","source":"import numpy as np\nfrom tensorflow.python.keras.applications.resnet50 import preprocess_input\nfrom tensorflow.python.keras.preprocessing.image import load_img, img_to_array\n\nimage_size = 224\n\ndef read_and_prep_images(img_paths, img_height=image_size, img_width=image_size):\n    imgs = [load_img(img_path, target_size=(img_height, img_width)) for img_path in img_paths]\n    img_array = np.array([img_to_array(img) for img in imgs])\n    output = preprocess_input(img_array)\n    return(output)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a5e6e54f17224607b2a8fd29041473235bed284b"},"cell_type":"code","source":"from tensorflow.python.keras.applications import ResNet50\n\nmy_model = ResNet50(weights='../input/resnet50/resnet50_weights_tf_dim_ordering_tf_kernels.h5')\ntest_data = read_and_prep_images(img_paths)\npreds = my_model.predict(test_data)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"f18959976e96bd28f173ae4e338e4914a98d8cae"},"cell_type":"markdown","source":"### Visualize Predictions"},{"metadata":{"trusted":true,"_uuid":"680e3f7fec652428a11c8723f45d8622e1530af7"},"cell_type":"code","source":"from learntools.deep_learning.decode_predictions import decode_predictions\nfrom IPython.display import Image, display\n\nmost_likely_labels = decode_predictions(preds, top=3, class_list_path='../input/resnet50/imagenet_class_index.json')\n\nfor i, img_path in enumerate(img_paths):\n    display(Image(img_path))\n    print(most_likely_labels[i])","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}