I found that the problem was because in
`data_generator(train_descriptions, train_features, wordtoix, max_length, number_pics_per_bath)` the train_features was blank because no images assigned.
I tried to check where they were from, and found out the train_img from this part since the embedding took nearly no time.
# Call the funtion to encode all the train images
# This will take a while on CPU - Execute this only once
start = time()
encoding_train = {}
for img in train_img:
encoding_train[img[len(images):]] = encode(img)
print("Time taken in seconds =", time()-start)
this was the problem and fixed by fixing the directory
# Below path contains all the images
images = 'Flickr_Data/Images'
# Create a list of all image names in the directory
img = glob.glob(images + '*.jpg')
to
# Below path contains all the images
images = 'Flickr_Data/Images/'
# Create a list of all image names in the directory
img = glob.glob(images + '*.jpg')