Yes there sure is  Instead of having imgs as a list, try having it as a deafultdict where the key is the index, and value is a list of images. But, you might want to rethink this a bit. The txt_path is just 8 images and one label right? You have several of these files I suppose? Then you want to put them all in the dataset, no?
This code should get you started.
from collections import defaultdict

dict_imgs = defaultdict(list)
with open(txt_path) as f:
  lines = f.read().splitlines()

dict_imgs[0] = lines # dictimgs will contain 8 image paths & one label