In the following steps, we load the training and test image datasets and perform training on them:
- 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 ...