We'll code up the strategy that we have defined previously, as follows (the code file is available as Image_captioning.ipynb in GitHub):
- Download and import a dataset that contains images and their corresponding captions. The recommended datasets are provided in GitHub
- 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 ...