Training

In the following steps, we load the training and test image datasets and perform training on them:

  1. Let's now load the separated training and test files into the dataset. They contain the list of image filenames, which are actually the image IDs with file extensions, as can be seen in the following code block:
train_file = "./data/Flickr8k/text/Flickr_8k.trainImages.txt"test_file = "./data/Flickr8k/text/Flickr_8k.testImages.txt"

Now, we will be processing the train images list file to extract the image IDs, and leave out the file extension since it is the same in all cases, as shown in the following code snippet:

with open(train_file) as f:    cap_train = f.readlines()cap_train = [x.strip() for x in cap_train]

We do the same with the ...

Get Mobile Deep Learning with TensorFlow Lite, ML Kit and Flutter 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.