How to do it...

We'll code up the strategy that we have defined previously, as follows (the code file is available aImage_captioning.ipynb in GitHub):

  1. Download and import a dataset that contains images and their corresponding captions. The recommended datasets are provided in GitHub
  1. Import the relevant packages, as follows:
import globfrom PIL import Imageimport numpy as npimport matplotlib.pyplot as plt%matplotlib inlineimport picklefrom tqdm import tqdmimport pandas as pdfrom keras.preprocessing import sequencefrom keras.models import Sequentialfrom keras.layers import LSTM, Embedding, TimeDistributed, Dense, RepeatVector, merge, Activation, Flattenfrom keras.optimizers import Adam, RMSpropfrom keras.layers.wrappers import Bidirectional ...

Get Neural Networks with Keras Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.