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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.