How to preprocess data for image classification from a .txt file?
I am assuming from the description inside main directory there are more directories of  Apples, Bananas, Oranges, etc. and inside them you have .txt files containing information about the images.

import shutil

with open(file_path, 'r') as f:
    img_names = f.readlines()
    img_names = [img.strip() for img in img_names]

for i in range(len(img_names)): shutil.move(img_names[i], folder_path)


Once images are moved into there respective folder you can use ImageDataGenerator approach to train model.